public void TestProtectedSets()
        {
            FakeRelationshipDef relDef    = new FakeRelationshipDef();
            RelKeyDef           relKeyDef = new RelKeyDef();
            PropDef             propDef   = new PropDef("prop", typeof(string), PropReadWriteRule.ReadWrite, null);

            relKeyDef.Add(new RelPropDef(propDef, ""));

            Assert.AreEqual("rel", relDef.RelationshipName);
            relDef.SetRelationshipName("newrel");
            Assert.AreEqual("newrel", relDef.RelationshipName);

            Assert.AreEqual(typeof(MyRelatedBo), relDef.RelatedObjectClassType);
            relDef.SetRelatedObjectClassType(typeof(MyBO));
            Assert.AreEqual(typeof(MyBO), relDef.RelatedObjectClassType);

            Assert.AreEqual("Habanero.Test", relDef.RelatedObjectAssemblyName);
            relDef.SetRelatedObjectAssemblyName("someassembly");
            Assert.AreEqual("someassembly", relDef.RelatedObjectAssemblyName);

            Assert.AreEqual("Habanero.Test.MyBO", relDef.RelatedObjectClassName);
            relDef.SetRelatedObjectClassName("someclass");
            Assert.AreEqual("someclass", relDef.RelatedObjectClassName);

            Assert.AreEqual(0, relDef.RelKeyDef.Count);
            relDef.SetRelKeyDef(relKeyDef);
            Assert.AreEqual(1, relDef.RelKeyDef.Count);

            Assert.IsTrue(relDef.KeepReferenceToRelatedObject);
            relDef.SetKeepReferenceToRelatedObject(false);
            Assert.IsFalse(relDef.KeepReferenceToRelatedObject);
        }
        public void Test_OwningClassName_WhenOwningClassDefNull_ShouldReturnEmptyString()
        {
            //---------------Set up test pack-------------------
            IRelationshipDef relationshipDef = new FakeRelationshipDef();

            //---------------Assert Precondition----------------
            Assert.IsNull(relationshipDef.OwningClassDef);
            //---------------Execute Test ----------------------
            var owningClassName = relationshipDef.OwningClassName;

            //---------------Test Result -----------------------
            Assert.IsEmpty(owningClassName);
        }
        public void Test_SetOwningClassDef_ShouldSet()
        {
            //---------------Set up test pack-------------------
            IRelationshipDef relationshipDef = new FakeRelationshipDef();
            var expectedClassDef             = new FakeClassDef();

            //---------------Assert Precondition----------------
            Assert.IsNull(relationshipDef.OwningClassDef);
            //---------------Execute Test ----------------------
            relationshipDef.OwningClassDef = expectedClassDef;
            //---------------Test Result -----------------------
            Assert.AreSame(expectedClassDef, relationshipDef.OwningClassDef);
        }
        public void Test_SetClassDef_ShouldReturnClassDef()
        {
            //---------------Set up test pack-------------------
            IClassDef       classDef        = MockRepository.GenerateMock <IClassDef>();
            RelationshipDef relationshipDef = new FakeRelationshipDef();

            //---------------Assert Precondition----------------
            Assert.IsNull(relationshipDef.OwningClassDef);
            //---------------Execute Test ----------------------
            relationshipDef.OwningClassDef = classDef;
            //---------------Test Result -----------------------
            Assert.AreSame(classDef, relationshipDef.OwningClassDef);
        }
        public void Test_OwningClassName_WhenOwningClassDefSet_ShouldReturnOwningClassDefName()
        {
            IClassDef classDef = MockRepository.GenerateStub <IClassDef>();

            classDef.ClassName = GetRandomString();
            IRelationshipDef relationshipDef = new FakeRelationshipDef {
                OwningClassDef = classDef
            };

            //---------------Assert Precondition----------------
            Assert.IsNotNullOrEmpty(classDef.ClassName);
            //---------------Execute Test ----------------------
            var owningClassName = relationshipDef.OwningClassName;

            //---------------Test Result -----------------------
            Assert.AreEqual(classDef.ClassName, owningClassName);
        }
 public void Test_OwningClassName_WhenOwningClassDefSet_ShouldReturnOwningClassDefName()
 {
     IClassDef classDef = MockRepository.GenerateStub<IClassDef>();
     classDef.ClassName = GetRandomString();
     IRelationshipDef relationshipDef = new FakeRelationshipDef { OwningClassDef = classDef };
     //---------------Assert Precondition----------------
     Assert.IsNotNullOrEmpty(classDef.ClassName);
     //---------------Execute Test ----------------------
     var owningClassName = relationshipDef.OwningClassName;
     //---------------Test Result -----------------------
     Assert.AreEqual(classDef.ClassName, owningClassName);
 }
 public void Test_OwningClassName_WhenOwningClassDefNull_ShouldReturnEmptyString()
 {
     //---------------Set up test pack-------------------
     IRelationshipDef relationshipDef = new FakeRelationshipDef();
     //---------------Assert Precondition----------------
     Assert.IsNull(relationshipDef.OwningClassDef);
     //---------------Execute Test ----------------------
     var owningClassName = relationshipDef.OwningClassName;
     //---------------Test Result -----------------------
     Assert.IsEmpty(owningClassName);
 }
 public void Test_GetClassDef_ShouldReturnClassDef()
 {
     //---------------Set up test pack-------------------
     IClassDef classDef = MockRepository.GenerateMock<IClassDef>();
     IRelationshipDef relationshipDef = new FakeRelationshipDef {OwningClassDef = classDef};
     //---------------Assert Precondition----------------
     //---------------Execute Test ----------------------
     IClassDef owningClassDef = relationshipDef.OwningClassDef;
     //---------------Test Result -----------------------
     Assert.AreSame(classDef, owningClassDef);
 }
 public void Test_SetOwningClassDef_ShouldSet()
 {
     //---------------Set up test pack-------------------
     IRelationshipDef relationshipDef = new FakeRelationshipDef();
     var expectedClassDef = new FakeClassDef();
     //---------------Assert Precondition----------------
     Assert.IsNull(relationshipDef.OwningClassDef);
     //---------------Execute Test ----------------------
     relationshipDef.OwningClassDef = expectedClassDef;
     //---------------Test Result -----------------------
     Assert.AreSame(expectedClassDef, relationshipDef.OwningClassDef);
 }
        public void TestProtectedSets()
        {
            FakeRelationshipDef relDef = new FakeRelationshipDef();
            RelKeyDef relKeyDef = new RelKeyDef();
            PropDef propDef = new PropDef("prop", typeof (string), PropReadWriteRule.ReadWrite, null);
            relKeyDef.Add(new RelPropDef(propDef, ""));

            Assert.AreEqual("rel", relDef.RelationshipName);
            relDef.SetRelationshipName("newrel");
            Assert.AreEqual("newrel", relDef.RelationshipName);

            Assert.AreEqual(typeof (MyRelatedBo), relDef.RelatedObjectClassType);
            relDef.SetRelatedObjectClassType(typeof (MyBO));
            Assert.AreEqual(typeof (MyBO), relDef.RelatedObjectClassType);

            Assert.AreEqual("Habanero.Test", relDef.RelatedObjectAssemblyName);
            relDef.SetRelatedObjectAssemblyName("someassembly");
            Assert.AreEqual("someassembly", relDef.RelatedObjectAssemblyName);

            Assert.AreEqual("Habanero.Test.MyBO", relDef.RelatedObjectClassName);
            relDef.SetRelatedObjectClassName("someclass");
            Assert.AreEqual("someclass", relDef.RelatedObjectClassName);

            Assert.AreEqual(0, relDef.RelKeyDef.Count);
            relDef.SetRelKeyDef(relKeyDef);
            Assert.AreEqual(1, relDef.RelKeyDef.Count);

            Assert.IsTrue(relDef.KeepReferenceToRelatedObject);
            relDef.SetKeepReferenceToRelatedObject(false);
            Assert.IsFalse(relDef.KeepReferenceToRelatedObject);
        }