Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

Add RetrieveCurrentOrganizationRequest #478

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -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
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this PR @sulzsolutions-st . However the build is failing, I'm guessing it has to do with the precompilation symbols which will have to be moved to the top of the file, so it'll exclude messages that are not available for earlier versions entirely....

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
}
}
}
1 change: 1 addition & 0 deletions FakeXrmEasy.Shared/FakeXrmEasy.Shared.projitems
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Extensions\XmlExtensionsForFetchXml.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeMessageExecutors\AddListMembersListRequestExecutor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeMessageExecutors\FetchXmlToQueryExpressionRequestExecutor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeMessageExecutors\RetrieveCurrentOrganizationRequestExecutor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeMessageExecutors\RetrieveExchangeRateRequest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeMessageExecutors\BulkDeleteRequestExecutor.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeMessageExecutors\RemoveMembersTeamRequestExecutor.cs" />
Expand Down
4 changes: 4 additions & 0 deletions FakeXrmEasy.Shared/XrmFakedContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ public partial class XrmFakedContext : IXrmContext
private IServiceEndpointNotificationService _serviceEndpointNotificationService;

private readonly Lazy<XrmFakedTracingService> _tracingService = new Lazy<XrmFakedTracingService>(() => new XrmFakedTracingService());
/// <summary>
/// A Dictionary to bring FakeObjects in a PluginPipeLine
/// </summary>
public Dictionary<string, object> FakeObjects { get; set; }

/// <summary>
/// All proxy type assemblies available on mocked database.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
<Compile Include="$(MSBuildThisFileDirectory)FakeContextTests\RemoveFromQueueRequestTests\RemoveFromQueueRequestTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeContextTests\RemoveMembersTeamRequestTests\Tests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeContextTests\RetrieveAttributeRequestTests\RetrieveAttributeRequestTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeContextTests\RetrieveCurrentOrganizationRequestTests\RetrieveCurrentOrganizationRequestTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeContextTests\RetrieveEntityRequestTests\RetrieveEntityRequestTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeContextTests\RetrieveMultiple\QueryLinkEntityTests.cs" />
<Compile Include="$(MSBuildThisFileDirectory)FakeContextTests\RetrieveMultiple\RetrieveMultipleTests.cs" />
Expand Down