public void TestDisassociateWOPrimaryNamePlugin() { using (var context = new Xrm(orgAdminUIService)) { EntityReferenceCollection relatedEntities = new EntityReferenceCollection(); dg_bus bus = new dg_bus { dg_Ticketprice = 1 }; bus.Id = orgAdminService.Create(bus); dg_child child = new dg_child { dg_name = "Margrethe", dg_parentBusId = bus.ToEntityReference() }; child.Id = orgAdminService.Create(child); relatedEntities.Add(new EntityReference(dg_child.EntityLogicalName, child.Id)); Relationship relationship = new Relationship("dg_bus_parental"); orgAdminUIService.Disassociate(dg_bus.EntityLogicalName, bus.Id, relationship, relatedEntities); var retrievedBus = dg_bus.Retrieve(orgAdminService, bus.Id, x => x.dg_Ticketprice); Assert.AreEqual(26, retrievedBus.dg_Ticketprice); } }
public void TestParentChangeCascading() { using (var context = new Xrm(orgAdminUIService)) { var businessunit = new BusinessUnit(); businessunit["name"] = "business unit name 6"; businessunit.Id = orgAdminUIService.Create(businessunit); var parentUser = crm.CreateUser(orgAdminUIService, businessunit.ToEntityReference(), SecurityRoles.Scheduler); var service = crm.CreateOrganizationService(parentUser.Id); var bus = new dg_bus(); bus.Id = service.Create(bus); var parentChild = new dg_child(); parentChild.dg_parentBusId = bus.ToEntityReference(); parentChild.Id = service.Create(parentChild); var otherChild = new dg_child(); otherChild.Id = orgAdminUIService.Create(otherChild); FaultException faultException = null; try { service.Retrieve(otherChild.LogicalName, otherChild.Id, new ColumnSet(true)); Assert.Fail(); } catch (FaultException e) { faultException = e; } otherChild.dg_parentBusId = bus.ToEntityReference(); orgAdminUIService.Update(otherChild); service.Retrieve(otherChild.LogicalName, otherChild.Id, new ColumnSet(true)); } }
public void TestCreateWithUpdate() { var child = new dg_child() { dg_name = "Donald Duck" }; child.Id = orgAdminUIService.Create(child); var resp = dg_child.Retrieve(orgAdminService, child.Id); Assert.Equal("Micky Mouse", resp.dg_name); }