コード例 #1
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);
        }
コード例 #2
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);
        }
コード例 #3
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);
        }
コード例 #4
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);
        }