public TestManipulator(UnswerManipalatorI unswerManipalator, GoTestQueryConfiguratorI goTestQueryConfigurator, QuestionManipulatorI questionManipulator) { testloader = new TestLoader(unswerManipalator, goTestQueryConfigurator, questionManipulator); testUpdater = new TestUpdater(unswerManipalator, goTestQueryConfigurator, questionManipulator); testCreator = new TestCreator(unswerManipalator, goTestQueryConfigurator, questionManipulator); }
protected override void Test(IOrganizationService service) { service = new OrganizationServiceBuilder(service).WithIdsDefaultedForCreate(Ids.Contact).Build(); var entity = new Contact { Address1_City = "Any Town", Address1_AddressTypeCodeEnum = Contact_Address1_AddressTypeCode.Primary, FirstName = "Hi", LastName = "Yah", NumberOfChildren = 3, }; // Should Create service.CreateOrMinimumUpdate(entity); AssertCrm.Exists(Ids.Contact); // Should not update or create var readOnly = new OrganizationServiceBuilder(service).IsReadOnly().Build(); readOnly.CreateOrMinimumUpdate(entity); // Should update only single value; var entitiesById = new Dictionary <Guid, Contact> { { entity.Id, entity.Clone(true) } }; entity.Address1_Country = "USA"; var updater = new TestUpdater(entitiesById); service.CreateOrMinimumUpdate(entity, updater); var unchanged = updater.MostRecentUnchangedAttributes; Assert.AreEqual(5, unchanged.Count); AssertContains(unchanged, Contact.Fields.Address1_City); AssertContains(unchanged, Contact.Fields.NumberOfChildren); AssertContains(unchanged, Contact.Fields.Address1_AddressTypeCode); AssertContains(unchanged, Contact.Fields.FirstName); AssertContains(unchanged, Contact.Fields.LastName); Assert.IsFalse(unchanged.Contains(Contact.Fields.Address1_Country)); // No existing, should Update everything: updater.MostRecentUnchangedAttributes.Clear(); service.CreateOrMinimumUpdate(new Contact { Id = Ids.Contact, FirstName = "Updated" }, new Dictionary <Guid, Contact>()); Assert.AreEqual(0, updater.MostRecentUnchangedAttributes.Count); var value = service.GetEntity(Ids.Contact); Assert.AreEqual("Updated", value.FirstName); }