Skip to content
Thomas Malowanczyk edited this page Jun 20, 2018 · 3 revisions

How does FakeXrmEasy relate to XrmMockup?

FakeXrmEasy approaches testing by forcing you to Mock everything yourself. XrmMockup has already mocked everything, which allows you to just write tests. This means all your processes can call each other - just like your real CRM system. The reasoning is that the real complexity of a CRM system comes from the chaining of processes, therefore XrmMockup tests the actual effects of your code in your system, which FakeXrmEasy does not completely do.

In addition, XrmMockup supports testing with security roles and testing Workflows, which is unsupported by FakeXrmEasy.

Where are my traces?

What do you need traces for when you can place breakpoints in your code? Anyway, XrmMockup writes all traces to the console, so it should be visible in your test framework. In MsTest, an output link is visible under each test result.

I got "Unable to cast object of type 'Microsoft.Xrm.Sdk.Entity' to type 'Db.Crm.Context.Account"

This error is the result of the test using a context that XrmMockup is not aware of. This can either be because EnableProxyTypes is not set to true or it can be that XrmMockup can't find your context through the plugin assemblies you have provided through the settings.

Make sure the context used in your test is referenced in the project of at least one of the plugins given to XrmMockup. Next make sure the plugins that are given to XrmMockup are base classes of your plugins.

If you do not have a base plugin class then a temporary fix is to reference an instance of an entity generated by your context. In this case XrmMockup will directly find your proxytypes, instead of indirectly through your plugins.

My user / team have no security roles - how do I add them?

XrmMockup have helper functions called createUser and createTeam which allows you to create users or teams with specific businesunits and security roles. They require an IOrganizationService to create the record, a reference to a businessunit (like the one given by .RootBusinessUnit and a series of security roles found in Metadata/TypeDeclaration.cs, which can by accessed in the struct DG.Tools.XrmMockup.SecurityRoles.XXXX.

The functions return a retrieve result of the created user / team.

Note that XrmMockup currently only supports owner teams. Not Access teams.

The metadata generator seems to include to many entities, why?

The MetadataGenerator fetches as many entities as possible. Thus the entities given by the entities and solutions parameters are combined, as well as any entities given by any context that is referenced - unless the fetchFromAssemblies setting is set to false.

Does XrmMockup support actions?

Yes, open the TestAction.cs file to see examples of tests using actions.