-
Notifications
You must be signed in to change notification settings - Fork 17
Open
Description
Minimal test case:
using FakeXrmEasy.Abstractions.Enums;
using FakeXrmEasy.Middleware;
using FakeXrmEasy.Middleware.Crud;
using FakeXrmEasy.Middleware.Messages;
using FakeXrmEasy.Middleware.Pipeline;
using FakeXrmEasy.Pipeline;
using FakeXrmEasy.Plugins.PluginSteps;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Microsoft.Xrm.Sdk;
using System;
using SIT.Core.Plugins.Entities;
namespace SIT.Core.Plugins.Tests;
[TestClass]
public class TestClass
{
public class TestPlugin : IPlugin
{
public void Execute(IServiceProvider serviceProvider)
{
var context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
var tracing = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
var target = (Entity)context.InputParameters["Target"];
tracing.Trace($"Entity Logical Name: {target.LogicalName}");
tracing.Trace($"Entity ID: {target.Id}");
}
}
[TestMethod]
public void Test()
{
// Arange
var context = MiddlewareBuilder
.New()
.AddCrud()
.AddFakeMessageExecutors()
.AddGenericFakeMessageExecutors()
.AddPipelineSimulation()
.UsePipelineSimulation()
.UseCrud()
.UseMessages()
.SetLicense(FakeXrmEasyLicense.RPL_1_5)
.Build();
context.RegisterPluginStep<TestPlugin>(new PluginStepDefinition()
{
MessageName = "Create",
EntityLogicalName = Contact.EntityLogicalName,
Stage = FakeXrmEasy.Abstractions.Plugins.Enums.ProcessingStepStage.Postoperation,
});
// Act
var service = context.GetOrganizationService();
var contactId = service.Create(new Contact());
// Assert
var trace = context.GetTracingService().DumpTrace().Split([Environment.NewLine], StringSplitOptions.RemoveEmptyEntries);
Assert.AreEqual($"Entity Logical Name: {Contact.EntityLogicalName}", trace[0]);
Assert.AreEqual($"Entity ID: {contactId}", trace[1]);
}
}might be similar to #162
Fails with
Assert.AreEqual failed. String lengths are both 47 but differ at index 11. 'expected' expression: '$"Entity ID: {contactId}"', 'actual' expression: 'trace[1]'.
Expected: "Entity ID: 5ddeb8c5-3ed8-4e15-ac52-bc3..."
But was: "Entity ID: 00000000-0000-0000-0000-000..."
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels