Ejemplo n.º 1
0
 public void Test_Add_ShouldSetPropDefsClassDef()
 {
     //---------------Set up test pack-------------------
     PropDef propDef = new PropDefFake();
     PropDefCol col = new PropDefCol();
     var expectedClassDef = MockRepository.GenerateStub<IClassDef>();
     col.ClassDef = expectedClassDef;
     //---------------Assert Preconditions---------------
     Assert.IsNull(propDef.ClassDef);
     //---------------Execute Test ----------------------
     col.Add(propDef);
     //---------------Test Result -----------------------
     Assert.AreSame(expectedClassDef, propDef.ClassDef);
 }
Ejemplo n.º 2
0
        public void TestProtectedSets()
        {
            PropDefFake propDef = new PropDefFake();

            Assert.AreEqual("prop", propDef.PropertyName);
            propDef.SetPropertyName("myprop");
            Assert.AreEqual("myprop", propDef.PropertyName);

            Assert.AreEqual(typeof (MyBO), propDef.PropertyType);
            propDef.SetPropertyType(typeof (MyRelatedBo));
            Assert.AreEqual(typeof (MyRelatedBo), propDef.PropertyType);

            Assert.AreEqual("Habanero.Test.MyRelatedBo", propDef.PropertyTypeName);
            propDef.SetPropertyTypeName("myproptype");
            Assert.AreEqual("myproptype", propDef.PropertyTypeName);

            Assert.AreEqual("Habanero.Test", propDef.PropertyTypeAssemblyName);
            propDef.SetPropertyTypeAssemblyName("myassembly");
            Assert.AreEqual("myassembly", propDef.PropertyTypeAssemblyName);
            Assert.IsNull(propDef.PropertyTypeName);
            Assert.IsNull(propDef.PropertyType);

            Assert.AreEqual("prop", propDef.DatabaseFieldName);
            propDef.SetDatabaseFieldName("propfield");
            Assert.AreEqual("propfield", propDef.DatabaseFieldName);

            Assert.IsNull(propDef.DefaultValue);
            propDef.SetPropertyType(typeof (String));
            propDef.SetDefaultValue("default");
            Assert.AreEqual("default", propDef.DefaultValue);

            Assert.AreEqual("default", propDef.DefaultValueString);
            propDef.SetDefaultValueString("none");
            Assert.AreEqual("none", propDef.DefaultValueString);

            Assert.IsFalse(propDef.Compulsory);
            propDef.SetCompulsory(true);
            Assert.IsTrue(propDef.Compulsory);

            Assert.AreEqual(PropReadWriteRule.ReadWrite, propDef.ReadWriteRule);
            propDef.SetReadWriteRule(PropReadWriteRule.ReadOnly);
            Assert.AreEqual(PropReadWriteRule.ReadOnly, propDef.ReadWriteRule);

            Assert.IsTrue(propDef.IsPropValueValid("somestring"));

            Assert.AreEqual(typeof (String), propDef.PropertyType);
            propDef.SetPropType(typeof (DateTime));
            Assert.AreEqual(typeof(DateTime), propDef.PropertyType);

            PropDefParameterSQLInfo propDefParameterSQLInfo = new PropDefParameterSQLInfo(propDef);
            Assert.AreEqual(ParameterType.Date, propDefParameterSQLInfo.ParameterType);
        }
Ejemplo n.º 3
0
 public void Test_ClassNameViaInterface_WhenNotHasClassDef_ShouldReturnEmptyString()
 {
     //---------------Set up test pack-------------------
     IPropDef propDef = new PropDefFake();
     //---------------Assert Precondition----------------
     Assert.IsNull(propDef.ClassDef);
     //---------------Execute Test ----------------------
     string className = propDef.ClassName;
     //---------------Test Result -----------------------
     Assert.IsEmpty(className);
 }
Ejemplo n.º 4
0
 public void Test_ClassName_WhenHasClassDef_ShouldReturnClassDef_ClassName()
 {
     //---------------Set up test pack-------------------
     PropDef propDef = new PropDefFake {ClassDef = new FakeClassDef{ClassName = GetRandomString()}};
     //---------------Assert Precondition----------------
     Assert.IsNotNull(propDef.ClassDef);
     //---------------Execute Test ----------------------
     string className = propDef.ClassName;
     //---------------Test Result -----------------------
     Assert.AreEqual(propDef.ClassDef.ClassName, className);
 }
 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);
        }
Ejemplo n.º 7
0
        public void Test_CallGetPropDef_RemovePropDefToPropDefCol_ThenGetPropDef_ShouldNotHaveRemovedPropDef_FixBug583()
        {
            //---------------Set up test pack-------------------
            FakeClassDef classDef = new FakeClassDef();
            classDef.SetPropDefCol(new PropDefCol());
            const string propertyName = "SomePropName";           
            var removedPropDef = new PropDefFake(propertyName);
            classDef.PropDefcol.Add(removedPropDef);

            var initialPropDef = classDef.GetPropDef(propertyName, false);
            //---------------Assert Precondition----------------
            Assert.IsNotNull(initialPropDef);
            //---------------Execute Test ----------------------
            classDef.PropDefcol.Remove(removedPropDef);
            var returnedPropDef = classDef.GetPropDef(propertyName, false);
            //---------------Test Result -----------------------
            Assert.IsNull(returnedPropDef);
        }