コード例 #1
0
        public void Test_MarkForDeleteBO_MarkForDelete_RemovedNotFired()
        {
            //A Business object that exists in the collection can be marked for deletion either as a bo or
            //  as an index in the collection
            //---------------Set up test pack-------------------
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCollectionWith_OneBO(OrganisationTestBO.CreateSavedOrganisation());
            ContactPersonTestBO markForDeleteCP = cpCol[0];

            cpCol.MarkForDelete(markForDeleteCP);
            _removedEventFired           = false;
            cpCol.BusinessObjectRemoved += delegate { _removedEventFired = true; };

            //---------------Assert Precondition----------------
            AssertOnePersisted_OneMarkForDelete(cpCol);
            Assert.IsFalse(_removedEventFired);

            //---------------Execute Test ----------------------
            cpCol.MarkForDelete(markForDeleteCP);

            //---------------Test Result -----------------------
            AssertOnePersisted_OneMarkForDelete(cpCol);
            Assert.IsTrue(markForDeleteCP.Status.IsDeleted);
            Assert.IsFalse(_removedEventFired);
        }
コード例 #2
0
        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));
        }
コード例 #3
0
        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);
        }
コード例 #4
0
        public void Test_Remove_ColMarkForDelete()
        {
            //-----Create Test pack---------------------
            ContactPersonTestBO cp;
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCol_OneCP(out cp, OrganisationTestBO.CreateSavedOrganisation());

            cpCol.Remove(cp);
            _removedEventFired           = false;
            cpCol.BusinessObjectRemoved += delegate { _removedEventFired = true; };
            //--------------Assert Preconditions--------
            AssertOneObjectInRemovedAndPersistedCollection(cpCol);
            Assert.IsFalse(_removedEventFired);

            //-----Run tests----------------------------
            cpCol.MarkForDelete(cp);

            ////-----Test results-------------------------
            AssertOnePersisted_OneMarkForDelete(cpCol);
            Assert.IsFalse(_removedEventFired);
        }
コード例 #5
0
        public void Test_MarkForDeleteBO_RestoreBOndepedently()
        {
            //---------------Set up test pack-------------------
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCollectionWith_OneBO(OrganisationTestBO.CreateSavedOrganisation());
            ContactPersonTestBO cp = cpCol[0];

            cpCol.MarkForDelete(cp);
            _addedEventFired           = false;
            cpCol.BusinessObjectAdded += delegate { _addedEventFired = true; };
            //---------------Assert Precondition----------------
            AssertOnePersisted_OneMarkForDelete(cpCol);
            Assert.IsFalse(_addedEventFired);

            //---------------Execute Test ----------------------
            cp.CancelEdits();

            //---------------Test Result -----------------------
            AssertOneObjectInCurrentAndPersistedCollection(cpCol);
            Assert.IsTrue(cpCol.Contains(cp));
            Assert.IsTrue(_addedEventFired);
        }
コード例 #6
0
        public void Test_CreatedBusinessObject_ColMarkForDelete_ShouldRemoveFromCurrentAndCreatedCol()
        {
            //---------------Set up test pack-------------------
            //ContactPersonTestBO.LoadDefaultClassDef();
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateRelatedCPCol();

            ContactPersonTestBO newCP = cpCol.CreateBusinessObject();

            newCP.Surname = TestUtil.GetRandomString();

            //---------------Assert Precondition----------------
            AssertOneObjectInCurrentAndCreatedCollection(cpCol);

            //---------------Execute Test ----------------------
            cpCol.MarkForDelete(newCP);

            //---------------Test Result -----------------------
            Assert.AreEqual(0, cpCol.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.MarkedForDeleteBusinessObjects.Count);
            Assert.IsTrue(newCP.Status.IsDeleted);
        }
コード例 #7
0
        public void Test_MarkForDeleteBO_Refresh()
        {
            //---------------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 ----------------------
            try
            {
                BORegistry.DataAccessor.BusinessObjectLoader.Refresh(cp);
                Assert.Fail("Expected to throw an HabaneroDeveloperException");
            }
            //---------------Test Result -----------------------
            catch (HabaneroDeveloperException ex)
            {
                StringAssert.Contains("the object being refreshed is being edited", ex.Message);
            }
        }
コード例 #8
0
        public void Test_MarkForDelete_Added_MarkForDeleteBO()
        {
            //---------------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.MarkForDelete(myBO);

            //---------------Test Result -----------------------
            util.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);
        }
コード例 #9
0
        public void TestAddMethod_MarkForDeleteAddedBusinessObject()
        {
            //---------------Set up test pack-------------------
            RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol =
                new RelatedBusinessObjectCollection<ContactPersonTestBO>(GetContactPersonRelationship());
            ContactPersonTestBO myBO = ContactPersonTestBO.CreateSavedContactPerson();
            cpCol.Add(myBO);
            util.RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            util.AssertOneObjectInCurrentAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);
            util.AssertAddedAndRemovedEventsNotFired();
            //---------------Execute Test ----------------------
            cpCol.MarkForDelete(myBO);

            //---------------Test Result -----------------------
            util.AssertOneObjectInMarkForDeleteAndAddedCollection(cpCol);
            Assert.IsTrue(myBO.Status.IsDirty);
            util.AssertRemovedEventFired();
        }