-
Notifications
You must be signed in to change notification settings - Fork 28
Example: Time Control
When an account is created, wait until a name is set on it and the currency is danish. Then append the name with itself and wait 2 days. After that, set the name to "qwerty".
The following test ensures the specification is met. The code shown in this example will use our early-bound context generator, XrmContext. We use this, since it has some great features compared to CrmSvcUtil. For a comparison, look at https://github.com/delegateas/XrmContext/wiki/functionality
[TestMethod]
public void TestTimeWorkflow() {
using (var context = new Xrm(orgAdminUIService)) {
var acc = new Account();
acc.Id = orgAdminUIService.Create(acc);
var retrieved = orgAdminUIService.Retrieve(Account.EntityLogicalName, acc.Id, new ColumnSet(true)) as Account;
Assert.IsNull(retrieved.Name);
acc.Name = "Some name";
orgAdminUIService.Update(acc);
retrieved = orgAdminUIService.Retrieve(Account.EntityLogicalName, acc.Id, new ColumnSet(true)) as Account;
Assert.AreEqual(acc.Name + acc.Name, retrieved.Name);
crm.AddDays(1);
retrieved = orgAdminUIService.Retrieve(Account.EntityLogicalName, acc.Id, new ColumnSet(true)) as Account;
Assert.AreNotEqual("qwerty", retrieved.Description);
crm.AddDays(2);
retrieved = orgAdminUIService.Retrieve(Account.EntityLogicalName, acc.Id, new ColumnSet(true)) as Account;
Assert.AreEqual("qwerty", retrieved.Description);
}
}
A workflow is created, which triggers according to the specification, this workflow is shown below.
Then the MetadataGenerator is run to include the new workflow in the metadata, after which the test is green. Notice that XrmMockup automatically runs your waiting workflows and you have the ability to control time by adding time to XrmMockup.
Getting started
General
Examples
Contribute