public void Test_Remove_SaveAll() { //-----Create Test pack--------------------- ContactPersonTestBO cp; RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCol_OneCP(out cp, OrganisationTestBO.CreateSavedOrganisation()); //--------------Assert Preconditions-------- AssertOneObjectInCurrentAndPersistedCollection(cpCol); //-----Run tests---------------------------- cpCol.Remove(cp); cpCol.SaveAll(); ////-----Test results------------------------- AssertAllCollectionsHaveNoItems(cpCol); Assert.IsFalse(cp.Status.IsDirty); Assert.IsNull(cp.OrganisationID); }
public void Test_MarkForDeleteBO_SaveAll() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCollectionWith_OneBO(OrganisationTestBO.CreateSavedOrganisation()); ContactPersonTestBO cp = cpCol[0]; //---------------Assert Precondition---------------- AssertOneObjectInCurrentAndPersistedCollection(cpCol); Assert.IsTrue(cpCol.Contains(cp)); //---------------Execute Test ---------------------- cpCol.MarkForDelete(cp); cpCol.SaveAll(); //---------------Test Result ----------------------- AssertAllCollectionsHaveNoItems(cpCol); Assert.IsFalse(cpCol.Contains(cp)); Assert.IsTrue(cp.Status.IsDeleted); Assert.IsTrue(cp.Status.IsNew); }
public void Test_CreatedBusinessObject_SaveAll() { //Saving a created business object should remove the business // object from the created col. it should still exist in // the main collection and should be added to the persisted collection //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); IMultipleRelationship cpRelationship = (IMultipleRelationship)organisationTestBO.Relationships["ContactPeople"]; RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = new RelatedBusinessObjectCollection <ContactPersonTestBO>(cpRelationship); cpCol.LoadAll(); ContactPersonTestBO newCP = cpCol.CreateBusinessObject(); newCP.Surname = TestUtil.GetRandomString(); newCP.FirstName = TestUtil.GetRandomString(); RegisterForAddedEvent(cpCol); //---------------Assert Preconditions -------------- Assert.IsFalse(_addedEventFired); Assert.AreEqual(InsertParentAction.InsertRelationship, cpRelationship.RelationshipDef.InsertParentAction); AssertOneObjectInCurrentAndCreatedCollection(cpCol); //---------------Execute Test ---------------------- cpCol.SaveAll(); //---------------Test Result ----------------------- Assert.IsFalse(_addedEventFired); Assert.Contains(newCP, cpCol); AssertOneObjectInCurrentAndPersistedCollection(cpCol); Assert.IsFalse(newCP.Status.IsNew); Assert.IsFalse(newCP.Status.IsDirty); }
public void TestAddMethod_SaveAllBusinessObject() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol = new RelatedBusinessObjectCollection<ContactPersonTestBO>(GetContactPersonRelationship()); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(myBO); myBO.Surname = TestUtil.GetRandomString(); util.RegisterForAddedEvent(cpCol); //---------------Assert Precondition---------------- util.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); Assert.IsFalse(util.AddedEventFired); //---------------Execute Test ---------------------- cpCol.SaveAll(); //---------------Test Result ----------------------- util.AssertOneObjectInCurrentPersistedCollection(cpCol); Assert.IsFalse(myBO.Status.IsDirty); Assert.IsFalse(util.AddedEventFired); }
public void Test_MarkForDelete_Added_SaveAll() { //---------------Set up test pack------------------- RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol = new RelatedBusinessObjectCollection<ContactPersonTestBO>(GetContactPersonRelationship()); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB"); cpCol.Add(myBO); myBO.MarkForDelete(); //---------------Assert Precondition---------------- util.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); //---------------Execute Test ---------------------- cpCol.SaveAll(); //---------------Test Result ----------------------- util.AssertAllCollectionsHaveNoItems(cpCol); Assert.IsFalse(myBO.Status.IsDirty); }
public void Test_CreatedBusinessObject_SaveAll() { //Saving a created business object should remove the business // object from the created col. it should still exist in // the main collection and should be added to the persisted collection //---------------Set up test pack------------------- OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation(); IMultipleRelationship cpRelationship = (IMultipleRelationship) organisationTestBO.Relationships["ContactPeople"]; RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol = new RelatedBusinessObjectCollection<ContactPersonTestBO>(cpRelationship); cpCol.LoadAll(); ContactPersonTestBO newCP = cpCol.CreateBusinessObject(); newCP.Surname = TestUtil.GetRandomString(); newCP.FirstName = TestUtil.GetRandomString(); RegisterForAddedEvent(cpCol); //---------------Assert Preconditions -------------- Assert.IsFalse(_addedEventFired); Assert.AreEqual(InsertParentAction.InsertRelationship, cpRelationship.RelationshipDef.InsertParentAction); AssertOneObjectInCurrentAndCreatedCollection(cpCol); //---------------Execute Test ---------------------- cpCol.SaveAll(); //---------------Test Result ----------------------- Assert.IsFalse(_addedEventFired); Assert.Contains(newCP, cpCol); AssertOneObjectInCurrentAndPersistedCollection(cpCol); Assert.IsFalse(newCP.Status.IsNew); Assert.IsFalse(newCP.Status.IsDirty); }