What is FakeXrmEasy?
FakeXrmEasy is a set of libraries that mimic a CRM workflow operating environment. Using the framework allows a developer to write code against a shell CRM system. This code can be used to test software without ever having it interact with a CRM environment.
You can write tests with FakeXrmEasy by creating its "fake" Service Context, then making CRM API calls to it from your code.
var context = new XrmFakedContext();
var service = context.GetFakedOrganizationService();
For each test, load sample data into your Fake CRM Context to use with your Workflow Activity
var context = new XrmFakedContext { ProxyTypesAssembly = Assembly.GetExecutingAssembly() };
var service = context.GetFakedOrganizationService();
service.Create(new Contact { FirstName = "Jimmy" });
Setting up the Unit Testing Project
To start writing Unit Tests for your code, open your Solution in Visual Studio and add a Unit Test Project.
Once the Testing Project is added, you can run these commands on the NuGet Package Manager Console to install the References for the FakeXrmEasy Framework.
// Install-Package FakeXrmEasy //For Dynamics CRM 2011
// Install-Package FakeXrmEasy.2013 //For Dynamics CRM 2013
// Install-Package FakeXrmEasy.2015 //For Dynamics CRM 2015
// Install-Package FakeXrmEasy.2016 //For Dynamics CRM 2016
// and this... //
// Install-Package xunit -Version 1.9.2
// Install-Package xunit.runner.visualstudio
With the packages installed, you can start writing tests! Remember to reference your CRM Custom Activity Library and start testing. See the FakeXrmEasy website and CRMUG for some examples.
Thanks for Reading, and may your Unit Testing be a Success!
Beringer Associates, a Microsoft Gold Certified Partner, is always here to provide expert knowledge in topics like these. Please contact us with any questions you may have.
You must be logged in to post a comment.