Пример #1
0
        public void TestWithUnknownRelatedType()
        {
            //---------------Set up test pack-------------------
            DefClassFactory       defClassFactory = new DefClassFactory();
            XmlRelationshipLoader loader          = new XmlRelationshipLoader(new DtdLoader(), defClassFactory, "TestClass");
            IPropDefCol           propDefs        = defClassFactory.CreatePropDefCol();

            propDefs.Add(defClassFactory.CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false));

            RelationshipDef relDef =
                (RelationshipDef)loader.LoadRelationship(
                    @"<relationship 
						name=""TestRelationship"" 
						type=""single"" 
						relatedClass=""Habanero.Test.BO.Loaders.NonExistantTestRelatedClass"" 
						relatedAssembly=""Habanero.Test.BO"" 
                    >
						    <relatedProperty property=""TestProp"" relatedProperty=""TestRelatedProp"" />

					</relationship>"                    ,
                    propDefs);

            //---------------Execute Test ----------------------
            try
            {
                Type classType = relDef.RelatedObjectClassType;

                Assert.Fail("Expected to throw an UnknownTypeNameException");
            }
            //---------------Test Result -----------------------
            catch (UnknownTypeNameException ex)
            {
                StringAssert.Contains("Unable to load the related object type while attempting to load a relationship definition", ex.Message);
            }
        }
Пример #2
0
        public void Test_CreatUIFormProperty()
        {
            //---------------Set up test pack-------------------
            IDefClassFactory defClassFactory = new DefClassFactory();
            var label = TestUtil.GetRandomString();

            var               propertyName     = TestUtil.GetRandomString();
            var               controlTypeName  = TestUtil.GetRandomString();
            var               controlAssembly  = TestUtil.GetRandomString();
            var               mapperTypeName   = TestUtil.GetRandomString();
            var               mapperAssembly   = TestUtil.GetRandomString();
            var               editable         = TestUtil.GetRandomBoolean();
            const bool        showAsCompulsory = true;
            var               toolTipText      = TestUtil.GetRandomString();
            const LayoutStyle layoutStyle      = LayoutStyle.Label;
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var uiFormField = defClassFactory.CreateUIFormProperty(label, propertyName
                                                                   , controlTypeName, controlAssembly, mapperTypeName,
                                                                   mapperAssembly, editable, showAsCompulsory,
                                                                   toolTipText, null, layoutStyle);

            //---------------Test Result -----------------------
            Assert.AreEqual(label, uiFormField.Label);
            Assert.AreEqual(propertyName, uiFormField.PropertyName);
            Assert.AreEqual(controlTypeName, uiFormField.ControlTypeName);
            Assert.AreEqual(controlAssembly, uiFormField.ControlAssemblyName);
            Assert.AreEqual(mapperTypeName, uiFormField.MapperTypeName);
            Assert.AreEqual(editable, uiFormField.Editable);
            Assert.AreEqual(showAsCompulsory, uiFormField.IsCompulsory);
            Assert.AreEqual(toolTipText, uiFormField.ToolTipText);
            Assert.AreEqual(layoutStyle, uiFormField.Layout);
        }
Пример #3
0
        public void Test_Construct_ConstructedCorrectly()
        {
            //---------------Set up test pack-------------------

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

            //---------------Execute Test ----------------------
            IDefClassFactory defClassFactory = new DefClassFactory();

            //---------------Test Result -----------------------
            Assert.IsNotNull(defClassFactory);
        }
Пример #4
0
        public void Test_CreatePropRule_WhenTypeIsInt64_ShouldConstruct()
        {
            //---------------Set up test pack-------------------
            IDefClassFactory defFactory = new DefClassFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var createdPropRule = defFactory.CreatePropRuleLong("fdasfd", "fdsafasd");

            //---------------Test Result -----------------------
            Assert.IsNotNull(createdPropRule);
            Assert.IsInstanceOf <PropRuleLong>(createdPropRule);
        }
Пример #5
0
        public void Test_CreatePropRuleDouble()
        {
            //---------------Set up test pack-------------------
            IDefClassFactory defClassFactory = new DefClassFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            var rule = (PropRuleDouble)defClassFactory.CreatePropRuleDouble("SomeName", "SomeMessage");

            //---------------Test Result -----------------------
            Assert.AreEqual("SomeName", rule.Name);
            Assert.AreEqual("SomeMessage", rule.Message);
            Assert.AreEqual(Double.MinValue, rule.MinValue);
            Assert.AreEqual(Double.MaxValue, rule.MaxValue);
        }
Пример #6
0
        public void CreatePropRuleInt16_ShouldConstruct()
        {
            //---------------Set up test pack-------------------
            IDefClassFactory defFactory = new DefClassFactory();
            //---------------Assert Precondition----------------

            //---------------Execute Test ----------------------
            const string expectedRuleName = "MyRule";
            var          createdPropRule  = defFactory.CreatePropRuleShort(expectedRuleName, "fdafasdf");

            //---------------Test Result -----------------------
            Assert.IsNotNull(createdPropRule);
            Assert.IsInstanceOf <PropRuleShort>(createdPropRule);
            Assert.AreEqual(expectedRuleName, createdPropRule.Name);
        }
Пример #7
0
        public void Test_LoadInheritedRelationship_UsingInheritedRelatedProps()
        {
            DefClassFactory       defClassFactory = new DefClassFactory();
            XmlRelationshipLoader loader          = new XmlRelationshipLoader(new DtdLoader(), defClassFactory, "TestClass");
            IPropDefCol           propDefs        = defClassFactory.CreatePropDefCol();

            propDefs.Add(defClassFactory.CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false));

            RelationshipDef relDef =
                (RelationshipDef)loader.LoadRelationship(
                    @"<relationship 
						name=""TestRelationship"" 
						type=""single"" 
						relatedClass=""Habanero.Test.BO.Loaders.NonExistantTestRelatedClass"" 
						relatedAssembly=""Habanero.Test.BO"" 
                    >
						    <relatedProperty property=""TestProp"" relatedProperty=""TestRelatedProp"" />

					</relationship>"                    ,
                    propDefs);
            Type classType = relDef.RelatedObjectClassType;
        }