Если кого-то интересует, последний фрагмент выглядит следующим образом:
var context = new XrmFakedContext { UsePipelineSimulation = true };
context.RegisterPluginStep<Foo, Account>("Create", ProcessingStepStage.Postoperation);
var organizationService = context.GetOrganizationService();
organizationService.Create(new Account { LogicalName = "account" });
И метаданные сущности (все) должны учитываться следующим образом:
[EntityLogicalNameAttribute("account")]
public class Account : Entity
{
[AttributeLogicalName("name")]
public string Name { get; set; }
public int EntityTypeCode;
public Account()
{
this.EntityTypeCode = 1;
}
}
Включая только системные метаданные:
[EntityLogicalName("plugintype")]
public class PluginType : Entity
{
[AttributeLogicalName("plugintypeid")]
public Guid PluginTypeId { get; set; }
[AttributeLogicalName("name")]
public string Name { get; set; }
[AttributeLogicalName("typename")]
public string TypeName { get; set; }
[AttributeLogicalName("assemblyname")]
public string AssemblyName { get; set; }
[AttributeLogicalName("major")]
public int Major { get; set; }
[AttributeLogicalName("minor")]
public int Minor { get; set; }
[AttributeLogicalName("version")]
public string Version { get; set; }
}
[EntityLogicalName("sdkmessage")]
public class SdkMessage : Entity
{
[AttributeLogicalName("sdkmessageid")]
public Guid SdkMessageId { get; set; }
[AttributeLogicalName("name")]
public string Name { get; set; }
}
[EntityLogicalName("sdkmessagefilter")]
public class SdkMessageFilter : Entity
{
[AttributeLogicalName("sdkmessagefilterid")]
public Guid SdkMessageFilterId { get; set; }
[AttributeLogicalName("primaryobjecttypecode")]
public int PrimaryObjectTypeCode { get; set; }
}
[EntityLogicalName("sdkmessageprocessingstep")]
public class SdkMessageProcessingStep : Entity
{
[AttributeLogicalName("configuration")]
public string Configuration { get; set; }
[AttributeLogicalName("eventhandler")]
public EntityReference EventHandler { get; set; }
[AttributeLogicalName("sdkmessageid")]
public EntityReference SdkMessageId { get; set; }
[AttributeLogicalName("sdkmessagefilterid")]
public EntityReference SdkMessageFilterId { get; set; }
[AttributeLogicalName("filteringattributes")]
public string FilteringAttributes { get; set; }
[AttributeLogicalName("mode")]
public OptionSetValue Mode { get; set; }
[AttributeLogicalName("stage")]
public OptionSetValue Stage { get; set; }
[AttributeLogicalName("rank")]
public int Rank { get; set; }
}