public void Test_MarkForDelete_Added_RestoreBO_LoadWCriteria() { //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); cpCol.Load("Surname=cc", ""); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB"); cpCol.Add(myBO); myBO.MarkForDelete(); _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); //---------------Execute Test ---------------------- myBO.CancelEdits(); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsFalse(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedEventFired(); _businessObjectCollectionTestHelper.AssertRemovedEventNotFired(); }
public void TestAddMethod_PersistedObject_IgnoresAddWhenItemAlreadyExists() { //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(myBO); _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); _businessObjectCollectionTestHelper.AssertAddedEventNotFired(); //---------------Execute Test ---------------------- cpCol.Add(myBO); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); _businessObjectCollectionTestHelper.AssertAddedEventNotFired(); }
public void Test_AddMethod() { //---------------Set up test pack------------------- //ContactPersonTestBO.LoadDefaultClassDef(); BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); ContactPersonTestBO myBO = new ContactPersonTestBO(); _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol); //---------------Assert Precondition---------------- Assert.AreEqual(0, cpCol.Count); Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count); _businessObjectCollectionTestHelper.AssertAddedEventNotFired(); //---------------Execute Test ---------------------- cpCol.Add(myBO); //---------------Test Result ----------------------- Assert.AreEqual(1, cpCol.Count, "One object should be in the cpCollection"); BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndCreatedCollection(cpCol); _businessObjectCollectionTestHelper.AssertAddedEventFired(); Assert.AreEqual(myBO, cpCol[0], "Added object should be in the cpCollection"); }
public void TestAddMethod_SaveBusinessObject() { //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(myBO); myBO.Surname = TestUtil.GetRandomString(); _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); _businessObjectCollectionTestHelper.AssertAddedEventNotFired(); //---------------Execute Test ---------------------- myBO.Save(); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentPersistedAndAddedCollection(cpCol); _businessObjectCollectionTestHelper.AssertAddedEventNotFired(); }
public void TestAddMethod_IgnoresAddWhenItemAlreadyExists() { //---------------Set up test pack------------------- MyBO.LoadDefaultClassDef(); BusinessObjectCollection <MyBO> cpCol = new BusinessObjectCollection <MyBO>(); MyBO myBO = new MyBO(); cpCol.Add(myBO); _businessObjectCollectionTestHelper.RegisterForAddedEvent(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndCreatedCollection(cpCol); _businessObjectCollectionTestHelper.AssertAddedEventNotFired(); //---------------Execute Test ---------------------- cpCol.Add(myBO); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndCreatedCollection(cpCol); _businessObjectCollectionTestHelper.AssertAddedEventNotFired(); }
public void Test_MarkForDelete_Added_boSave() { //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("BB"); cpCol.Add(myBO); myBO.MarkForDelete(); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); //---------------Execute Test ---------------------- myBO.Save(); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertAllCollectionsHaveNoItems(cpCol); Assert.IsFalse(myBO.Status.IsDirty); }
public void TestAddMethod_MarkForDeleteAddedBusinessObject() { //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(myBO); _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsFalse(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired(); //---------------Execute Test ---------------------- cpCol.MarkForDelete(myBO); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertRemovedEventFired(); }
public void Test_MarkForDelete_Added_RefreshAll() { //---------------Set up test pack------------------- ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); cpCol.Load(new Criteria("Surname", Criteria.ComparisonOp.Equals, TestUtil.GetRandomString()), ""); cpCol.Add(myBO); myBO.MarkForDelete(); _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired(); //---------------Execute Test ---------------------- cpCol.Refresh(); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired(); }
public void TestAddMethod_Refresh_LoadWithCriteria_BusinessObject() { //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); cpCol.Load("Surname='bbb'", ""); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson("aaa"); cpCol.Add(myBO); _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsFalse(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired(); //---------------Execute Test ---------------------- cpCol.Refresh(); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsFalse(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired(); }
public void TestAddMethod_RestoreBusinessObject() { //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(myBO); myBO.Surname = TestUtil.GetRandomString(); _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired(); //---------------Execute Test ---------------------- myBO.CancelEdits(); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndAddedCollection(cpCol); Assert.IsFalse(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired(); }
public void TestAddMethod_Remove_Added_NonPersisted_BusinessObject() { //---------------Set up test pack------------------- BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); ContactPersonTestBO myBO = ContactPersonTestBO.CreateUnsavedContactPerson (TestUtil.GetRandomString(), TestUtil.GetRandomString()); cpCol.Add(myBO); _businessObjectCollectionTestHelper.RegisterForAddedAndRemovedEvents(cpCol); //---------------Assert Precondition---------------- BusinessObjectCollectionTestHelper.AssertOneObjectInCurrentAndCreatedCollection(cpCol); Assert.IsTrue(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertAddedAndRemovedEventsNotFired(); //---------------Execute Test ---------------------- cpCol.Remove(myBO); //---------------Test Result ----------------------- BusinessObjectCollectionTestHelper.AssertAllCollectionsHaveNoItems(cpCol); Assert.IsTrue(myBO.Status.IsDirty); _businessObjectCollectionTestHelper.AssertRemovedEventFired(); _businessObjectCollectionTestHelper.AssertAddedEventNotFired(); }
public void Test_Add_PersistedBO_CancelEdits() { //---------------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. BusinessObjectCollection <ContactPersonTestBO> cpCol = new BusinessObjectCollection <ContactPersonTestBO>(); ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson(); ContactPersonTestBO myBO2 = ContactPersonTestBO.CreateSavedContactPerson(); ContactPersonTestBO myBO3 = ContactPersonTestBO.CreateSavedContactPerson(); cpCol.Add(myBO, myBO2, myBO3); _businessObjectCollectionTestHelper.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"); _businessObjectCollectionTestHelper.AssertRemovedEventNotFired(); ///---------------Execute Test ---------------------- cpCol.CancelEdits(); //---------------Test Result ----------------------- - Result BusinessObjectCollectionTestHelper.AssertAllCollectionsHaveNoItems(cpCol); _businessObjectCollectionTestHelper.AssertRemovedEventFired(); }
public void SetupTest() { //Runs every time that any testmethod is executed _businessObjectCollectionTestHelper = new BusinessObjectCollectionTestHelper(); }