示例#1
0
        public void TestGetReverseRelationship_ReverseRelationshipSpecifiedButNotFound()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO.LoadDefaultClassDef();
            IClassDef cpClassDef = ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();

            string reverseRelationshipName = TestUtil.GetRandomString();

            cpClassDef.RelationshipDefCol["Organisation"].ReverseRelationshipName = reverseRelationshipName;

            OrganisationTestBO  organisation  = OrganisationTestBO.CreateSavedOrganisation();
            ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateUnsavedContactPerson();

            SingleRelationship <OrganisationTestBO> organisationRel =
                contactPerson.Relationships.GetSingle <OrganisationTestBO>("Organisation");

            //---------------Execute Test ----------------------
            try
            {
                organisationRel.GetReverseRelationship(organisation);
                Assert.Fail("Should have failed since a reverse relationship was specified that didn't exist.");
            }
            catch (HabaneroDeveloperException ex)
            {
                StringAssert.Contains(
                    string.Format(
                        "The relationship 'Organisation' on class 'ContactPersonTestBO' has a reverse relationship defined ('{0}')",
                        reverseRelationshipName), ex.Message);
            }
        }
示例#2
0
        public void TestGetReverseRelationship()
        {
            //---------------Set up test pack-------------------
            OrganisationTestBO.LoadDefaultClassDef_WithTwoRelationshipsToContactPerson();
            IClassDef cpClassDef = ContactPersonTestBO.LoadClassDefOrganisationTestBORelationship_MultipleReverse();

            cpClassDef.RelationshipDefCol["Organisation"].ReverseRelationshipName = "OtherContactPeople";

            OrganisationTestBO  organisation  = OrganisationTestBO.CreateSavedOrganisation();
            ContactPersonTestBO contactPerson = ContactPersonTestBO.CreateUnsavedContactPerson();

            SingleRelationship <OrganisationTestBO> organisationRel =
                contactPerson.Relationships.GetSingle <OrganisationTestBO>("Organisation");
            MultipleRelationship <ContactPersonTestBO> contactPeopleRel =
                organisation.Relationships.GetMultiple <ContactPersonTestBO>("OtherContactPeople");

            //---------------Execute Test ----------------------
            IRelationship reverseRelationship = organisationRel.GetReverseRelationship(organisation);

            //---------------Test Result -----------------------
            Assert.AreSame(contactPeopleRel, reverseRelationship);
        }