Skip to content

Commit

Permalink
Added new fake xrm plugin context classes for the new IPluginExecutio…
Browse files Browse the repository at this point in the history
…nContext* interfaces DynamicsValue/fake-xrm-easy#122
  • Loading branch information
jordimontana82 committed Mar 29, 2024
1 parent 75c655a commit c3676aa
Show file tree
Hide file tree
Showing 9 changed files with 165 additions and 7 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## [2.5.0]

### Added

- Added support for new IPluginExecutionContext2, IPluginExecutionContext3, and IPluginExecutionContext4 interfaces

### Changed

- Upgraded dependency "Microsoft.CrmSdk.CoreAssemblies" to 9.0.2.52
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
using System;
using Microsoft.Xrm.Sdk;

namespace FakeXrmEasy.Plugins.PluginExecutionContext
{
/// <summary>
/// Implements IPluginExecutionContext2 interface, an extension of IPluginExecutionContext adding support for azure AAD properties
/// </summary>
public class XrmFakedPluginExecutionContext2: XrmFakedPluginExecutionContext, IPluginExecutionContext2

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2015)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2015)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2013)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2013)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2016)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2016)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext2.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY)

The type or namespace name 'IPluginExecutionContext2' could not be found (are you missing a using directive or an assembly reference?)
{
/// <summary>
/// Gets azure active directory object Id of user.
/// </summary>
public Guid UserAzureActiveDirectoryObjectId { get; set; }

/// <summary>
/// Gets azure active directory object Id of user that initiates web service.
/// </summary>
public Guid InitiatingUserAzureActiveDirectoryObjectId { get; set; }

/// <summary>
/// Gets application Id of user that initiates the plugin (for NON-app user .. it is Guid.Empty)
/// </summary>
public Guid InitiatingUserApplicationId { get; set; }

/// <summary>
/// Gets contactId that got passed for the calls that come from portals client to web service (for NON-portal/Anonymous call, it is guid.Empty)
/// </summary>
public Guid PortalsContactId { get; set; }

/// <summary>
/// Gets a value indicating whether 'True' if the call is originated from Portals client
/// </summary>
public bool IsPortalsClientCall { get; set;}

/// <summary>
/// Default constructor
/// </summary>
public XrmFakedPluginExecutionContext2()
{
UserAzureActiveDirectoryObjectId = Guid.NewGuid();
InitiatingUserAzureActiveDirectoryObjectId = Guid.NewGuid();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
using System;
using Microsoft.Xrm.Sdk;

namespace FakeXrmEasy.Plugins.PluginExecutionContext
{
/// <summary>
/// Implements IPluginExecutionContext2 interface, an extension of IPluginExecutionContext adding support for azure AAD properties
/// </summary>
public class XrmFakedPluginExecutionContext3: XrmFakedPluginExecutionContext2, IPluginExecutionContext3

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2015)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2015)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2013)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2013)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2016)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2016)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 9 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext3.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY)

The type or namespace name 'IPluginExecutionContext3' could not be found (are you missing a using directive or an assembly reference?)
{
/// <summary>
/// Gets id of the authenticated user
/// </summary>
public Guid AuthenticatedUserId { get; }

/// <summary>
/// Default constructor
/// </summary>
public XrmFakedPluginExecutionContext3()
{
AuthenticatedUserId = Guid.NewGuid();
}


}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using Microsoft.Xrm.Sdk;

namespace FakeXrmEasy.Plugins.PluginExecutionContext
{
public class XrmFakedPluginExecutionContext4: XrmFakedPluginExecutionContext3, IPluginExecutionContext4

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2015)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2015)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2013)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2013)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_365)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2016)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_2016)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check failure on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY)

The type or namespace name 'IPluginExecutionContext4' could not be found (are you missing a using directive or an assembly reference?)

Check warning on line 5 in src/FakeXrmEasy.Plugins/PluginExecutionContext/XrmFakedPluginExecutionContext4.cs

View workflow job for this annotation

GitHub Actions / build-windows (FAKE_XRM_EASY_9)

Missing XML comment for publicly visible type or member 'XrmFakedPluginExecutionContext4'
{
/// <summary>
/// Contains a collection of PreEntityImages
/// </summary>
public EntityImageCollection[] PreEntityImagesCollection { get; set; }

/// <summary>
/// Contains a collection of PostEntityImages
/// </summary>
public EntityImageCollection[] PostEntityImagesCollection { get; set; }

/// <summary>
/// Default constructor
/// </summary>
public XrmFakedPluginExecutionContext4()
{
PreEntityImagesCollection = new EntityImageCollection[] {};
PostEntityImagesCollection = new EntityImageCollection[] {};
}

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
using Microsoft.Xrm.Sdk;
using Xunit;

namespace FakeXrmEasy.Plugins.Tests
namespace FakeXrmEasy.Plugins.Tests.XrmFakedPluginExecutionContextTests
{
public class XrmFakedPluginContextPropertiesTests : FakeXrmEasyTestsBase
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using FakeXrmEasy.Plugins.PluginExecutionContext;
using System;
using Xunit;

namespace FakeXrmEasy.Plugins.Tests.XrmFakedPluginExecutionContextTests
{
public class XrmFakedPluginExecutionContext2Tests
{
[Fact]
public void Should_set_default_plugin_context_properties()
{
var plugCtx = new XrmFakedPluginExecutionContext2();

Assert.NotEqual(Guid.Empty, plugCtx.UserAzureActiveDirectoryObjectId);
Assert.NotEqual(Guid.Empty, plugCtx.InitiatingUserAzureActiveDirectoryObjectId);

Assert.Equal(Guid.Empty, plugCtx.InitiatingUserApplicationId);

Assert.False(plugCtx.IsPortalsClientCall);
Assert.Equal(Guid.Empty, plugCtx.PortalsContactId);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using System;
using FakeXrmEasy.Plugins.PluginExecutionContext;
using Xunit;

namespace FakeXrmEasy.Plugins.Tests.XrmFakedPluginExecutionContextTests
{
public class XrmFakedPluginExecutionContext3Tests
{
[Fact]
public void Should_set_default_plugin_context_properties()
{
var plugCtx = new XrmFakedPluginExecutionContext3();

Assert.NotEqual(Guid.Empty, plugCtx.AuthenticatedUserId);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using FakeXrmEasy.Plugins.PluginExecutionContext;
using System;
using Xunit;

namespace FakeXrmEasy.Plugins.Tests.XrmFakedPluginExecutionContextTests
{
public class XrmFakedPluginExecutionContext4Tests
{
[Fact]
public void Should_set_default_plugin_context_properties()
{
var plugCtx = new XrmFakedPluginExecutionContext4();

Assert.NotNull(plugCtx.PreEntityImagesCollection);
Assert.NotNull(plugCtx.PostEntityImagesCollection);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
using FakeXrmEasy.Plugins;
using Crm;

namespace FakeXrmEasy.Abstractions.Tests.Plugins
namespace FakeXrmEasy.Plugins.Tests.XrmFakedPluginExecutionContextTests
{
public class XrmFakedPluginExecutionContextTests
{
Expand Down Expand Up @@ -42,13 +42,12 @@ public void Should_set_default_plugin_context_in_transaction_based_on_stage_and_
[Fact]
public void Should_set_default_plugin_context_with_custom_properties()
{

var plugCtx = new XrmFakedPluginExecutionContext();

var operationCreatedOn = DateTime.UtcNow;
var businessUnitId = Guid.NewGuid();
var correlationId = Guid.NewGuid();
var initiatinUserId = Guid.NewGuid();
var initiatingUserId = Guid.NewGuid();
var inputParameters = new ParameterCollection();
var outputParameters = new ParameterCollection();
var sharedVariables = new ParameterCollection();
Expand All @@ -65,7 +64,7 @@ public void Should_set_default_plugin_context_with_custom_properties()
plugCtx.BusinessUnitId = businessUnitId;
plugCtx.CorrelationId = correlationId;
plugCtx.Depth = 2;
plugCtx.InitiatingUserId = initiatinUserId;
plugCtx.InitiatingUserId = initiatingUserId;
plugCtx.InputParameters = inputParameters;
plugCtx.IsOfflinePlayback = false;
plugCtx.IsolationMode = (int) PluginAssemblyIsolationMode.None;
Expand All @@ -91,7 +90,7 @@ public void Should_set_default_plugin_context_with_custom_properties()
Assert.Equal(businessUnitId, plugCtx.BusinessUnitId);
Assert.Equal(correlationId, plugCtx.CorrelationId);
Assert.Equal(2, plugCtx.Depth);
Assert.Equal(initiatinUserId, plugCtx.InitiatingUserId);
Assert.Equal(initiatingUserId, plugCtx.InitiatingUserId);
Assert.Equal(inputParameters, plugCtx.InputParameters);
Assert.False(plugCtx.IsOfflinePlayback);
Assert.Equal((int) PluginAssemblyIsolationMode.None, plugCtx.IsolationMode);
Expand All @@ -113,7 +112,6 @@ public void Should_set_default_plugin_context_with_custom_properties()
Assert.Equal(userId, plugCtx.UserId);
Assert.Equal(parentPluginContext, plugCtx.ParentContext);
Assert.Equal((int) ProcessingStepStage.Preoperation, plugCtx.Stage);

}

[Fact]
Expand Down

0 comments on commit c3676aa

Please sign in to comment.