コード例 #1
0
        public void Test_LoadMultiplerelationship_TimeOutNotExceeded_DoesNotReloadFromDB()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            IClassDef orgClassDef = OrganisationTestBO.LoadDefaultClassDef();

            ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();
            OrganisationTestBO        organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            RelationshipDef           relationshipDef    = (RelationshipDef)orgClassDef.RelationshipDefCol["ContactPeople"];
            IMultipleRelationship     rel        = new MultipleRelationship <ContactPersonTestBO>(organisationTestBO, relationshipDef, organisationTestBO.Props, 30000);
            IBusinessObjectCollection collection = rel.BusinessObjectCollection;
            DateTime?initialTimeLastLoaded       = collection.TimeLastLoaded;

            //---------------Assert Precondition----------------
            Assert.AreEqual(initialTimeLastLoaded, collection.TimeLastLoaded);
            Assert.AreEqual(0, collection.Count);
            //---------------Execute Test ----------------------
            ContactPersonTestBO contactPerson = organisationTestBO.ContactPeople.CreateBusinessObject();

            contactPerson.Surname   = TestUtil.GetRandomString();
            contactPerson.FirstName = TestUtil.GetRandomString();
            contactPerson.Save();
            TestUtil.Wait(100);
            IBusinessObjectCollection secondCollectionCall = rel.BusinessObjectCollection;

            //---------------Test Result -----------------------
            Assert.AreSame(collection, secondCollectionCall);
            Assert.AreEqual(0, secondCollectionCall.Count);
            Assert.AreEqual(initialTimeLastLoaded, secondCollectionCall.TimeLastLoaded);
        }
コード例 #2
0
        public virtual void Test_AddDirtyChildrenToTransactionCommitter_AddedChild()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            MultipleRelationship <ContactPersonTestBO> relationship =
                organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople");
            RelationshipDef relationshipDef = (RelationshipDef)relationship.RelationshipDef;

            relationshipDef.RelationshipType = RelationshipType.Association;

            ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson();

            relationship.BusinessObjectCollection.Add(contactPerson);
            SingleRelationship <OrganisationTestBO> reverseRelationship =
                contactPerson.Relationships.GetSingle <OrganisationTestBO>("Organisation");


            TransactionCommitter tc = (TransactionCommitter)BORegistry.DataAccessor.CreateTransactionCommitter();

            //---------------Assert PreConditions---------------
            Assert.AreEqual(0, tc.OriginalTransactions.Count);
            Assert.IsNotNull(reverseRelationship);

            //---------------Execute Test ----------------------
            relationship.AddDirtyChildrenToTransactionCommitter(tc);

            //---------------Test Result -----------------------
            Assert.AreEqual(1, tc.OriginalTransactions.Count);

            Assert.IsInstanceOf(typeof(TransactionalSingleRelationship_Added), tc.OriginalTransactions[0]);
            Assert.AreSame(relationship, ((TransactionalSingleRelationship_Added)tc.OriginalTransactions[0]).Relationship);
        }
コード例 #3
0
        public void Test_PersistParent_PersistsDirtyChildren()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            RelationshipCol    relationships      = organisationTestBO.Relationships;
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     aggregateRelationship = GetAggregationRelationship
                                                                                       (organisationTestBO, out cpCol);

            ContactPersonTestBO myBO = cpCol.CreateBusinessObject();

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

            //---------------Assert Precondition----------------
            Assert.IsTrue(aggregateRelationship.IsDirty);
            Assert.IsTrue(myBO.Status.IsDirty);
            Assert.IsTrue(relationships.IsDirty);
            Assert.IsTrue(organisationTestBO.Status.IsDirty);

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

            //---------------Test Result -----------------------
            Assert.IsFalse(myBO.Status.IsDirty);
            Assert.IsFalse(aggregateRelationship.IsDirty);
            Assert.IsFalse(relationships.IsDirty);
            Assert.IsFalse(organisationTestBO.Status.IsDirty);
        }
コード例 #4
0
        public void TestCreateRelationshipUsingGenerics()
        {
            MultipleRelationship rel =
                (MultipleRelationship)_multipleRelationshipDef.CreateRelationship(_mockBo, _mockBo.PropCol);

            Assert.AreEqual(_multipleRelationshipDef.RelationshipName, rel.RelationshipName);

            Assert.IsTrue(_mockBo.GetPropertyValue("MockBOProp1") == null);

            BusinessObjectCollection <MockBO> relatedObjects = rel.GetRelatedBusinessObjectCol <MockBO>();

            Assert.IsTrue(relatedObjects.Count == 0);

            //			_mockBo.SetPropertyValue("MockBOProp1",_mockBo.GetPropertyValue("MockBOID"));
            //			_mockBo.Save();
            //			Assert.IsTrue (rel.HasRelationship(), "Should be true since prop MockBOProp1 has been set");
            //
            //			Assert.AreEqual(_mockBo.GetPropertyValue("MockBOProp1") ,_mockBo.GetPropertyValue("MockBOID"));
            //TODO:
            //			MockBO ltempBO = (MockBO) rel.GetRelatedObject();
            //			Assert.IsFalse(ltempBO == null);
            //			Assert.AreEqual(_mockBo.GetPropertyValue("MockBOID") ,ltempBO.GetPropertyValue("MockBOID"), "The object returned should be the one with the ID = MockBOID");
            //			Assert.AreEqual(_mockBo.GetPropertyValueString("MockBOProp1") ,ltempBO.GetPropertyValueString("MockBOID"), "The object returned should be the one with the ID = MockBOID");
            //			Assert.AreEqual(_mockBo.GetPropertyValue("MockBOProp1") ,ltempBO.GetPropertyValue("MockBOID"), "The object returned should be the one with the ID = MockBOID");
        }
コード例 #5
0
        [Ignore("Working on this")] //TODO Mark 27 Feb 2009: Ignored Test - Working on this
        public void Test_CancelEdit_Owner_ChildOwnsTheEdit_ForCreatedChild()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO;
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     aggregateRelationship = GetRelationship(out organisationTestBO, out cpCol);
            ContactPersonTestBO createdChild = CreateCreatedChild_ChildOwnsEdit(organisationTestBO);

            //---------------Assert Precondition----------------
            Assert.AreEqual(1, cpCol.Count);
            Assert.IsTrue(createdChild.Status.IsDirty);
            Assert.IsTrue(aggregateRelationship.IsDirty);
            Assert.AreEqual(1, aggregateRelationship.GetDirtyChildren().Count);
            Assert.AreEqual(0, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(1, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.MarkedForDeleteBusinessObjects.Count);
            //---------------Execute Test ----------------------
            createdChild.CancelEdits();
            //---------------Test Result -----------------------
            Assert.AreEqual(0, cpCol.Count);
            Assert.IsFalse(createdChild.Status.IsDirty);
            Assert.IsFalse(aggregateRelationship.IsDirty);
            Assert.AreEqual(0, aggregateRelationship.GetDirtyChildren().Count);
            Assert.AreEqual(0, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.MarkedForDeleteBusinessObjects.Count);
        }
コード例 #6
0
        public void Test_CreateMultipleRelationshipDef_Association()
        {
            //---------------Set up test pack-------------------
            BORegistry.DataAccessor = new DataAccessorInMemory();
            ClassDef.ClassDefs.Clear();
            OrganisationTestBO.LoadDefaultClassDef();
            ContactPersonTestBO.LoadDefaultClassDef();
            RelPropDef relPropDef = new RelPropDef(ClassDef.Get <OrganisationTestBO>().PropDefcol["OrganisationID"], "OrganisationID");
            RelKeyDef  relKeyDef  = new RelKeyDef();

            relKeyDef.Add(relPropDef);
            const int expectedTimeout = 550;
            MultipleRelationshipDef relationshipDef = new MultipleRelationshipDef("ContactPeople", "Habanero.Test.BO",
                                                                                  "ContactPersonTestBO", relKeyDef, true, "", DeleteParentAction.DeleteRelated, InsertParentAction.InsertRelationship, RelationshipType.Association, expectedTimeout);
            OrganisationTestBO organisation = OrganisationTestBO.CreateSavedOrganisation();

            //---------------Assert Precondition----------------
            Assert.AreEqual(expectedTimeout, relationshipDef.TimeOut);
            //---------------Execute Test ----------------------
            MultipleRelationship <ContactPersonTestBO> relationship = (MultipleRelationship <ContactPersonTestBO>)relationshipDef.CreateRelationship(organisation, organisation.Props);

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedTimeout, relationship.TimeOut);
            Assert.AreEqual(InsertParentAction.InsertRelationship, relationship.RelationshipDef.InsertParentAction);
        }
コード例 #7
0
        public void Test_LoadMultiplerelationship_TimeOutExceeded_WhenTimeOutZero_DoesResetTheTimeLastLoaded()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            IClassDef orgClassDef = OrganisationTestBO.LoadDefaultClassDef();

            ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();
            OrganisationTestBO        organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            RelationshipDef           relationshipDef    = (RelationshipDef)orgClassDef.RelationshipDefCol["ContactPeople"];
            IMultipleRelationship     rel        = new MultipleRelationship <ContactPersonTestBO>(organisationTestBO, relationshipDef, organisationTestBO.Props, 0);
            IBusinessObjectCollection collection = rel.BusinessObjectCollection;
            DateTime?initialTimeLastLoaded       = collection.TimeLastLoaded;

            //---------------Assert Precondition----------------
            Assert.IsNotNull(collection.TimeLastLoaded);
            Assert.AreEqual(initialTimeLastLoaded, collection.TimeLastLoaded);
            //---------------Execute Test ----------------------
            TestUtil.Wait(1000);
            IBusinessObjectCollection secondCollectionCall = rel.BusinessObjectCollection;

            //---------------Test Result -----------------------
            Assert.AreSame(collection, secondCollectionCall);
            Assert.IsNotNull(secondCollectionCall.TimeLastLoaded);
            Assert.AreNotEqual(initialTimeLastLoaded, secondCollectionCall.TimeLastLoaded);
        }
コード例 #8
0
        public void Test_LoadMultiplerelationship_TimeOutExceeded_WhenTimeOutZero_UsingRelationship_DoesReloadFromDB()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            IClassDef orgClassDef = OrganisationTestBO.LoadDefaultClassDef();

            ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();
            OrganisationTestBO        organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            IBusinessObjectCollection collection         = organisationTestBO.ContactPeople;
            DateTime?initialTimeLastLoaded = collection.TimeLastLoaded;

            //---------------Assert Precondition----------------
            Assert.IsNotNull(collection.TimeLastLoaded);
            Assert.AreEqual(initialTimeLastLoaded, collection.TimeLastLoaded);
            Assert.AreEqual(0, collection.Count);
            MultipleRelationship <ContactPersonTestBO> relationship = (MultipleRelationship <ContactPersonTestBO>)organisationTestBO.Relationships["ContactPeople"];

            Assert.AreEqual(0, relationship.TimeOut);
            //---------------Execute Test ----------------------
            ContactPersonTestBO contactPerson = organisationTestBO.ContactPeople.CreateBusinessObject();

            contactPerson.Surname   = TestUtil.GetRandomString();
            contactPerson.FirstName = TestUtil.GetRandomString();
            contactPerson.Save();
            TestUtil.Wait(100);
            IBusinessObjectCollection secondCollectionCall = organisationTestBO.ContactPeople;

            //---------------Test Result -----------------------
            Assert.AreSame(collection, secondCollectionCall);
            Assert.IsNotNull(secondCollectionCall.TimeLastLoaded);
            Assert.AreEqual(1, secondCollectionCall.Count);
            Assert.AreNotEqual(initialTimeLastLoaded, secondCollectionCall.TimeLastLoaded);
        }
コード例 #9
0
        public void Test_GetDirtyChildren_ReturnAllDirty()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     relationship = GetAggregationRelationship(organisationTestBO, out cpCol);

            ContactPersonTestBO myBO_delete = ContactPersonTestBO.CreateSavedContactPerson_AsChild(cpCol);

            cpCol.MarkForDelete(myBO_delete);
            ContactPersonTestBO myBO_Edited = ContactPersonTestBO.CreateSavedContactPerson_AsChild(cpCol);

            myBO_Edited.Surname = TestUtil.GetRandomString();

            ContactPersonTestBO myBo_Created = ContactPersonTestBO.CreateUnsavedContactPerson_AsChild(cpCol);
            ContactPersonTestBO myBo_Removed = ContactPersonTestBO.CreateSavedContactPerson_AsChild(cpCol);

            cpCol.Remove(myBo_Removed);

            //---------------Execute Test ----------------------
            IList <ContactPersonTestBO> dirtyChildren = relationship.GetDirtyChildren();

            //---------------Test Result -----------------------
            Assert.Contains(myBO_delete, (ICollection)dirtyChildren);
            Assert.Contains(myBO_Edited, (ICollection)dirtyChildren);
            Assert.Contains(myBo_Created, (ICollection)dirtyChildren);
            Assert.Contains(myBo_Removed, (ICollection)dirtyChildren);
            Assert.AreEqual(4, dirtyChildren.Count);
        }
コード例 #10
0
        public void Test_AddMethod_AddPersistedChild()
        {
            //An already persisted invoice line cannot be added to an Invoice
            //(In Habanero a new invoice line can be added to an invoice).
            //---------------Set up test pack-------------------
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     compositionRelationship = GetCompositionRelationship(out cpCol);
            ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson();

            //---------------Assert Precondition----------------
            util.AssertAllCollectionsHaveNoItems(cpCol);

            //---------------Execute Test ----------------------
            try
            {
                cpCol.Add(contactPerson);
                Assert.Fail("expected Err");
            }
            //---------------Test Result -----------------------
            catch (HabaneroDeveloperException ex)
            {
                AssertMessageIsCorrect(ex, compositionRelationship.RelationshipDef.RelatedObjectClassName, "added", compositionRelationship.RelationshipName);
            }
            catch (Exception ex)
            {
                Assert.Fail("HabaneroDeveloperException not thrown. Exception Thrown was : " + ex.Message);
            }
        }
コード例 #11
0
        public void Test_CancelEdit_NonOwner_ForDeletedChild()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     associationRelationship = GetRelationship(out cpCol);
            ContactPersonTestBO deletedChild = EditChild(CreateDeletedChild(cpCol));

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, cpCol.Count);
            AssertEditedPropDirtyState(true, deletedChild);
            Assert.IsTrue(deletedChild.Status.IsDeleted);
            Assert.IsTrue(associationRelationship.IsDirty);
            Assert.AreEqual(1, associationRelationship.GetDirtyChildren().Count);
            Assert.AreEqual(1, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(1, cpCol.MarkedForDeleteBusinessObjects.Count);
            //---------------Execute Test ----------------------
            deletedChild.CancelEdits();
            //---------------Test Result -----------------------
            Assert.AreEqual(1, cpCol.Count);
            AssertEditedPropDirtyState(false, deletedChild);
            Assert.IsFalse(deletedChild.Status.IsDeleted);
            Assert.IsFalse(associationRelationship.IsDirty);
            Assert.AreEqual(0, associationRelationship.GetDirtyChildren().Count);
            Assert.AreEqual(1, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.MarkedForDeleteBusinessObjects.Count);
        }
コード例 #12
0
        [Ignore("Working on this")] //TODO Mark 02 Mar 2009: Ignored Test - Working on this
        public virtual void Test_CancelEdit_NonOwner_ChildOwnsTheEdit_ForRemovedChild()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO;
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     associationRelationship = GetRelationship(out organisationTestBO, out cpCol);
            ContactPersonTestBO removedChild = EditChild(CreateRemovedChild_ChildOwnsEdit(organisationTestBO));

            //---------------Assert Precondition----------------
            Assert.AreEqual(0, cpCol.Count);
            AssertEditedPropDirtyState(true, removedChild);
            AssertFKDirtyState(true, removedChild);
            Assert.IsTrue(associationRelationship.IsDirty);
            Assert.AreEqual(1, associationRelationship.GetDirtyChildren().Count);
            Assert.AreEqual(1, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(1, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.MarkedForDeleteBusinessObjects.Count);
            //---------------Execute Test ----------------------
            associationRelationship.CancelEdits();
            //---------------Test Result -----------------------
            Assert.AreEqual(0, cpCol.Count);
            AssertEditedPropDirtyState(true, removedChild);
            AssertFKDirtyState(true, removedChild);
            Assert.IsFalse(associationRelationship.IsDirty);
            Assert.AreEqual(1, associationRelationship.GetDirtyChildren().Count);
            Assert.AreEqual(1, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(1, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.MarkedForDeleteBusinessObjects.Count);
        }
コード例 #13
0
        public override void Test_Acceptance_CancelEditParent_CancelsEditsForDirtyChildren()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO;
            RelationshipCol    relationships;
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     aggregateRelationship =
                GetRelationship(out organisationTestBO, out relationships, out cpCol);

            ContactPersonTestBO existingChild;
            ContactPersonTestBO editedChild;
            ContactPersonTestBO deletedChild;
            ContactPersonTestBO createdChild;
            ContactPersonTestBO createdChildWithEdits;

            CreateDirtyChildren(cpCol, out existingChild, out editedChild,
                                out deletedChild,
                                out createdChildWithEdits, out createdChild);

            //---------------Assert Precondition----------------
            Assert.IsTrue(aggregateRelationship.IsDirty);
            Assert.IsTrue(relationships.IsDirty);
            Assert.IsTrue(organisationTestBO.Status.IsDirty);

            Assert.AreEqual(4, cpCol.Count);
            Assert.AreEqual(3, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(2, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(1, cpCol.MarkedForDeleteBusinessObjects.Count);

            Assert.IsTrue(editedChild.Status.IsDirty);
            Assert.IsFalse(existingChild.Status.IsDirty);
            Assert.IsTrue(deletedChild.Status.IsDeleted);
            Assert.IsTrue(createdChildWithEdits.Status.IsDirty);
            Assert.IsTrue(createdChild.Status.IsDirty);


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

            //---------------Test Result -----------------------
            Assert.IsFalse(aggregateRelationship.IsDirty);
            Assert.IsFalse(relationships.IsDirty);
            Assert.IsFalse(organisationTestBO.Status.IsDirty);
            Assert.AreEqual(3, cpCol.Count);
            Assert.AreEqual(3, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.MarkedForDeleteBusinessObjects.Count);

            Assert.IsFalse(editedChild.Status.IsDirty);
            Assert.IsFalse(existingChild.Status.IsDirty);
            Assert.IsFalse(deletedChild.Status.IsDeleted);
            Assert.IsFalse(createdChildWithEdits.Status.IsDirty);
            Assert.IsFalse(createdChild.Status.IsDirty);
        }
コード例 #14
0
        public virtual void Test_Acceptance_CancelEdit_CancelsEditsForDirtyChildren()
        {
            //---------------Set up test pack-------------------
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     associationRelationship = GetRelationship(out cpCol);

            ContactPersonTestBO existingChild;
            ContactPersonTestBO editedChild;
            ContactPersonTestBO deletedChild;
            ContactPersonTestBO removedChild;
            ContactPersonTestBO addedChild;
            ContactPersonTestBO createdChild;
            ContactPersonTestBO createdChildWithEdits;

            CreateDirtyChildren(cpCol, out existingChild, out editedChild,
                                out deletedChild, out removedChild, out addedChild,
                                out createdChildWithEdits, out createdChild);

            //---------------Assert Precondition----------------
            Assert.IsTrue(associationRelationship.IsDirty);
            Assert.AreEqual(6, associationRelationship.GetDirtyChildren().Count);
            Assert.AreEqual(5, cpCol.Count);
            Assert.AreEqual(4, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(1, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(2, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(1, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(1, cpCol.MarkedForDeleteBusinessObjects.Count);

            Assert.IsTrue(editedChild.Status.IsDirty);
            Assert.IsFalse(existingChild.Status.IsDirty);
            Assert.IsTrue(deletedChild.Status.IsDeleted);
            Assert.IsTrue(removedChild.Status.IsDirty);
            Assert.IsTrue(addedChild.Status.IsDirty);
            Assert.IsTrue(createdChildWithEdits.Status.IsDirty);
            Assert.IsTrue(createdChild.Status.IsDirty);

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

            //---------------Test Result -----------------------
            Assert.IsFalse(associationRelationship.IsDirty);
            Assert.AreEqual(0, associationRelationship.GetDirtyChildren().Count);

            Assert.AreEqual(4, cpCol.Count);
            Assert.AreEqual(4, cpCol.PersistedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.AddedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.CreatedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.RemovedBusinessObjects.Count);
            Assert.AreEqual(0, cpCol.MarkedForDeleteBusinessObjects.Count);

            Assert.IsFalse(editedChild.Status.IsDirty);
            Assert.IsFalse(existingChild.Status.IsDirty);
            Assert.IsFalse(deletedChild.Status.IsDeleted);
            Assert.IsFalse(removedChild.Status.IsDirty);
            Assert.IsFalse(addedChild.Status.IsDirty);
            Assert.IsFalse(createdChildWithEdits.Status.IsDirty);
            Assert.IsFalse(createdChild.Status.IsDirty);
        }
コード例 #15
0
        private static MultipleRelationship <ContactPersonTestBO> GetAggregateRelationship(OrganisationTestBO organisationTestBO, out BusinessObjectCollection <ContactPersonTestBO> cpCol)
        {
            MultipleRelationship <ContactPersonTestBO> aggregateRelationship = organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople");
            RelationshipDef relationshipDef = (RelationshipDef)aggregateRelationship.RelationshipDef;

            relationshipDef.RelationshipType = RelationshipType.Aggregation;
            cpCol = aggregateRelationship.BusinessObjectCollection;
            return(aggregateRelationship);
        }
コード例 #16
0
        private MultipleRelationship <ContactPersonTestBO> GetRelationship(OrganisationTestBO organisationTestBO, RelationshipType relationshipType, out BusinessObjectCollection <ContactPersonTestBO> cpCol)
        {
            MultipleRelationship <ContactPersonTestBO> relationship =
                organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople");
            RelationshipDef relationshipDef = (RelationshipDef)relationship.RelationshipDef;

            relationshipDef.RelationshipType = relationshipType;
            cpCol = relationship.BusinessObjectCollection;
            return(relationship);
        }
コード例 #17
0
        private static MultipleRelationship <ContactPersonTestBO> GetCompositionRelationship(out BusinessObjectCollection <ContactPersonTestBO> cpCol, OrganisationTestBO organisationTestBO)
        {
            MultipleRelationship <ContactPersonTestBO> compositionRelationship =
                organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople");
            RelationshipDef relationshipDef = (RelationshipDef)compositionRelationship.RelationshipDef;

            relationshipDef.RelationshipType = RelationshipType.Composition;
            cpCol = compositionRelationship.BusinessObjectCollection;
            return(compositionRelationship);
        }
コード例 #18
0
        private static ContactPersonTestBO CreateSavedContactPerson(OrganisationTestBO organisation)
        {
            MultipleRelationship <ContactPersonTestBO> relationship = GetContactPersonRelationship(organisation);
            ContactPersonTestBO cp = relationship.BusinessObjectCollection.CreateBusinessObject();

            cp.Surname   = TestUtil.GetRandomString();
            cp.FirstName = TestUtil.GetRandomString();
            cp.Save();
            return(cp);
        }
コード例 #19
0
        protected MultipleRelationship <ContactPersonTestBO> GetRelationship(OrganisationTestBO organisationTestBO)
        {
            RelationshipType relationshipType = GetRelationshipType();
            MultipleRelationship <ContactPersonTestBO> relationship =
                organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople");
            RelationshipDef relationshipDef = (RelationshipDef)relationship.RelationshipDef;

            relationshipDef.RelationshipType = relationshipType;
            return(relationship);
        }
コード例 #20
0
        protected MultipleRelationship <ContactPersonTestBO> GetCompositionRelationship(OrganisationTestBO organisationTestBO, out BusinessObjectCollection <ContactPersonTestBO> cpCol)
        {
            RelationshipType relationshipType = RelationshipType.Composition;
            MultipleRelationship <ContactPersonTestBO> relationship =
                organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople");
            RelationshipDef relationshipDef = (RelationshipDef)relationship.RelationshipDef;

            relationshipDef.RelationshipType = relationshipType;
            cpCol = relationship.BusinessObjectCollection;
            return(relationship);
        }
コード例 #21
0
        private static MultipleRelationship <ContactPersonTestBO> GetAssociationRelationship
            (BusinessObject organisationTestBO, out BusinessObjectCollection <ContactPersonTestBO> cpCol)
        {
            const RelationshipType relationshipType = RelationshipType.Association;
            MultipleRelationship <ContactPersonTestBO> relationship =
                organisationTestBO.Relationships.GetMultiple <ContactPersonTestBO>("ContactPeople");
            RelationshipDef relationshipDef = (RelationshipDef)relationship.RelationshipDef;

            relationshipDef.RelationshipType = relationshipType;
            cpCol = relationship.BusinessObjectCollection;
            return(relationship);
        }
コード例 #22
0
        public void Test_Criteria_OneProp()
        {
            //--------------- Set up test pack ------------------
            MyBO.LoadClassDefWithRelationship();
            MyRelatedBo.LoadClassDef();
            MyBO myBO = new MyBO();
            MultipleRelationship <MyRelatedBo> relationship = myBO.Relationships.GetMultiple <MyRelatedBo>("MyMultipleRelationship");
            //--------------- Test Preconditions ----------------

            //--------------- Execute Test ----------------------
            Criteria relCriteria = relationship.RelKey.Criteria;

            //--------------- Test Result -----------------------
            StringAssert.AreEqualIgnoringCase("MyBoID = '" + myBO.MyBoID.Value.ToString("B") + "'", relCriteria.ToString());
        }
コード例 #23
0
        public void Test_ParentDirtyIfHasCreatedChildren()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     compositionRelationship = GetCompositionRelationship(organisationTestBO, out cpCol);

            //---------------Assert Precondition----------------
            Assert.IsFalse(organisationTestBO.Status.IsDirty);

            //---------------Execute Test ----------------------
            cpCol.CreateBusinessObject();

            //---------------Test Result -----------------------
            Assert.IsTrue(organisationTestBO.Status.IsDirty);
        }
コード例 #24
0
        public void Test_CreateMultipleRelationshipWithTimeout()
        {
            //---------------Set up test pack-------------------
            ClassDef.ClassDefs.Clear();
            IClassDef orgClassDef = OrganisationTestBO.LoadDefaultClassDef();

            ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            RelationshipDef    relationshipDef    = (RelationshipDef)orgClassDef.RelationshipDefCol["ContactPeople"];
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            IMultipleRelationship rel = new MultipleRelationship <ContactPersonTestBO> (organisationTestBO, relationshipDef, organisationTestBO.Props, 30000);

            //---------------Test Result -----------------------
            Assert.IsTrue(true, "Should not give an error when constructing");
        }
コード例 #25
0
        public void TestGetMultiple_Generic()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MyBO.LoadClassDefWithRelationship();

            MyRelatedBo.LoadClassDef();
            MyBO   bo1 = (MyBO)classDef.CreateNewBusinessObject();
            string relationshipName = "MyMultipleRelationship";

            //---------------Execute Test ----------------------
            MultipleRelationship <MyRelatedBo> relationship = bo1.Relationships.GetMultiple <MyRelatedBo>(relationshipName);

            //---------------Test Result -----------------------

            Assert.IsNotNull(relationship);
            Assert.AreEqual(relationshipName, relationship.RelationshipName);
        }
コード例 #26
0
        public void Test_GetDirtyChildren_Added()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     relationship = GetAssociationRelationship
                                                                              (organisationTestBO, out cpCol);

            ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson();

            cpCol.Add(contactPerson);
            //---------------Execute Test ----------------------
            IList <ContactPersonTestBO> dirtyChildren = relationship.GetDirtyChildren();

            //---------------Test Result -----------------------
            Assert.AreEqual(0, dirtyChildren.Count);
        }
コード例 #27
0
        public void Test_Criteria_CompositeKey()
        {
            //--------------- Set up test pack ------------------
            new Car();
            ContactPersonCompositeKey person = new ContactPersonCompositeKey();

            person.PK1Prop1 = TestUtil.GetRandomString();
            person.PK1Prop2 = TestUtil.GetRandomString();
            MultipleRelationship <Car> relationship = person.Relationships.GetMultiple <Car>("Driver");
            //--------------- Test Preconditions ----------------

            //--------------- Execute Test ----------------------
            Criteria relCriteria = relationship.RelKey.Criteria;

            //--------------- Test Result -----------------------
            StringAssert.AreEqualIgnoringCase(string.Format("(DriverFK1 = '{0}') AND (DriverFK2 = '{1}')", person.PK1Prop1, person.PK1Prop2), relCriteria.ToString());
        }
コード例 #28
0
        public void Test_DirtyIfHasAddedChildren()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     aggregationRelationship = GetAggregationRelationship
                                                                                         (organisationTestBO, out cpCol);
            ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateSavedContactPerson();

            //---------------Assert Precondition----------------
            Assert.IsFalse(aggregationRelationship.IsDirty);

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

            //---------------Test Result -----------------------
            Assert.IsTrue(aggregationRelationship.IsDirty);
        }
コード例 #29
0
        public void Test_GetDirtyChildren_Created()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
            BusinessObjectCollection <ContactPersonTestBO> cpCol;
            MultipleRelationship <ContactPersonTestBO>     relationship = GetCompositionRelationship(organisationTestBO, out cpCol);

            ContactPersonTestBO contactPerson = cpCol.CreateBusinessObject();

            contactPerson.Surname   = TestUtil.GetRandomString();
            contactPerson.FirstName = TestUtil.GetRandomString();

            //---------------Execute Test ----------------------
            IList <ContactPersonTestBO> dirtyChildren = relationship.GetDirtyChildren();

            //---------------Test Result -----------------------
            Assert.AreEqual(1, dirtyChildren.Count);
            Assert.IsTrue(dirtyChildren.Contains(contactPerson));
        }
コード例 #30
0
        public void TestGetMultiple_Generic_Fail()
        {
            //---------------Set up test pack-------------------
            IClassDef classDef = MyBO.LoadClassDefWithRelationship();

            MyRelatedBo.LoadClassDef();
            MyBO   bo1 = (MyBO)classDef.CreateNewBusinessObject();
            string relationshipName = "MyRelationship";

            //---------------Execute Test ----------------------
            try
            {
                MultipleRelationship <MyRelatedBo> relationship = bo1.Relationships.GetMultiple <MyRelatedBo>(relationshipName);
                Assert.Fail("Should have failed because we're accessing a single relationship as a multiple.");
                //---------------Test Result -----------------------
            }
            catch (InvalidRelationshipAccessException)
            {
            }
        }
コード例 #31
0
 private static OrganisationTestBO CreateSavedOrganisation_WithOneValidRemovedContactPerson
     (out ContactPersonTestBO contactPerson, out MultipleRelationship<ContactPersonTestBO> relationship)
 {
     OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
     BusinessObjectCollection<ContactPersonTestBO> cpCol;
     relationship = GetAssociationRelationship(organisationTestBO, out cpCol);
     contactPerson = ContactPersonTestBO.CreateSavedContactPerson
         (TestUtil.GetRandomString(), TestUtil.GetRandomString());
     cpCol.Add(contactPerson);
     cpCol.SaveAll();
     organisationTestBO.Save();
     cpCol.Remove(contactPerson);
     return organisationTestBO;
 }
コード例 #32
0
 public void Test_CreateMultipleRelationshipWithTimeout()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     IClassDef orgClassDef = OrganisationTestBO.LoadDefaultClassDef();
     ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();
     OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
     RelationshipDef relationshipDef = (RelationshipDef) orgClassDef.RelationshipDefCol["ContactPeople"];
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     IMultipleRelationship rel = new MultipleRelationship<ContactPersonTestBO> (organisationTestBO, relationshipDef, organisationTestBO.Props, 30000);
     //---------------Test Result -----------------------
     Assert.IsTrue(true, "Should not give an error when constructing");
 }
コード例 #33
0
 public void Test_LoadMultiplerelationship_TimeOutExceeded_WhenTimeOutZero_DoesReloadFromDB()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     IClassDef orgClassDef = OrganisationTestBO.LoadDefaultClassDef();
     ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();
     OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
     RelationshipDef relationshipDef = (RelationshipDef)orgClassDef.RelationshipDefCol["ContactPeople"];
     IMultipleRelationship rel = new MultipleRelationship<ContactPersonTestBO>(organisationTestBO, relationshipDef, organisationTestBO.Props, 0);
     IBusinessObjectCollection collection = rel.BusinessObjectCollection;
     DateTime? initialTimeLastLoaded = collection.TimeLastLoaded;
     //---------------Assert Precondition----------------
     Assert.IsNotNull(collection.TimeLastLoaded);
     Assert.AreEqual(initialTimeLastLoaded, collection.TimeLastLoaded);
     MultipleRelationship<ContactPersonTestBO> relationship = (MultipleRelationship<ContactPersonTestBO>)organisationTestBO.Relationships["ContactPeople"];
     Assert.AreEqual(0, relationship.TimeOut);
     //---------------Execute Test ----------------------
     ContactPersonTestBO contactPerson = organisationTestBO.ContactPeople.CreateBusinessObject();
     contactPerson.Surname = TestUtil.GetRandomString();
     contactPerson.FirstName = TestUtil.GetRandomString();
     contactPerson.Save();
     TestUtil.Wait(100);
     IBusinessObjectCollection secondCollectionCall = rel.BusinessObjectCollection;
     //---------------Test Result -----------------------
     Assert.AreSame(collection, secondCollectionCall);
     Assert.IsNotNull(secondCollectionCall.TimeLastLoaded);
     Assert.AreEqual(1, secondCollectionCall.Count);
     Assert.AreNotEqual(initialTimeLastLoaded, secondCollectionCall.TimeLastLoaded);
 }
コード例 #34
0
 public void Test_LoadMultiplerelationship_TimeOutExceeded_WhenTimeOutTwo_DoesReloadFromDB()
 {
     //---------------Set up test pack-------------------
     ClassDef.ClassDefs.Clear();
     IClassDef orgClassDef = OrganisationTestBO.LoadDefaultClassDef();
     ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();
     OrganisationTestBO organisationTestBO = OrganisationTestBO.CreateSavedOrganisation();
     RelationshipDef relationshipDef = (RelationshipDef)orgClassDef.RelationshipDefCol["ContactPeople"];
     IMultipleRelationship rel = new MultipleRelationship<ContactPersonTestBO>(organisationTestBO, relationshipDef, organisationTestBO.Props, 2);
     IBusinessObjectCollection collection = rel.BusinessObjectCollection;
     DateTime? initialTimeLastLoaded = collection.TimeLastLoaded;
     //---------------Assert Precondition----------------
     Assert.AreEqual(initialTimeLastLoaded, collection.TimeLastLoaded);
     //---------------Execute Test ----------------------
     TestUtil.Wait(100);
     IBusinessObjectCollection secondCollectionCall = rel.BusinessObjectCollection;
     //---------------Test Result -----------------------
     Assert.AreSame(collection, secondCollectionCall);
     Assert.AreNotEqual(initialTimeLastLoaded, secondCollectionCall.TimeLastLoaded);
 }