-
Notifications
You must be signed in to change notification settings - Fork 11
Home
Daryl LaBar edited this page Aug 30, 2018
·
3 revisions
- Automated Crm Tests With Open Source Tools - A walk through of how to start using XrmUnitTest, and a comparing it between MSFakes, and FakeXrmEasy:
- Entity Builders - Entity Builders fluent builders that are used to help make Unit Tests DRY and easier to read, by easing the amount of code required to instantiate data. Check out the LeadBuilder in XrmUnitTest.Test.Builder namespace for an example of how to use one, and the DLaB.Xrm.LocalCrm.Tests.LocalCrmDatabaseOrganizationServiceExecuteTests for how it is used:
var lead = new LeadBuilder
{
Lead = new Lead
{
Address1_Line2 = "Test Address1_Line2",
Address1_Line3 = "Test Address1_Line3",
Description = "Test Description",
Fax = "555-555-1234",
JobTitle = "Sales Agent",
LeadSourceCodeEnum = Lead_LeadSourceCode.Advertisement,
PreferredContactMethodCodeEnum = Lead_PreferredContactMethodCode.Phone,
WebSiteUrl = "https://github.com/daryllabar/XrmUnitTest",
TransactionCurrencyId = currency.ToEntityReference()
}
}
.WithAddress1()
.WithAddress2()
.WithDoNotContact(false)
.WithEmail()
.WithName()
.WithPhone()
.Build();
You can see that the lead has some custom attributes that are being set, as well add Address1, Address2, the do not contact fields, Email, Name, and Phone. The test doesn't care what the actual values are, just that they are populated, so this removes the need to have duplicate initialization values throughout your project, as well as makes it extremely readable as to what data you need. Other methods could be added such as .WithFranceAddress() for example, if you need an address that isn't in the United States.
Coming Soon