public void Test_AddPersistedObject_AddsObjectToCollection_SurvivesRefresh() { //---------------Set up test pack------------------- //The Foreign Key (address.ContactPersonId) should be set up to be // equal to the contactPerson.ContactPersonID //Test that using relationship from contact person so that overcome issues // with reloading all the time. ClassDef.ClassDefs.Clear(); AddressTestBO address; ContactPersonTestBO.CreateContactPersonWithOneAddressTestBO(out address); ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO(); RelatedBusinessObjectCollection <AddressTestBO> addressTestBOS = contactPersonTestBO.AddressTestBOs; addressTestBOS.Add(address); //---------------Assert Precondition---------------- Assert.AreEqual(1, addressTestBOS.AddedBusinessObjects.Count); Assert.AreEqual(1, addressTestBOS.Count); Assert.AreEqual(0, addressTestBOS.PersistedBusinessObjects.Count); //---------------Execute Test ---------------------- addressTestBOS.Refresh(); //---------------Test Result ----------------------- Assert.AreEqual(1, addressTestBOS.AddedBusinessObjects.Count); Assert.AreEqual(1, addressTestBOS.Count); Assert.AreEqual(0, addressTestBOS.PersistedBusinessObjects.Count); }
public void Test_Refresh_W_CreatedBOs_CreatedObjectsStillRespondToEvents() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCollectionWith_OneBO(); ContactPersonTestBO createdCp = cpCol.CreateBusinessObject(); createdCp.Surname = BOTestUtils.RandomString; createdCp.FirstName = BOTestUtils.RandomString; RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- Assert.AreEqual(2, cpCol.Count); Assert.AreEqual(1, cpCol.CreatedBusinessObjects.Count); Assert.AreEqual(1, cpCol.PersistedBusinessObjects.Count); //---------------Execute Test ---------------------- cpCol.Refresh(); createdCp.Save(); //---------------Test Result ----------------------- Assert.AreEqual(2, cpCol.Count); Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count); Assert.AreEqual(2, cpCol.PersistedBusinessObjects.Count); AssertAddedAndRemovedEventsNotFired(); }
public void Test_RefreshCollection_ShouldSetDateTimeLastLoaded() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); AddressTestBO address; ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateContactPersonWithOneAddress_CascadeDelete(out address, TestUtil.GetRandomString()); RelatedBusinessObjectCollection <AddressTestBO> col = new RelatedBusinessObjectCollection <AddressTestBO>(contactPersonTestBO.Relationships["Addresses"]); //---------------Assert Precondition---------------- Assert.IsNull(col.TimeLastLoaded); //---------------Execute Test ---------------------- col.Refresh(); //---------------Test Result ----------------------- Assert.IsNotNull(col.TimeLastLoaded); }
public void Test_Remove_RefreshAll() { //-----Create Test pack--------------------- ContactPersonTestBO cp; RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCol_OneCP(out cp, OrganisationTestBO.CreateSavedOrganisation()); cpCol.Remove(cp); //--------------Assert Preconditions-------- AssertOneObjectInRemovedAndPersistedCollection(cpCol); //-----Run tests---------------------------- cpCol.Refresh(); ////-----Test results------------------------- AssertOneObjectInRemovedAndPersistedCollection(cpCol); }
public void Test_loadedBo_RefreshAll() { //-----Create Test pack--------------------- ContactPersonTestBO cp; RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCol_OneCP(out cp, OrganisationTestBO.CreateSavedOrganisation()); cp.FirstName = TestUtil.GetRandomString(); //--------------Assert Preconditions-------- AssertOneObjectInCurrentAndPersistedCollection(cpCol); //-----Run tests---------------------------- cpCol.Refresh(); ////-----Test results------------------------- AssertOneObjectInCurrentAndPersistedCollection(cpCol); }
public void Test_RemovedBOs_Refresh() { //---------------Set up test pack------------------- ContactPersonTestBO cp; RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCol_OneCP(out cp, OrganisationTestBO.CreateSavedOrganisation()); cpCol.Remove(cp); //---------------Assert Precondition---------------- AssertOneObjectInRemovedAndPersistedCollection(cpCol); Assert.AreEqual(0, cpCol.Count); //---------------Execute Test ---------------------- cpCol.Refresh(); //---------------Test Result ----------------------- AssertOneObjectInRemovedAndPersistedCollection(cpCol); }
public void Test_RefreshAll_W_CreatedBO() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateRelatedCPCol(); cpCol.CreateBusinessObject(); RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- AssertOneObjectInCurrentAndCreatedCollection(cpCol); //---------------Execute Test ---------------------- cpCol.Refresh(); //---------------Test Result ----------------------- AssertOneObjectInCurrentAndCreatedCollection(cpCol); AssertAddedAndRemovedEventsNotFired(); }
public void Test_Refresh_PreservesCreateBusObjectCollection() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); ContactPersonTestBO.LoadClassDefWithAddressesRelationship_DeleteRelated(); ContactPersonTestBO bo = new ContactPersonTestBO(); RelatedBusinessObjectCollection <AddressTestBO> addresses = bo.Addresses; addresses.CreateBusinessObject(); //---------------Assert Precondition---------------- Assert.AreEqual(1, addresses.CreatedBusinessObjects.Count); Assert.AreEqual(1, addresses.Count); Assert.AreEqual(0, addresses.PersistedBusinessObjects.Count); //---------------Execute Test ---------------------- addresses.Refresh(); //---------------Test Result ----------------------- Assert.AreEqual(1, addresses.CreatedBusinessObjects.Count); Assert.AreEqual(1, addresses.Count); Assert.AreEqual(0, addresses.PersistedBusinessObjects.Count); }
public void Test_MarkForDelete_Added_LoadWCriteria_RefreshAll() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol = new RelatedBusinessObjectCollection<ContactPersonTestBO>(GetContactPersonRelationship()); cpCol.Load("Surname=cc", ""); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB"); cpCol.Add(myBO); myBO.MarkForDelete(); util.RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- util.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); //---------------Execute Test ---------------------- cpCol.Refresh(); //---------------Test Result ----------------------- util.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); util.AssertAddedAndRemovedEventsNotFired(); }
public void TestAddMethod_Refresh_LoadWithCriteria_BusinessObject() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol = new RelatedBusinessObjectCollection<ContactPersonTestBO>(GetContactPersonRelationship()); cpCol.Load("Surname='bbb'", ""); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("aaa"); cpCol.Add(myBO); util.RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- util.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); util.AssertAddedAndRemovedEventsNotFired(); //---------------Execute Test ---------------------- cpCol.Refresh(); //---------------Test Result ----------------------- util.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); util.AssertAddedAndRemovedEventsNotFired(); }
public void Test_RefreshCollection_ShouldSetDateTimeLastLoaded() { //---------------Set up test pack------------------- ClassDef.ClassDefs.Clear(); AddressTestBO address; ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateContactPersonWithOneAddress_CascadeDelete(out address, TestUtil.GetRandomString()); RelatedBusinessObjectCollection<AddressTestBO> col = new RelatedBusinessObjectCollection<AddressTestBO>(contactPersonTestBO.Relationships["Addresses"]); //---------------Assert Precondition---------------- Assert.IsNull(col.TimeLastLoaded); //---------------Execute Test ---------------------- col.Refresh(); //---------------Test Result ----------------------- Assert.IsNotNull(col.TimeLastLoaded); }