-
Notifications
You must be signed in to change notification settings - Fork 180
How to Mock IorganiationService.Retrieve & RetrieveMultiple methods #68
Comments
Hi @krishire You don't need to mock those methods, they are already "mocked", which is the point of the framework. The only thing you need to do is to get an instance of a fake organization service like this
|
Many Thanks Jordi, just realised that, thanks for your immediately reply. |
No worries |
fakedContext.GetDefaultPluginContext().InitiatingUserId and PluginExecutionContext.InitiatingUserId within the plugin code are not matching, any idea. |
Hi @krishire Could you please provide a unit test to reproduce this? From the GetDefaultPluginContext implementation, it should retrieve the one you passed to the context, or, a default one, if it was empty |
Thanks a lot Again Jordi, found the issue in my code, re-initialised the initiatingUserId in the context, after creating the required base record using the default plugin context's intiatingUserId value. |
Grand! You're welcome. |
I have started using FakeXrmEasy but struggling to Mock the retrieve method of the FakedOrganisationService object. Earlier I was using in this fashion base.OrganizationServiceMock.Setup(t =>
t.Retrieve(It.Is(s => s == "systemuser"),
It.IsAny(),
It.IsAny<Microsoft.Xrm.Sdk.Query.ColumnSet>())) // don't care about a specific ColumnSet
.Returns(activeUserNameMock);
Please provide some sample on how to implement the proxy retrieve method.
Basically, In my actual plugin code, I'm retrieving the SystemUser entity for an user in this fashion:
Entity userName = service.Retrieve("systemuser", userId, new Microsoft.Xrm.Sdk.Query.ColumnSet(new[] { "domainname", "fullname" }));
The text was updated successfully, but these errors were encountered: