public void TestRefreshWithRemovedChild() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); AddressTestBO address; ContactPersonTestBO cp = ContactPersonTestBO.CreateContactPersonWithOneAddress_DeleteDoNothing(out address); //---------------Assert Precondition---------------- Assert.AreEqual(1, cp.Addresses.Count); //---------------Execute Test ---------------------- address.MarkForDelete(); address.Save(); //---------------Test Result ----------------------- Assert.AreEqual(0, cp.Addresses.Count); }
public void Test_EditableGridIsPopulated() { //---------------Set up test pack------------------- IEditableGridControl editableGrid = GetControlFactory().CreateEditableGridControl(); const string propName = "Addresses"; EditableGridControlMapper mapper = new EditableGridControlMapper(editableGrid, propName, false, GetControlFactory()); AddressTestBO address; ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateContactPersonWithOneAddress_DeleteDoNothing(out address); //---------------Assert PreConditions--------------- Assert.AreEqual(1, contactPersonTestBO.Addresses.Count); //---------------Execute Test ---------------------- mapper.BusinessObject = contactPersonTestBO; //---------------Test Result ----------------------- Assert.AreSame(contactPersonTestBO.Addresses, editableGrid.Grid.BusinessObjectCollection); }
public void TestRefreshWithRemovedChild_DereferenceChild() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); AddressTestBO address; ContactPersonTestBO cp = ContactPersonTestBO.CreateContactPersonWithOneAddress_DeleteDoNothing(out address); ContactPersonTestBO cp2 = new ContactPersonTestBO(); cp2.Surname = Guid.NewGuid().ToString("N"); cp2.FirstName = Guid.NewGuid().ToString("N"); cp2.Save(); //---------------Assert Precondition---------------- Assert.AreEqual(1, cp.Addresses.Count); //---------------Execute Test ---------------------- address.ContactPersonID = cp2.ContactPersonID; address.Save(); address.SetDeletable(false); RelatedBusinessObjectCollection <AddressTestBO> addresses = cp.Addresses; //---------------Test Result ----------------------- Assert.AreEqual(0, addresses.Count); }