Plugins

How to Unit Test CreateMultiple, UpdateMultiple, and UpsertMultiple plugins

Minimum Version: 2.5.0 / 3.5.0

When it comes to unit testing plugins for Bulk Operations, you must be aware that a new interface, IPluginExecutionContext4 exists that you’ll need to use for plugins than run off these messages.

So how does that work with FakeXrmEasy?

XrmFakedPluginExecutionContext4

For simplicity, we extended the context.GetDefaultPluginContext() method to return extra properties that are needed for bulk operations, like the PreEntityImageCollections and PostEntityImageCollections.

The method is still backward compatible with previous unit tests, as none of existing the properties there have changed.

You can for example set a Targets property in the input parameters that the plugin will use.

Or if you need to use the new entity image collections, you can do so as well.

The sample below executes a plugin that will execute a plugin that needs the IPluginExecutionContext4 interface.

You can find the source code here.

Plugin for an xMultiple message

This section covers how to unit test plugins that fire off these multiple requests in isolation from each other.

If you want to explore how to do the same in Pipeline Simulation, please have a look at the next section.