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);
            }
        }
Beispiel #2
0
        public void TestRelationshipType_Invalid()
        {
            //---------------Set up test pack-------------------
            string className             = TestUtil.GetRandomString();
            XmlRelationshipLoader loader = new XmlRelationshipLoader(new DtdLoader(), GetDefClassFactory(), className);
            const string          singleRelationshipStringComposition = @"
					<relationship 
						name=""TestRelationship"" 
						type=""single"" 
                        relationshipType=""Bob""
                        relatedClass=""Habanero.Test.BO.Loaders.TestRelatedClass"" 
						relatedAssembly=""Habanero.Test.BO""
                    >
						    <relatedProperty property=""TestProp"" relatedProperty=""TestRelatedProp"" />
					</relationship>"                    ;

            //---------------Execute Test ----------------------
            try
            {
                loader.LoadRelationship(singleRelationshipStringComposition, _propDefs);
                Assert.Fail("An error should have been raised as there is no relationship type of Bob");
                //---------------Test Result -----------------------
            } catch (InvalidXmlDefinitionException ex)
            {
                StringAssert.Contains(string.Format("'TestRelationship' on class '{0}'", className), ex.Message);
                StringAssert.Contains("invalid value ('Bob')", ex.Message);
            }
        }
        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;
        }
Beispiel #4
0
 protected void Initialise()
 {
     _loader   = new XmlRelationshipLoader(new DtdLoader(), GetDefClassFactory(), "TestClass");
     _propDefs = GetDefClassFactory().CreatePropDefCol();
     _propDefs.Add(GetDefClassFactory().CreatePropDef("TestProp", "System", "String", PropReadWriteRule.ReadWrite, null, null, false, false, 255, null, null, false));
 }