public void Test_loadedBo_RestoreAll() { //-----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.CancelEdits(); ////-----Test results------------------------- AssertOneObjectInCurrentAndPersistedCollection(cpCol); }
public void Test_MarkForDeleteBO_RestoreAll() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCollectionWith_OneBO(OrganisationTestBO.CreateSavedOrganisation()); ContactPersonTestBO cp = cpCol[0]; cpCol.MarkForDelete(cp); //---------------Assert Precondition---------------- AssertOnePersisted_OneMarkForDelete(cpCol); //---------------Execute Test ---------------------- cpCol.CancelEdits(); //---------------Test Result ----------------------- AssertOneObjectInCurrentAndPersistedCollection(cpCol); Assert.IsTrue(cpCol.Contains(cp)); }
public void Test_Remove_RestoreAll() { //-----Create Test pack--------------------- ContactPersonTestBO cp; RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCol_OneCP(out cp, OrganisationTestBO.CreateSavedOrganisation()); cpCol.Remove(cp); _addedEventFired = false; cpCol.BusinessObjectAdded += delegate { _addedEventFired = true; }; //--------------Assert Preconditions-------- AssertOneObjectInRemovedAndPersistedCollection(cpCol); Assert.IsFalse(_addedEventFired); //-----Run tests---------------------------- cpCol.CancelEdits(); //-----Test results------------------------- AssertOneObjectInCurrentAndPersistedCollection(cpCol); Assert.IsTrue(_addedEventFired); }
public void Test_CreatedBusinessObject_RestoredAll() { //---------------Set up test pack------------------- //ContactPersonTestBO.LoadDefaultClassDef(); RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateRelatedCPCol(); ContactPersonTestBO newCP = cpCol.CreateBusinessObject(); newCP.Surname = TestUtil.GetRandomString(); RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- AssertOneObjectInCurrentAndCreatedCollection(cpCol); //---------------Execute Test ---------------------- cpCol.CancelEdits(); //---------------Test Result ----------------------- AssertAllCollectionsHaveNoItems(cpCol); AssertRemovedEventFired(); }
public void Test_MarkForDelete_Added_RestoreAll() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol = new RelatedBusinessObjectCollection<ContactPersonTestBO>(GetContactPersonRelationship()); 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.CancelEdits(); //---------------Test Result ----------------------- util.AssertAllCollectionsHaveNoItems(cpCol); Assert.IsFalse(myBO.Status.IsDirty); util.AssertAddedEventFired(); util.AssertRemovedEventFired(); }
Test_FixBug_AddMethod_RestoreNewCollection_WhenObjectWasOnPreviousRelationshipShouldRestoreToPrevious() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol = new RelatedBusinessObjectCollection<ContactPersonTestBO>(GetContactPersonRelationship()); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(myBO); myBO.Surname = TestUtil.GetRandomString(); myBO.Save(); Guid? origionalOrganisationID = myBO.OrganisationID; OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); MultipleRelationship<ContactPersonTestBO> contactPeopleRel = organisationTestBO.Relationships.GetMultiple<ContactPersonTestBO>("ContactPeople"); RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol2 = new RelatedBusinessObjectCollection<ContactPersonTestBO>(contactPeopleRel); cpCol.Remove(myBO); cpCol2.Add(myBO); //---------------Assert Precondition---------------- util.AssertOneObjectInRemovedAndPersisted(cpCol); util.AssertOneObjectInCurrentAndAddedCollection(cpCol2); Assert.IsTrue(myBO.Status.IsDirty); // util.AssertAddedAndRemovedEventsNotFired(); Assert.AreEqual(organisationTestBO.OrganisationID, myBO.OrganisationID); Assert.AreNotEqual(origionalOrganisationID, myBO.OrganisationID); //---------------Execute Test ---------------------- cpCol2.CancelEdits(); //---------------Test Result ----------------------- Assert.IsFalse(myBO.Status.IsDirty); // util.AssertAddedAndRemovedEventsNotFired(); Assert.AreNotEqual(organisationTestBO.OrganisationID, myBO.OrganisationID); Assert.AreEqual(origionalOrganisationID, myBO.OrganisationID); util.AssertOneObjectInCurrentPersistedCollection(cpCol); util.AssertAllCollectionsHaveNoItems(cpCol2); }
public void Test_Add_PersistedBO_RestoreAll() { //---------------Set up test pack------------------- //The persisted objects are added to the added cpCollection // when restore is called the added objects should be removed from the cpCollection. RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol = new RelatedBusinessObjectCollection<ContactPersonTestBO>(GetContactPersonRelationship()); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); ContactPersonTestBO myBO2 = ContactPersonTestBO.CreateSavedContactPerson(); ContactPersonTestBO myBO3 = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(myBO, myBO2, myBO3); util.RegisterForRemovedEvent(cpCol); //-------Assert Preconditions Assert.AreEqual(3, cpCol.Count, "Three objects should be in the copied cpCollection"); Assert.AreEqual(3, cpCol.AddedBusinessObjects.Count, "Three objects should be in the cpCollection"); Assert.IsFalse(util.RemovedEventFired); Assert.IsNotNull(myBO.OrganisationID); Assert.IsTrue(myBO.Status.IsDirty); //---------------Execute Test ---------------------- cpCol.CancelEdits(); //---------------Test Result ----------------------- - Result util.AssertAllCollectionsHaveNoItems(cpCol); Assert.IsNull(myBO.OrganisationID); Assert.IsTrue(util.RemovedEventFired); }