Пример #1
0
        public void Test_GetSingleRevRelationshipName_WhenHasRevRel_ShouldBeFoundRevRelName()
        {
            //---------------Set up test pack-------------------
            var             classType            = typeof(FakeBOWithReverseSingle).ToTypeWrapper();
            const string    relationshipName     = "SingleWithRevesre";
            PropertyWrapper relPropInfo          = classType.GetProperty(relationshipName);
            const string    foundRevRelationship = "ReverseSingleRel";
            var             relatedClassType     = relPropInfo.RelatedClassType;

            //---------------Assert Precondition----------------
            Assert.IsNotNull(relPropInfo);
            relatedClassType.AssertPropertyExists(foundRevRelationship);
            //---------------Execute Test ----------------------
            string reverseRelationshipName = relPropInfo.GetSingleReverseRelationshipName <AutoMapOneToOneAttribute>();

            //---------------Test Result -----------------------
            Assert.AreEqual(foundRevRelationship, reverseRelationshipName);
        }
Пример #2
0
        public void Test_GetSingleRevRelationshipName_ShouldReturnRelDefWithRevRelNameSet()
        {
            //---------------Set up test pack-------------------
            var             classType          = typeof(FakeBOAttributePKAndPKNaming).ToTypeWrapper();
            const string    expectedPropName   = "MyMultipleRevRel2";
            PropertyWrapper propertyInfo       = classType.GetProperty(expectedPropName);
            PropertyWrapper reverseRelPropInfo = propertyInfo.GetSingleReverseRelPropInfos()[0];

            //---------------Assert Precondition----------------
            propertyInfo.AssertIsMultipleRelationship();
            Assert.IsTrue(propertyInfo.HasSingleReverseRelationship, "There is no reverse single rel");

            Assert.AreNotEqual(classType.Name, reverseRelPropInfo.Name);
            //---------------Execute Test ----------------------
            string reverseRelationshipName = propertyInfo.GetSingleReverseRelationshipName <AutoMapOneToManyAttribute>();

            //---------------Test Result -----------------------
            Assert.AreEqual(reverseRelPropInfo.Name, reverseRelationshipName);
        }
 private static void AssertMockPropSetupCorrectly(PropertyWrapper propertyWrapper, TypeWrapper ownerType, TypeWrapper relatedType, string relationshipName, string reverseRelName)
 {
     Assert.AreEqual(reverseRelName, propertyWrapper.GetSingleReverseRelationshipName<AutoMapOneToOneAttribute>());
     Assert.AreSame(ownerType, propertyWrapper.DeclaringType);
     Assert.AreSame(relatedType, propertyWrapper.RelatedClassType);
     Assert.AreEqual(relationshipName, propertyWrapper.Name);
 }