diff --git a/FakeXrmEasy.Shared/FakeMessageExecutors/RetrieveCurrentOrganizationRequestExecutor.cs b/FakeXrmEasy.Shared/FakeMessageExecutors/RetrieveCurrentOrganizationRequestExecutor.cs new file mode 100644 index 00000000..55d982d6 --- /dev/null +++ b/FakeXrmEasy.Shared/FakeMessageExecutors/RetrieveCurrentOrganizationRequestExecutor.cs @@ -0,0 +1,55 @@ +using Microsoft.Xrm.Sdk; +using Microsoft.Crm.Sdk.Messages; +using System; +using System.Collections.Generic; +using System.Text; + +namespace FakeXrmEasy.FakeMessageExecutors +{ + public class RetrieveCurrentOrganizationRequestExecutor : IFakeMessageExecutor + { + public bool CanExecute(OrganizationRequest request) + { +#if FAKE_XRM_EASY || FAKE_XRM_EASY_2013 + return false; +#else + return request is RetrieveCurrentOrganizationRequest; +#endif + } + + public OrganizationResponse Execute(OrganizationRequest request, XrmFakedContext ctx) + { +#if !FAKE_XRM_EASY && !FAKE_XRM_EASY_2013 + RetrieveCurrentOrganizationRequest createRequest = (RetrieveCurrentOrganizationRequest)request; + + var service = ctx.GetOrganizationService(); + + return new RetrieveCurrentOrganizationResponse() + { + ResponseName = "RetrieveCurrentOrganization", + Results = new ParameterCollection { { "Detail" , + new Microsoft.Xrm.Sdk.Organization.OrganizationDetail() + { + OrganizationId = new Guid("59115200-433D-4E75-9351-0AC8602C1890"), + OrganizationVersion = "9.0.3.7", + UniqueName = "FakeXRM", + State = Microsoft.Xrm.Sdk.Organization.OrganizationState.Enabled, + FriendlyName = "FakeXRM", + + }} } + }; +#else + throw new NotImplementedException("The Request RetrieveCurrentOrganizationRequest is not working on this CRM Version"); +#endif + } + + public Type GetResponsibleRequestType() + { +#if FAKE_XRM_EASY || FAKE_XRM_EASY_2013 + throw new NotImplementedException("The Request RetrieveCurrentOrganizationRequest is not working on this CRM Version"); +#else + return typeof(RetrieveCurrentOrganizationRequest); +#endif + } + } +} diff --git a/FakeXrmEasy.Shared/FakeXrmEasy.Shared.projitems b/FakeXrmEasy.Shared/FakeXrmEasy.Shared.projitems index bdba655d..3e65a485 100644 --- a/FakeXrmEasy.Shared/FakeXrmEasy.Shared.projitems +++ b/FakeXrmEasy.Shared/FakeXrmEasy.Shared.projitems @@ -23,6 +23,7 @@ + diff --git a/FakeXrmEasy.Shared/XrmFakedContext.cs b/FakeXrmEasy.Shared/XrmFakedContext.cs index 48fddb6e..4ca28b16 100644 --- a/FakeXrmEasy.Shared/XrmFakedContext.cs +++ b/FakeXrmEasy.Shared/XrmFakedContext.cs @@ -25,6 +25,10 @@ public partial class XrmFakedContext : IXrmContext private IServiceEndpointNotificationService _serviceEndpointNotificationService; private readonly Lazy _tracingService = new Lazy(() => new XrmFakedTracingService()); + /// + /// A Dictionary to bring FakeObjects in a PluginPipeLine + /// + public Dictionary FakeObjects { get; set; } /// /// All proxy type assemblies available on mocked database. diff --git a/FakeXrmEasy.Tests.Shared/FakeContextTests/RetrieveCurrentOrganizationRequestTests/RetrieveCurrentOrganizationRequestTest.cs b/FakeXrmEasy.Tests.Shared/FakeContextTests/RetrieveCurrentOrganizationRequestTests/RetrieveCurrentOrganizationRequestTest.cs new file mode 100644 index 00000000..1042e27f --- /dev/null +++ b/FakeXrmEasy.Tests.Shared/FakeContextTests/RetrieveCurrentOrganizationRequestTests/RetrieveCurrentOrganizationRequestTest.cs @@ -0,0 +1,26 @@ +using Microsoft.Crm.Sdk.Messages; +using System; +using Xunit; + +namespace FakeXrmEasy.Tests.FakeContextTests.RetrieveCurrentOrganizationRequestTests +{ + public class RetrieveCurrentOrganizationRequestTest + { + [Fact] + public void RetrieveCurrentOrganization_Rrequest() + { +#if !FAKE_XRM_EASY && !FAKE_XRM_EASY_2013 + var ctx = new XrmFakedContext(); + var service = ctx.GetFakedOrganizationService(); + + var req = new RetrieveCurrentOrganizationRequest() + { + + }; + + var ex = Record.Exception(() => service.Execute(req)); + Assert.Null(ex); +#endif + } + } +} diff --git a/FakeXrmEasy.Tests.Shared/FakeXrmEasy.Tests.Shared.projitems b/FakeXrmEasy.Tests.Shared/FakeXrmEasy.Tests.Shared.projitems index 4f3a3fed..f5331291 100644 --- a/FakeXrmEasy.Tests.Shared/FakeXrmEasy.Tests.Shared.projitems +++ b/FakeXrmEasy.Tests.Shared/FakeXrmEasy.Tests.Shared.projitems @@ -78,6 +78,7 @@ +