コード例 #1
0
        public void Test_CreateBusinessObject_ForeignKeySetUp_BeforeAddedEventFired()
        {
            //---------------Set up test pack-------------------
            //The Foreign Key (address.ContactPersonId) should be set up to be
            // equal to the contactPerson.ContactPersonID before he Added event fires.
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadClassDefWithAddressesRelationship_DeleteRelated();
            ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
            RelatedBusinessObjectCollection <AddressTestBO> addresses = contactPersonTestBO.Addresses;
            AddressTestBO addressFromEvent = null;
            Guid?         addressContactPersonIDFromEvent = null;

            addresses.BusinessObjectAdded += delegate(object sender, BOEventArgs <AddressTestBO> e)
            {
                addressFromEvent = e.BusinessObject;
                addressContactPersonIDFromEvent = addressFromEvent.ContactPersonID;
            };
            //---------------Assert Precondition----------------
            Assert.IsNull(addressFromEvent);
            Assert.IsNull(addressContactPersonIDFromEvent);
            //---------------Execute Test ----------------------
            AddressTestBO address = addresses.CreateBusinessObject();

            //---------------Test Result -----------------------
            Assert.IsNotNull(addressFromEvent);
            Assert.IsNotNull(addressContactPersonIDFromEvent, "Adress.ContactPersonID should have been set before the Added event was called");
            Assert.AreEqual(contactPersonTestBO.ContactPersonID, addressContactPersonIDFromEvent);
            Assert.AreSame(address, addressFromEvent);
            Assert.AreEqual(contactPersonTestBO.ContactPersonID, address.ContactPersonID);
            Assert.IsTrue(address.Status.IsNew);
            Assert.AreEqual(1, addresses.CreatedBusinessObjects.Count);
        }
コード例 #2
0
        public void Test_CreatedBusinessObject_SaveBO()
        {
            //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);
            AssertOneObjectInCurrentAndCreatedCollection(cpCol);

            //---------------Execute Test ----------------------
            newCP.Save();

            //---------------Test Result -----------------------
            Assert.IsFalse(_addedEventFired);
            Assert.Contains(newCP, cpCol);
            AssertOneObjectInCurrentAndPersistedCollection(cpCol);
        }
コード例 #3
0
        public void Test_CreatedBo_Remove()
        {
            //If you remove a created business object that is not yet persisted then
            //-- remove from the restored and saved event.
            //---------------Set up test pack-------------------
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCollectionWith_OneBO();

            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            ContactPersonTestBO createdCp = cpCol.CreateBusinessObject();

            createdCp.Surname   = BOTestUtils.RandomString;
            createdCp.FirstName = BOTestUtils.RandomString;
            RegisterForAddedAndRemovedEvents(cpCol);

            //---------------Assert Precondition----------------
            Assert.IsTrue(cpCol.Contains(createdCp));
            AssertTwoCurrentObjects_OnePsersisted_OneCreated(cpCol);
            //---------------Execute Test ----------------------
            cpCol.Remove(createdCp);

            //---------------Test Result -----------------------
            Assert.IsFalse(cpCol.Contains(createdCp));
            AssertOneObjectInCurrentAndPersistedCollection(cpCol);
            AssertRemovedEventFired();
            AssertAddedEventNotFired();
        }
コード例 #4
0
        public void TestRemoveRelatedObject()
        {
            //-----Create Test pack---------------------
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadClassDefWithAddressesRelationship_DeleteRelated();
            ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateSavedContactPersonNoAddresses();
            RelatedBusinessObjectCollection <AddressTestBO> addresses1 = contactPersonTestBO.Addresses;
            AddressTestBO address = addresses1.CreateBusinessObject();

            address.Save();

            //------Assert Preconditions
            Assert.AreEqual(0, addresses1.RemovedBusinessObjects.Count);
            Assert.AreEqual(1, addresses1.Count);
            Assert.AreEqual(1, addresses1.PersistedBusinessObjects.Count);

            //-----Run tests----------------------------
            RelatedBusinessObjectCollection <AddressTestBO> addresses = addresses1;

            addresses.Remove(address);

            ////-----Test results-------------------------
            Assert.AreEqual(1, addresses1.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, addresses1.Count);
            Assert.AreEqual(1, addresses1.PersistedBusinessObjects.Count);
            Assert.IsNull(address.ContactPersonTestBO);
            Assert.IsNull(address.ContactPersonID);
        }
コード例 #5
0
        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();
        }
コード例 #6
0
        public void Test_RemoveCreatedBo_DeregistersForSaveEvent()
        {
            //If you remove a created business object that is not yet persisted then
            //-- remove from the restored and saved event.
            //-- when the object is saved it should be independent of the collection.
            //---------------Set up test pack-------------------
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateCollectionWith_OneBO();
            ContactPersonTestBO createdCp = cpCol.CreateBusinessObject();

            createdCp.Surname   = BOTestUtils.RandomString;
            createdCp.FirstName = BOTestUtils.RandomString;
            cpCol.Remove(createdCp);
            RegisterForAddedAndRemovedEvents(cpCol);
            //---------------Assert Precondition----------------
            AssertOneObjectInCurrentAndPersistedCollection(cpCol);
            Assert.IsFalse(cpCol.Contains(createdCp));

            //---------------Execute Test ----------------------
            createdCp.Save();

            //---------------Test Result -----------------------
            AssertOneObjectInCurrentAndPersistedCollection(cpCol);
            Assert.IsFalse(cpCol.Contains(createdCp));
            AssertAddedAndRemovedEventsNotFired();
        }
コード例 #7
0
        public void Test_CreateBusinessObject()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO    organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            IMultipleRelationship cpRelationship     =
                (IMultipleRelationship)organisationTestBO.Relationships["ContactPeople"];
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol =
                new RelatedBusinessObjectCollection <ContactPersonTestBO>(cpRelationship);

            cpCol.LoadAll();
            RegisterForAddedEvent(cpCol);

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, cpCol.Count);
            Assert.IsFalse(_addedEventFired);
            Assert.AreEqual(0, cpCol.PersistedBusinessObjects.Count);

            //---------------Execute Test ----------------------
            ContactPersonTestBO newCP = cpCol.CreateBusinessObject();

            //---------------Test Result -----------------------
            AssertOneObjectInCurrentAndCreatedCollection(cpCol);

            Assert.Contains(newCP, cpCol.CreatedBusinessObjects);
            Assert.Contains(newCP, cpCol);
            Assert.IsFalse(cpCol.PersistedBusinessObjects.Contains(newCP));
            Assert.IsTrue(_addedEventFired);
        }
コード例 #8
0
        private static RelatedBusinessObjectCollection <ContactPersonTestBO> CreateCollectionWith_OneBO()
        {
            OrganisationTestBO    organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            IMultipleRelationship cpRelationship     =
                (IMultipleRelationship)organisationTestBO.Relationships["ContactPeople"];
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol =
                new RelatedBusinessObjectCollection <ContactPersonTestBO>(cpRelationship);

            ContactPersonTestBO cp = cpCol.CreateBusinessObject();

            cp.FirstName = TestUtil.GetRandomString();
            cp.Surname   = TestUtil.GetRandomString();
            cp.Save();
            return(BORegistry.DataAccessor.BusinessObjectLoader.GetRelatedBusinessObjectCollection <ContactPersonTestBO>
                       (cpRelationship));
        }
コード例 #9
0
        public void Test_CreatedBusinessObject_MarkForDelete_ShouldRemoveFromCurrentAndCreatedCol()
        {
            //---------------Set up test pack-------------------
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateRelatedCPCol();

            ContactPersonTestBO newCP = cpCol.CreateBusinessObject();

            newCP.Surname = TestUtil.GetRandomString();
            //---------------Assert Precondition----------------
            AssertOneObjectInCurrentAndCreatedCollection(cpCol);
            //---------------Execute Test ----------------------
            newCP.MarkForDelete();
            //---------------Test Result -----------------------
            Assert.AreEqual(0, cpCol.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.MarkedForDeleteBusinessObjects.Count);
            Assert.IsTrue(newCP.Status.IsDeleted);
        }
コード例 #10
0
        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();
        }
コード例 #11
0
        public void Test_CreatedBusinessObject_Refresh()
        {
            //---------------Set up test pack-------------------
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateRelatedCPCol();

            ContactPersonTestBO newCP = cpCol.CreateBusinessObject();

            newCP.Surname = TestUtil.GetRandomString();

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

            //---------------Execute Test ----------------------
            BORegistry.DataAccessor.BusinessObjectLoader.Refresh(newCP);

            //---------------Test Result -----------------------
            AssertOneObjectInCurrentAndCreatedCollection(cpCol);
        }
コード例 #12
0
        public void Test_CreateBusinessObject_OnlyFiresOneAddedEvent()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            MyBO.LoadClassDefWithRelationship();
            MyRelatedBo.LoadClassDef();
            MyBO bo = new MyBO();
            IMultipleRelationship rel = bo.Relationships.GetMultiple("MyMultipleRelationship");
            RelatedBusinessObjectCollection <MyRelatedBo> col = (RelatedBusinessObjectCollection <MyRelatedBo>)rel.BusinessObjectCollection;
            int addedEventCount = 0;

            col.BusinessObjectAdded += (sender, e) => addedEventCount++;
            //---------------Assert Precondition----------------
            Assert.AreEqual(0, addedEventCount);
            //---------------Execute Test ----------------------
            col.CreateBusinessObject();
            //---------------Test Result -----------------------
            Assert.AreEqual(1, addedEventCount);
        }
コード例 #13
0
        public void TestRemoveRelatedObject_SetsRemovedBO()
        {
            //-----Create Test pack---------------------
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadClassDefWithAddressesRelationship_DeleteRelated();
            ContactPersonTestBO contactPersonTestBO = ContactPersonTestBO.CreateSavedContactPersonNoAddresses();
            RelatedBusinessObjectCollection <AddressTestBO> addresses1 = contactPersonTestBO.Addresses;
            AddressTestBO address = addresses1.CreateBusinessObject();

            address.Save();

            //-----Run tests----------------------------
            RelatedBusinessObjectCollection <AddressTestBO> addresses = addresses1;

            addresses.Remove(address);

            ////-----Test results-------------------------
            Assert.AreSame(contactPersonTestBO, address.Relationships.GetSingle <ContactPersonTestBO>("ContactPersonTestBO").RemovedBO);
        }
コード例 #14
0
        public void Test_CreatedBusinessObject_RestoreIndependently()
        {
            //---------------Set up test pack-------------------
            //ContactPersonTestBO.LoadDefaultClassDef();
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateRelatedCPCol();
            ContactPersonTestBO newCP = cpCol.CreateBusinessObject();

            newCP.Surname   = TestUtil.GetRandomString();
            newCP.FirstName = BOTestUtils.RandomString;

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

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

            //---------------Test Result -----------------------
            AssertOneObjectInCurrentAndCreatedCollection(cpCol);
        }
コード例 #15
0
        public void Test_CreatedBusinessObject_Add()
        {
            //---------------Set up test pack-------------------
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateRelatedCPCol();
            ContactPersonTestBO newCP = cpCol.CreateBusinessObject();

            newCP.Surname = TestUtil.GetRandomString();
            RegisterForAddedAndRemovedEvents(cpCol);

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

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

            //---------------Test Result -----------------------
            AssertOneObjectInCurrentAndCreatedCollection(cpCol);
            AssertAddedAndRemovedEventsNotFired();
        }
コード例 #16
0
        public void Test_CreateBusinessObject_AddedToTheCollection()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            MyBO.LoadClassDefWithRelationship();
            MyRelatedBo.LoadClassDef();
            MyBO bo = new MyBO();
            IMultipleRelationship rel = bo.Relationships.GetMultiple("MyMultipleRelationship");
            RelatedBusinessObjectCollection<MyRelatedBo> col = new RelatedBusinessObjectCollection<MyRelatedBo>(rel);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            MyRelatedBo relatedBo = col.CreateBusinessObject();
            //---------------Test Result -----------------------
            Assert.AreEqual(bo.MyBoID, relatedBo.MyBoID, "The foreign key should eb set");
            Assert.IsTrue(relatedBo.Status.IsNew);
            Assert.AreEqual(1, col.CreatedBusinessObjects.Count, "The created BOs should be added");
            Assert.AreEqual(0, col.AddedBusinessObjects.Count);
            Assert.AreEqual(1, col.Count);
        }
コード例 #17
0
        public void Test_CreateBusinessObject_AddedToTheCollection()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            MyBO.LoadClassDefWithRelationship();
            MyRelatedBo.LoadClassDef();
            MyBO bo = new MyBO();
            IMultipleRelationship rel = bo.Relationships.GetMultiple("MyMultipleRelationship");
            RelatedBusinessObjectCollection <MyRelatedBo> col = new RelatedBusinessObjectCollection <MyRelatedBo>(rel);
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            MyRelatedBo relatedBo = col.CreateBusinessObject();

            //---------------Test Result -----------------------
            Assert.AreEqual(bo.MyBoID, relatedBo.MyBoID, "The foreign key should eb set");
            Assert.IsTrue(relatedBo.Status.IsNew);
            Assert.AreEqual(1, col.CreatedBusinessObjects.Count, "The created BOs should be added");
            Assert.AreEqual(0, col.AddedBusinessObjects.Count);
            Assert.AreEqual(1, col.Count);
        }
コード例 #18
0
        public void Test_CreatedBusinessObject_SavedTwice()
        {
            //---------------Set up test pack-------------------
            RelatedBusinessObjectCollection <ContactPersonTestBO> cpCol = CreateRelatedCPCol();

            ContactPersonTestBO newCP = cpCol.CreateBusinessObject();

            newCP.Surname   = TestUtil.GetRandomString();
            newCP.FirstName = TestUtil.GetRandomString();
            newCP.Save();

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

            //---------------Execute Test ----------------------
            newCP.Surname = TestUtil.GetRandomString();
            newCP.Save();

            //---------------Test Result -----------------------
            AssertOneObjectInCurrentAndPersistedCollection(cpCol);
        }
コード例 #19
0
        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();
        }
コード例 #20
0
        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);
        }
コード例 #21
0
        public void Test_CreateBusinessObject_ForeignKeySetUp_PropertyUpdatedEventNotFired()
        {
            //---------------Set up test pack-------------------
            //The Foreign Key (address.ContactPersonId) should be set up to be
            // equal to the contactPerson.ContactPersonID before he Added event fires.
            ClassDef.ClassDefs.Clear();
            ContactPersonTestBO.LoadClassDefWithAddressesRelationship_DeleteRelated();
            ContactPersonTestBO contactPersonTestBO = new ContactPersonTestBO();
            RelatedBusinessObjectCollection <AddressTestBO> addresses = contactPersonTestBO.Addresses;
            bool propetyUpdatedEventFired = false;

            addresses.BusinessObjectPropertyUpdated += delegate {
                propetyUpdatedEventFired = true;
            };
            //---------------Assert Precondition----------------
            Assert.IsFalse(propetyUpdatedEventFired);
            Assert.AreEqual(0, addresses.CreatedBusinessObjects.Count);
            //---------------Execute Test ----------------------
            AddressTestBO address = addresses.CreateBusinessObject();

            //---------------Test Result -----------------------
            Assert.IsFalse(propetyUpdatedEventFired);
            Assert.AreEqual(1, addresses.CreatedBusinessObjects.Count);
        }
コード例 #22
0
        private static RelatedBusinessObjectCollection<ContactPersonTestBO> CreateCollectionWith_OneBO()
        {
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            IMultipleRelationship cpRelationship =
                (IMultipleRelationship) organisationTestBO.Relationships["ContactPeople"];
            RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol =
                new RelatedBusinessObjectCollection<ContactPersonTestBO>(cpRelationship);

            ContactPersonTestBO cp = cpCol.CreateBusinessObject();
            cp.FirstName = TestUtil.GetRandomString();
            cp.Surname = TestUtil.GetRandomString();
            cp.Save();
            return BORegistry.DataAccessor.BusinessObjectLoader.GetRelatedBusinessObjectCollection<ContactPersonTestBO>
                (cpRelationship);
        }
コード例 #23
0
        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);
        }
コード例 #24
0
        public void Test_CreateBusinessObject()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            IMultipleRelationship cpRelationship =
                (IMultipleRelationship) organisationTestBO.Relationships["ContactPeople"];
            RelatedBusinessObjectCollection<ContactPersonTestBO> cpCol =
                new RelatedBusinessObjectCollection<ContactPersonTestBO>(cpRelationship);
            cpCol.LoadAll();
            RegisterForAddedEvent(cpCol);

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, cpCol.Count);
            Assert.IsFalse(_addedEventFired);
            Assert.AreEqual(0, cpCol.PersistedBusinessObjects.Count);

            //---------------Execute Test ----------------------
            ContactPersonTestBO newCP = cpCol.CreateBusinessObject();

            //---------------Test Result -----------------------
            AssertOneObjectInCurrentAndCreatedCollection(cpCol);

            Assert.Contains(newCP, cpCol.CreatedBusinessObjects);
            Assert.Contains(newCP, cpCol);
            Assert.IsFalse(cpCol.PersistedBusinessObjects.Contains(newCP));
            Assert.IsTrue(_addedEventFired);
        }