public void Test_GetClassName_ShouldReturnOwningClassName()
        {//ClassName
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var className = relationshipDef.ClassName;

            //---------------Test Result -----------------------
            Assert.AreEqual(className, relationshipDef.OwningClassName);
        }
        public void Test_GetClassDef_ShouldReturnOwningClassDef()
        {//ClassDef
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var classDef = relationshipDef.ClassDef;

            //---------------Test Result -----------------------
            Assert.AreSame(classDef, relationshipDef.OwningClassDef);
        }
        public void Test_GetDescription_WhenNotSetShouldReturnEmptyString()
        {
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var actualDescription = relationshipDef.Description;

            //---------------Test Result -----------------------
            Assert.IsNullOrEmpty(actualDescription);
        }
        public void Test_SetDescription_ShouldSeet()
        {
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            var expectedRelationshipDescription = GetRandomString();

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            relationshipDef.Description = expectedRelationshipDescription;
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedRelationshipDescription, relationshipDef.Description);
        }
        public void Test_GetPropertyTypeAssemblyName_ShouldReturnRelatedObjectAssemblyName()
        {//PropertyTypeAssemblyName
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var propertyTypeAssemblyName = relationshipDef.PropertyTypeAssemblyName;

            //---------------Test Result -----------------------
            Assert.IsNotNullOrEmpty(propertyTypeAssemblyName);
            Assert.AreEqual(propertyTypeAssemblyName, relationshipDef.RelatedObjectAssemblyName);
        }
        public void Test_SetPropertyTypeName_ShouldSetItToRelatedObjectAssemblyName()
        {  ////PropertyTypeName
            //---------------Set up test pack-------------------
            var relationshipDef           = new FakeSingleRelationshipDef();
            var relatedObjectAssemblyName = relationshipDef.RelatedObjectAssemblyName;

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            relationshipDef.PropertyTypeName = relatedObjectAssemblyName;
            //---------------Test Result -----------------------
            StringAssert.Contains(relatedObjectAssemblyName, relationshipDef.PropertyTypeName);
        }
        public void Test_GetPropertyType_ShouldReturnRelatedObjectClassType()
        {//PropertyType
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            var propertyType = relationshipDef.PropertyType;

            //---------------Test Result -----------------------
            Assert.AreEqual(propertyType, relationshipDef.RelatedObjectClassType);
            Assert.AreSame(propertyType, relationshipDef.RelatedObjectClassType);
        }
        public void Test_SetPropertyType_ShouldSetItToRelatedObjectClassType()
        {  ////PropertyType
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            var randomType      = relationshipDef.RelatedObjectClassType;

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            relationshipDef.PropertyType = randomType;
            //---------------Test Result -----------------------
            Assert.AreSame(randomType, relationshipDef.PropertyType);
        }
        public void Test_SetClassDef_ShouldSetItToOwningClassDef()
        {  ////ClassDef
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            var classDef        = relationshipDef.OwningClassDef;

            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------
            relationshipDef.ClassDef = classDef;
            //---------------Test Result -----------------------
            Assert.AreEqual(classDef, relationshipDef.ClassDef);
        }
        public void Test_GetDisplayNameFull_ShouldReturnDisplayName()
        {//ClassName
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            var classNameFull = relationshipDef.DisplayNameFull;

            //---------------Test Result -----------------------
            Assert.AreEqual(classNameFull, relationshipDef.DisplayName);
        }
        public void Test_ConstructRelDef_ShouldSetReadWriteRuleToReadWriteByDefault()
        {
            //---------------Set up test pack-------------------

            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var relationshipDef = new FakeSingleRelationshipDef();

            //---------------Test Result -----------------------
            Assert.AreEqual(PropReadWriteRule.ReadWrite, relationshipDef.ReadWriteRule);
        }
        public void Test_SetReadWriteRule_ShouldSetRuleOnRelationship()
        {
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();

            //---------------Assert Precondition----------------
            Assert.AreEqual(PropReadWriteRule.ReadWrite, relationshipDef.ReadWriteRule);
            //---------------Execute Test ----------------------
            relationshipDef.ReadWriteRule = PropReadWriteRule.WriteNew;
            //---------------Test Result -----------------------
            Assert.AreEqual(PropReadWriteRule.WriteNew, relationshipDef.ReadWriteRule);
        }
Esempio n. 13
0
        public void Test_IsOneToOne_WhenIsSingleRelationship_ByDefault_ShouldReturnFalse()
        {
            //---------------Set up test pack-------------------
            IRelationshipDef relationshipDef = new FakeSingleRelationshipDef();

            //---------------Assert Precondition----------------
            Assert.IsInstanceOf(typeof(SingleRelationshipDef), relationshipDef);
            //---------------Execute Test ----------------------
            bool isOneToOne = relationshipDef.IsOneToOne;

            //---------------Test Result -----------------------
            Assert.IsFalse(isOneToOne);
        }
        public void Test_SetPropertyName_ShouldSetRelationshipName()
        {
            //---------------Set up test pack-------------------
            var relationshipDef          = new FakeSingleRelationshipDef(GetRandomString());
            var expectedRelationshipName = GetRandomString();

            //---------------Assert Precondition----------------
            Assert.AreNotEqual(expectedRelationshipName, relationshipDef.RelationshipName);
            //---------------Execute Test ----------------------
            relationshipDef.PropertyName = expectedRelationshipName;
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedRelationshipName, relationshipDef.RelationshipName);
        }
        public void Test_PropertyName_ShouldReturnRelationshipName()
        {
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef(GetRandomString());

            //---------------Assert Precondition----------------
            Assert.IsNotNullOrEmpty(relationshipDef.RelationshipName);
            //---------------Execute Test ----------------------
            var propertyName = relationshipDef.PropertyName;

            //---------------Test Result -----------------------
            Assert.AreEqual(relationshipDef.RelationshipName, propertyName);
        }
        public void Test_SetLookupList_ShouldDoNothing_ShouldReturnNullLookupList()
        {
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var lookupList = relationshipDef.LookupList;

            //---------------Test Result -----------------------
            Assert.IsNotNull(lookupList);
            Assert.IsInstanceOf <NullLookupList>(lookupList);
        }
        public void Test_PropRules_ShouldReturnEmptyPropRules()
        {
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var propRules = relationshipDef.PropRules;

            //---------------Test Result -----------------------
            Assert.IsNotNull(propRules);
            Assert.IsEmpty(propRules, "Should be empty list of prop rules");
        }
        public void Test_IsManyToOne_WhenIsSingleRelationship_NotSetOneToOne_ShouldReturnTrue()
        {
            //---------------Set up test pack-------------------
            var singleRelationshipDef        = new FakeSingleRelationshipDef();
            IRelationshipDef relationshipDef = singleRelationshipDef;

            //---------------Assert Precondition----------------
            Assert.IsInstanceOf(typeof(SingleRelationshipDef), relationshipDef);
            //---------------Execute Test ----------------------
            bool isManyToOne = relationshipDef.IsManyToOne;

            //---------------Test Result -----------------------
            Assert.IsTrue(isManyToOne);
        }
        public void Test_DisplayName_ShouldReturnRelationshipNamePascalCased()
        {
            //---------------Set up test pack-------------------
            var          relationshipDef     = new FakeSingleRelationshipDef("SomeName");
            const string expectedDisplayName = "Some Name";

            //---------------Assert Precondition----------------
            Assert.IsNotNullOrEmpty(relationshipDef.RelationshipName);
            //---------------Execute Test ----------------------
            var propertyName = relationshipDef.DisplayName;

            //---------------Test Result -----------------------
            Assert.AreEqual(expectedDisplayName, propertyName);
        }
        public void Test_GetCompulsory_WhenFalse_ShouldReturnRelationshipIsCompulsory()
        {
            //---------------Set up test pack-------------------

            var relationshipDef = new FakeSingleRelationshipDef();

            //---------------Assert Precondition----------------
            Assert.IsFalse(relationshipDef.IsCompulsory);
            //---------------Execute Test ----------------------
            var compulsory = relationshipDef.Compulsory;

            //---------------Test Result -----------------------
            Assert.IsFalse(compulsory);
        }
        public void Test_SetAsCompulsory_ShouldSetIsCompulsoryTrue()
        {
            //---------------Set up test pack-------------------
            var singleRelationshipDef = new FakeSingleRelationshipDef();

            IRelationshipDef relationshipDef = singleRelationshipDef;

            //---------------Assert Precondition----------------
            Assert.IsInstanceOf(typeof(SingleRelationshipDef), relationshipDef);
            Assert.IsFalse(relationshipDef.IsCompulsory);
            //---------------Execute Test ----------------------
            singleRelationshipDef.SetAsCompulsory();
            //---------------Test Result -----------------------
            Assert.IsTrue(relationshipDef.IsCompulsory);
        }
        public void Test_IsCompulsory_WhenNoPropDefs_ShouldRetFalse()
        {
            //---------------Set up test pack-------------------
            FakeSingleRelationshipDef relationshipDef = new FakeSingleRelationshipDef();
            IRelKeyDef relKeyDef = new RelKeyDef();

            relationshipDef.SetRelKeyDef(relKeyDef);
            relationshipDef.OwningBOHasForeignKey = true;
            //---------------Assert Precondition----------------
            Assert.IsTrue(relationshipDef.OwningBOHasForeignKey);
            //---------------Execute Test ----------------------
            bool isCompulsory = relationshipDef.IsCompulsory;

            //---------------Test Result -----------------------
            Assert.IsFalse(isCompulsory, "Rel Should not be compulsory");
        }
        public void Test_IsOneToOne_WhenNoRevRelTypeLoaded_SetOneToOneSetToFalse_ShouldReturnFalseBug944()
        {
            //---------------Set up test pack-------------------
            var singleRelationshipDef = new FakeSingleRelationshipDef
            {
                ReverseRelationshipName = GetRandomString()
            };
            IRelationshipDef relationshipDef = singleRelationshipDef;

            //---------------Assert Precondition----------------
            Assert.IsInstanceOf(typeof(SingleRelationshipDef), relationshipDef);
            Assert.IsNotNullOrEmpty(relationshipDef.ReverseRelationshipName);
            //---------------Execute Test ----------------------
            bool isOneToOne = relationshipDef.IsOneToOne;

            //---------------Test Result -----------------------
            Assert.IsFalse(isOneToOne);
        }
        public void Test_IsCompulsory_WhenOwnerPropDefNull_ShouldRetFalse()
        {
            //---------------Set up test pack-------------------
            FakeSingleRelationshipDef relationshipDef = new FakeSingleRelationshipDef();
            var         relKeyDef  = new RelKeyDef();
            IRelPropDef relPropDef = MockRepository.GenerateStub <IRelPropDef>();

            relPropDef.Stub(def => def.OwnerPropertyName).Return(TestUtil.GetRandomString());
            relKeyDef.Add(relPropDef);
            relationshipDef.SetRelKeyDef(relKeyDef);
            relationshipDef.OwningBOHasForeignKey = true;
            //---------------Assert Precondition----------------
            Assert.IsTrue(relationshipDef.OwningBOHasForeignKey);
            Assert.IsNull(relPropDef.OwnerPropDef);
            //---------------Execute Test ----------------------
            bool isCompulsory = relationshipDef.IsCompulsory;

            //---------------Test Result -----------------------
            Assert.IsFalse(isCompulsory, "Rel Should not be compulsory");
        }
        public void Test_IsCompulsory_WhenPropCompButNotOwningBoHasFK_ShouldRetFalse()
        {
            //---------------Set up test pack-------------------
            FakeSingleRelationshipDef relationshipDef = new FakeSingleRelationshipDef();
            var relKeyDef = new RelKeyDef();
            var propDef   = new PropDefFake {
                Compulsory = true
            };
            var relPropDef = new RelPropDef(propDef, "SomeThing");

            relKeyDef.Add(relPropDef);
            relationshipDef.SetRelKeyDef(relKeyDef);
            relationshipDef.OwningBOHasForeignKey = false;
            //---------------Assert Precondition----------------
            Assert.IsTrue(propDef.Compulsory);
            Assert.IsFalse(relationshipDef.OwningBOHasForeignKey);
            //---------------Execute Test ----------------------
            bool isCompulsory = relationshipDef.IsCompulsory;

            //---------------Test Result -----------------------
            Assert.IsFalse(isCompulsory, "Rel Should not be compulsory");
        }
        public void Test_IsCompulsory_WhenNotHasCompulsoryFKProps_ShouldReturnFalse()
        {
            FakeSingleRelationshipDef singleRelationshipDef = new FakeSingleRelationshipDef();
            var relKeyDef = new RelKeyDef();
            var propDef   = new PropDefFake {
                Compulsory = false
            };
            var relPropDef = new RelPropDef(propDef, "SomeThing");

            relKeyDef.Add(relPropDef);
            singleRelationshipDef.SetRelKeyDef(relKeyDef);
            singleRelationshipDef.OwningBOHasForeignKey = true;

            IRelationshipDef relationshipDef = singleRelationshipDef;

            //---------------Assert Precondition----------------
            Assert.IsFalse(propDef.Compulsory);
            Assert.IsTrue(singleRelationshipDef.OwningBOHasForeignKey);
            //---------------Execute Test ----------------------
            bool isCompulsory = relationshipDef.IsCompulsory;

            //---------------Test Result -----------------------
            Assert.IsFalse(isCompulsory);
        }
 public void Test_GetDescription_WhenNotSetShouldReturnEmptyString()
 {
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var actualDescription = relationshipDef.Description;
     //---------------Test Result -----------------------
     Assert.IsNullOrEmpty(actualDescription);
 }
 public void Test_SetDescription_ShouldSeet()
 {
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     var expectedRelationshipDescription = GetRandomString();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     relationshipDef.Description = expectedRelationshipDescription;
     //---------------Test Result -----------------------
     Assert.AreEqual(expectedRelationshipDescription, relationshipDef.Description);
 }
 public void Test_IsOneToOne_WhenIsSingleRelationship_SetOneToOneSetToTrue_ShouldReturnTrue()
 {
     //---------------Set up test pack-------------------
     var singleRelationshipDef = new FakeSingleRelationshipDef();
     singleRelationshipDef.SetAsOneToOne();
     IRelationshipDef relationshipDef = singleRelationshipDef;
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf(typeof(SingleRelationshipDef), relationshipDef);
     //---------------Execute Test ----------------------
     bool isOneToOne = relationshipDef.IsOneToOne;
     //---------------Test Result -----------------------
     Assert.IsTrue(isOneToOne);
 }
 public void Test_GetPropertyType_ShouldReturnRelatedObjectClassType()
 {//PropertyType
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var propertyType = relationshipDef.PropertyType;
     //---------------Test Result -----------------------
     Assert.AreEqual(propertyType, relationshipDef.RelatedObjectClassType);
     Assert.AreSame(propertyType, relationshipDef.RelatedObjectClassType);
 }
 public void Test_IsCompulsory_WhenPropCompButNotOwningBoHasFK_ShouldRetFalse()
 {
     //---------------Set up test pack-------------------
     FakeSingleRelationshipDef relationshipDef = new FakeSingleRelationshipDef();
     var relKeyDef = new RelKeyDef();
     var propDef = new PropDefFake { Compulsory = true };
     var relPropDef = new RelPropDef(propDef, "SomeThing");
     relKeyDef.Add(relPropDef);
     relationshipDef.SetRelKeyDef(relKeyDef);
     relationshipDef.OwningBOHasForeignKey = false;
     //---------------Assert Precondition----------------
     Assert.IsTrue(propDef.Compulsory);
     Assert.IsFalse(relationshipDef.OwningBOHasForeignKey);
     //---------------Execute Test ----------------------
     bool isCompulsory = relationshipDef.IsCompulsory;
     //---------------Test Result -----------------------
     Assert.IsFalse(isCompulsory, "Rel Should not be compulsory");
 }
 public void Test_IsCompulsory_WhenNoPropDefs_ShouldRetFalse()
 {
     //---------------Set up test pack-------------------
     FakeSingleRelationshipDef relationshipDef = new FakeSingleRelationshipDef();
     IRelKeyDef relKeyDef = new RelKeyDef();
     relationshipDef.SetRelKeyDef(relKeyDef);
     relationshipDef.OwningBOHasForeignKey = true;
     //---------------Assert Precondition----------------
     Assert.IsTrue(relationshipDef.OwningBOHasForeignKey);
     //---------------Execute Test ----------------------
     bool isCompulsory = relationshipDef.IsCompulsory;
     //---------------Test Result -----------------------
     Assert.IsFalse(isCompulsory, "Rel Should not be compulsory");
 }
        public void Test_SetPropertyName_ShouldSetRelationshipName()
        {
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef(GetRandomString());
            var expectedRelationshipName = GetRandomString();

            //---------------Assert Precondition----------------
            Assert.AreNotEqual(expectedRelationshipName, relationshipDef.RelationshipName);
            //---------------Execute Test ----------------------
            relationshipDef.PropertyName = expectedRelationshipName;
            //---------------Test Result -----------------------
            Assert.AreEqual(expectedRelationshipName, relationshipDef.RelationshipName);
        }
 public void Test_SetPropertyTypeName_ShouldSetItToRelatedObjectAssemblyName()
 {  ////PropertyTypeName
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     var relatedObjectAssemblyName = relationshipDef.RelatedObjectAssemblyName;
    
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     relationshipDef.PropertyTypeName = relatedObjectAssemblyName;
     //---------------Test Result -----------------------
     StringAssert.Contains(relatedObjectAssemblyName,relationshipDef.PropertyTypeName);
 
 }
 public void Test_SetAsCompulsory_ShouldSetIsCompulsoryTrue()
 {
     //---------------Set up test pack-------------------
     var singleRelationshipDef = new FakeSingleRelationshipDef();
     
     IRelationshipDef relationshipDef = singleRelationshipDef;
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf(typeof(SingleRelationshipDef), relationshipDef);
     Assert.IsFalse(relationshipDef.IsCompulsory);
     //---------------Execute Test ----------------------
     singleRelationshipDef.SetAsCompulsory();
     //---------------Test Result -----------------------
     Assert.IsTrue(relationshipDef.IsCompulsory);
 }
        public void Test_SetLookupList_ShouldDoNothing_ShouldReturnNullLookupList()
        {
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var lookupList = relationshipDef.LookupList;
            //---------------Test Result -----------------------
            Assert.IsNotNull(lookupList);
            Assert.IsInstanceOf<NullLookupList>(lookupList);
        }
        public void Test_PropRules_ShouldReturnEmptyPropRules()
        {
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var propRules = relationshipDef.PropRules;
            //---------------Test Result -----------------------
            Assert.IsNotNull(propRules);
            Assert.IsEmpty(propRules, "Should be empty list of prop rules");
        }
        public void Test_ConstructRelDef_ShouldSetReadWriteRuleToReadWriteByDefault()
        {
            //---------------Set up test pack-------------------
            
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Test Result -----------------------
            Assert.AreEqual(PropReadWriteRule.ReadWrite, relationshipDef.ReadWriteRule);
        }
 public void Test_IsOneToOne_WhenNoRevRelTypeLoaded_SetOneToOneSetToTrue_ShouldReturnTrue_Bug944()
 {
     //---------------Set up test pack-------------------
     var singleRelationshipDef = new FakeSingleRelationshipDef
                                     {
                                         ReverseRelationshipName = GetRandomString()
                                     };
     singleRelationshipDef.SetAsOneToOne();
     IRelationshipDef relationshipDef = singleRelationshipDef;
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf(typeof(SingleRelationshipDef), relationshipDef);
     Assert.IsNotNullOrEmpty(relationshipDef.ReverseRelationshipName);
     //---------------Execute Test ----------------------
     bool isOneToOne = relationshipDef.IsOneToOne;
     //---------------Test Result -----------------------
     Assert.IsTrue(isOneToOne);
 }
        public void Test_GetCompulsory_WhenFalse_ShouldReturnRelationshipIsCompulsory()
        {
            //---------------Set up test pack-------------------

            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------
            Assert.IsFalse(relationshipDef.IsCompulsory);
            //---------------Execute Test ----------------------
            var compulsory = relationshipDef.Compulsory;
            //---------------Test Result -----------------------
            Assert.IsFalse(compulsory);
        }
 public void Test_DisplayName_ShouldReturnRelationshipNamePascalCased()
 {
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef("SomeName");
     const string expectedDisplayName = "Some Name";
     //---------------Assert Precondition----------------
     Assert.IsNotNullOrEmpty(relationshipDef.RelationshipName);
     //---------------Execute Test ----------------------
     var propertyName = relationshipDef.DisplayName;
     //---------------Test Result -----------------------
     Assert.AreEqual(expectedDisplayName, propertyName);
 }
 public void Test_GetClassName_ShouldReturnOwningClassName()
 {//ClassName
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var className = relationshipDef.ClassName;
     //---------------Test Result -----------------------
     Assert.AreEqual(className, relationshipDef.OwningClassName);
 }
 public void Test_PropertyName_ShouldReturnRelationshipName()
 {
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef(GetRandomString());
     
     //---------------Assert Precondition----------------
     Assert.IsNotNullOrEmpty(relationshipDef.RelationshipName);
     //---------------Execute Test ----------------------
     var propertyName = relationshipDef.PropertyName;
     //---------------Test Result -----------------------
     Assert.AreEqual(relationshipDef.RelationshipName, propertyName);
 }
        public void Test_GetDisplayNameFull_ShouldReturnDisplayName()
        {//ClassName
            //---------------Set up test pack-------------------
            var relationshipDef = new FakeSingleRelationshipDef();
            //---------------Assert Precondition----------------
            //---------------Execute Test ----------------------

            var classNameFull = relationshipDef.DisplayNameFull;
            //---------------Test Result -----------------------
            Assert.AreEqual(classNameFull, relationshipDef.DisplayName);
        }
 public void Test_IsCompulsory_WhenOwnerPropDefNull_ShouldRetFalse()
 {
     //---------------Set up test pack-------------------
     FakeSingleRelationshipDef relationshipDef = new FakeSingleRelationshipDef();
     var relKeyDef = new RelKeyDef();
     IRelPropDef relPropDef = MockRepository.GenerateStub<IRelPropDef>();
     relPropDef.Stub(def => def.OwnerPropertyName).Return(TestUtil.GetRandomString());
     relKeyDef.Add(relPropDef);
     relationshipDef.SetRelKeyDef(relKeyDef);
     relationshipDef.OwningBOHasForeignKey = true;
     //---------------Assert Precondition----------------
     Assert.IsTrue(relationshipDef.OwningBOHasForeignKey);
     Assert.IsNull(relPropDef.OwnerPropDef);
     //---------------Execute Test ----------------------
     bool isCompulsory = relationshipDef.IsCompulsory;
     //---------------Test Result -----------------------
     Assert.IsFalse(isCompulsory, "Rel Should not be compulsory");
 }
 public void Test_SetClassDef_ShouldSetItToOwningClassDef()
 {  ////ClassDef
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     var classDef = relationshipDef.OwningClassDef;
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     relationshipDef.ClassDef = classDef; 
     //---------------Test Result -----------------------
     Assert.AreEqual(classDef, relationshipDef.ClassDef);
 }
        public void Test_IsCompulsory_WhenNotHasCompulsoryFKProps_ShouldReturnFalse()
        {
            FakeSingleRelationshipDef singleRelationshipDef = new FakeSingleRelationshipDef();
            var relKeyDef = new RelKeyDef();
            var propDef = new PropDefFake { Compulsory = false };
            var relPropDef = new RelPropDef(propDef, "SomeThing");
            relKeyDef.Add(relPropDef);
            singleRelationshipDef.SetRelKeyDef(relKeyDef);
            singleRelationshipDef.OwningBOHasForeignKey = true;

            IRelationshipDef relationshipDef = singleRelationshipDef;
            //---------------Assert Precondition----------------
            Assert.IsFalse(propDef.Compulsory);
            Assert.IsTrue(singleRelationshipDef.OwningBOHasForeignKey);
            //---------------Execute Test ----------------------
            bool isCompulsory = relationshipDef.IsCompulsory;
            //---------------Test Result -----------------------
            Assert.IsFalse(isCompulsory);
        }
 public void Test_GetClassDef_ShouldReturnOwningClassDef()
 {//ClassDef
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var classDef = relationshipDef.ClassDef;
     //---------------Test Result -----------------------
     Assert.AreSame(classDef, relationshipDef.OwningClassDef);
 }
 public void Test_SetPropertyType_ShouldSetItToRelatedObjectClassType()
 {  ////PropertyType
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     var randomType=relationshipDef.RelatedObjectClassType;
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     relationshipDef.PropertyType = randomType;
     //---------------Test Result -----------------------
     Assert.AreSame(randomType, relationshipDef.PropertyType);
 }
 public void Test_SetReadWriteRule_ShouldSetRuleOnRelationship()
 {
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     
     //---------------Assert Precondition----------------
     Assert.AreEqual(PropReadWriteRule.ReadWrite, relationshipDef.ReadWriteRule);
     //---------------Execute Test ----------------------
     relationshipDef.ReadWriteRule = PropReadWriteRule.WriteNew;
     //---------------Test Result -----------------------
     Assert.AreEqual(PropReadWriteRule.WriteNew, relationshipDef.ReadWriteRule);
 }
Esempio n. 51
0
 public void Test_IsOneToOne_WhenIsSingleRelationship_ByDefault_ShouldReturnFalse()
 {
     //---------------Set up test pack-------------------
     IRelationshipDef relationshipDef = new FakeSingleRelationshipDef();
     //---------------Assert Precondition----------------
     Assert.IsInstanceOf(typeof(SingleRelationshipDef), relationshipDef);
     //---------------Execute Test ----------------------
     bool isOneToOne = relationshipDef.IsOneToOne;
     //---------------Test Result -----------------------
     Assert.IsFalse(isOneToOne);
 }
 public void Test_GetPropertyTypeAssemblyName_ShouldReturnRelatedObjectAssemblyName()
 {//PropertyTypeAssemblyName
     //---------------Set up test pack-------------------
     var relationshipDef = new FakeSingleRelationshipDef();
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     var propertyTypeAssemblyName = relationshipDef.PropertyTypeAssemblyName;
     //---------------Test Result -----------------------
     Assert.IsNotNullOrEmpty(propertyTypeAssemblyName);
     Assert.AreEqual(propertyTypeAssemblyName, relationshipDef.RelatedObjectAssemblyName);
  }