Pipeline Simulation Basics

Pipeline Simulation is an advanced feature of FakeXrmEasy.

With Pipeline Simulation enabled, FakeXrmEasy will automatically fire plugin executions as long as these plugins are registered as plugin steps in FakeXrmEasy.

The plugin steps need to be registered manually right now, in a future version these will be automatically registered based on attributes.

In order to use Pipeline Simulation, you need to enable it in the middleware first:

Setup Pipeline Simulation in Middleware

The UsePipelineSimulation() needs to be put in front of every other middleware step so it would fire any PreOperation steps before any other message.

Every time a request is executed, FakeXrmEasy will determine if there is an appropiate plugin registered for that request, and will execute it accordingly.

See section below about how to register plugin steps in FakeXrmEasy.

public class FakeXrmEasyPipelineTestsBase
    protected readonly IXrmFakedContext _context;
    protected readonly IOrganizationService _service;

    public FakeXrmEasyPipelineTestsBase() 
        _context = MiddlewareBuilder




        _service = _context.GetAsyncOrganizationService();

Registering Plugin Steps

In order to register plugins you can use the RegisterPluginStep method, with different overloads.

A very simple way of registering a plugin step is like the one below, which would register the AccountNumberPlugin against the PreOperation of the Create message.

This will fire this plugin against the Create message of any entity.

using FakeXrmEasy.Pipeline;

public class PipelineTests: FakeXrmEasyPipelineTestsBase
    public void Should_set_account_number_on_account_create() 
        _context.RegisterPluginStep<AccountNumberPlugin>("Create", ProcessingStepStage.Preoperation);


        var account = _context.CreateQuery<Account>().FirstOrDefault();

There is a separate overload where you could specify for which entity should fire the message, i.e.:

_context.RegisterPluginStep<AccountNumberPlugin, Account>("Create");

The methods allow passing in other properties, like filtering attributes, rank (the order of execution), and so on.