Example #1
0
        public void TestFillPropertiesWithGroups()
        {
            Worm_CodeGen_Core_OrmXmlParserAccessor parser;

            using (XmlReader rdr = XmlReader.Create(GetFile("groups")))
            {
                object privateParser = Worm_CodeGen_Core_OrmXmlParserAccessor.CreatePrivate(rdr, new TestXmlUrlResolver());
                parser = new Worm_CodeGen_Core_OrmXmlParserAccessor(privateParser);
                parser.Read();
            }

            parser.FillSourceFragments();
            parser.FindEntities();
            parser.FillImports();
            parser.FillTypes();

            WXMLModel model = parser.Model;

            EntityDefinition entity = model.GetEntities()
                                      .Single(match => match.Identifier == "e1");

            parser.FillProperties(entity);

            Assert.AreEqual <int>(7, entity.OwnProperties.Count());

            PropertyDefinition prop = entity.GetProperty("Identifier1");

            Assert.IsNull(prop);
            prop = entity.GetProperty("ID");
            Assert.IsNotNull(prop);

            Assert.IsNull(prop.Group);

            prop = entity.GetProperty("prop1");
            Assert.IsNotNull(prop);
            Assert.IsNotNull(prop.Group);
            Assert.AreEqual("grp", prop.Group.Name);
            Assert.IsTrue(prop.Group.Hide);

            prop = entity.GetProperty("prop4");
            Assert.IsNotNull(prop);
            Assert.IsNotNull(prop.Group);
            Assert.AreEqual("grp1", prop.Group.Name);
            Assert.IsFalse(prop.Group.Hide);
        }
Example #2
0
        public void TestFillSuppressedProperties()
        {
            Worm_CodeGen_Core_OrmXmlParserAccessor parser = null;

            using (XmlReader rdr = XmlReader.Create(Resources.GetXmlDocumentStream("suppressed")))
            {
                object privateParser = Worm_CodeGen_Core_OrmXmlParserAccessor.CreatePrivate(rdr);
                parser = new Worm_CodeGen_Core_OrmXmlParserAccessor(privateParser);
                parser.Read();
            }

            parser.FillSourceFragments();
            parser.FindEntities();
            parser.FillImports();
            parser.FillTypes();

            WXMLModel ormObjectDef = parser.Model;

            EntityDefinition entity = ormObjectDef.GetEntity("e11");

            parser.FillEntities();

            Assert.AreEqual <int>(1, entity.SuppressedProperties.Count, "SuppressedProperties.Count");

            PropertyDefinition prop = entity.GetProperties()
                                      .Single(item => item.PropertyAlias == entity.SuppressedProperties[0]);

            Assert.AreEqual <string>("Prop1", prop.Name, "SuppressedPropertyName");
            Assert.IsTrue(prop.IsSuppressed, "SuppressedPropery.IsSuppressed");

            EntityDefinition completeEntity = entity;//.CompleteEntity;

            prop = completeEntity.GetProperty("Prop1");
            Assert.IsNotNull(prop);
            Assert.IsTrue(prop.IsSuppressed);

            prop = completeEntity.GetProperty("Prop11");
            Assert.IsNotNull(prop);
            Assert.IsFalse(prop.IsSuppressed);
        }
Example #3
0
        public void TestFillProperties()
        {
            Worm_CodeGen_Core_OrmXmlParserAccessor parser;

            using (XmlReader rdr = XmlReader.Create(GetSampleFileStream()))
            {
                object privateParser = Worm_CodeGen_Core_OrmXmlParserAccessor.CreatePrivate(rdr);
                parser = new Worm_CodeGen_Core_OrmXmlParserAccessor(privateParser);
                parser.Read();
            }

            parser.FillSourceFragments();
            parser.FindEntities();
            parser.FillImports();
            parser.FillTypes();


            WXMLModel ormObjectDef = parser.Model;

            EntityDefinition entity = ormObjectDef.GetEntities()
                                      .Single(match => match.Identifier == "eArtist" && match.Name == "Artist");

            parser.FillProperties(entity);

            Assert.AreEqual <int>(8, entity.OwnProperties.Count());

            ScalarPropertyDefinition prop = (ScalarPropertyDefinition)entity.GetProperty("ID");

            Assert.IsNotNull(prop);
            //Assert.AreEqual<int>(1, prop.Attributes.Length, "Attributes is undefined");
            Assert.AreEqual <string>("PK", prop.Attributes.ToString(), "Attributes is not correct defined");
            Assert.IsNotNull(prop.SourceFragment, "Table is undefined");
            Assert.AreEqual <string>("tblArtists", prop.SourceFragment.Identifier, "Table.Identifier is undefined");
            Assert.AreEqual <string>("id", prop.SourceFieldExpression, "FieldName is undefined");
            Assert.AreEqual <string>("System.Int32", prop.PropertyType.GetTypeName(null), "PropertyTypeString is undefined");
            Assert.AreEqual <string>("Property ID Description", prop.Description, "Description is undefined");
            Assert.AreEqual <AccessLevel>(AccessLevel.Private, prop.FieldAccessLevel, "FieldAccessLevel");
            Assert.AreEqual <AccessLevel>(AccessLevel.Public, prop.PropertyAccessLevel, "PropertyAccessLevel");
            Assert.AreEqual <string>(prop.Name, prop.PropertyAlias, "PropertyAlias");

            prop = (ScalarPropertyDefinition)entity.GetProperty("Title");
            Assert.IsNotNull(prop);
            //Assert.AreEqual<int>(0, prop.Attributes.Length, "Attributes is undefined");
            Assert.IsNotNull(prop.SourceFragment, "Table is undefined");
            Assert.AreEqual <string>("tblArtists", prop.SourceFragment.Identifier, "Table.Identifier is undefined");
            Assert.AreEqual <string>("name", prop.SourceFieldExpression, "FieldName is undefined");
            Assert.AreEqual <string>("System.String", prop.PropertyType.GetTypeName(null), "PropertyTypeString is undefined");
            Assert.AreEqual <string>("Property Title Description", prop.Description, "Description");
            Assert.AreEqual <AccessLevel>(AccessLevel.Private, prop.FieldAccessLevel, "FieldAccessLevel");
            Assert.AreEqual <AccessLevel>(AccessLevel.Assembly, prop.PropertyAccessLevel, "PropertyAccessLevel");
            Assert.AreEqual <string>(prop.Name, prop.PropertyAlias, "PropertyAlias");

            prop = (ScalarPropertyDefinition)entity.GetProperty("DisplayTitle");
            Assert.IsNull(prop);
            prop = (ScalarPropertyDefinition)entity.GetProperty("DisplayName");
            Assert.IsNotNull(prop);
            Assert.AreEqual <string>("DisplayTitle", prop.Name, "Name is undefined");
            //Assert.AreEqual<int>(0, prop.Attributes.Length, "Attributes is undefined");
            Assert.IsNotNull(prop.SourceFragment, "Table is undefined");
            Assert.AreEqual <string>("tblArtists", prop.SourceFragment.Identifier, "Table.Identifier is undefined");
            Assert.AreEqual <string>("display_name", prop.SourceFieldExpression, "FieldName is undefined");
            Assert.AreEqual <string>("System.String", prop.PropertyType.GetTypeName(null), "PropertyTypeString is undefined");
            Assert.AreEqual <string>("Property Title Description", prop.Description, "Property Title Description");
            Assert.AreEqual <AccessLevel>(AccessLevel.Family, prop.FieldAccessLevel, "FieldAccessLevel");
            Assert.AreEqual <AccessLevel>(AccessLevel.Family, prop.PropertyAccessLevel, "PropertyAccessLevel");
            Assert.AreEqual <string>("DisplayName", prop.PropertyAlias, "PropertyAlias");

            prop = (ScalarPropertyDefinition)entity.GetProperty("Fact");

            //Assert.AreEqual<int>(1, prop.Attributes.Length, "Attributes.Factory absent");
            Assert.AreEqual <string>("Factory", prop.Attributes.ToString(), "Attributes.Factory invalid");

            prop = (ScalarPropertyDefinition)entity.GetProperty("TestInsDef");

            //Assert.AreEqual<int>(1, prop.Attributes.Length, "Attributes.Factory absent");
            Assert.AreEqual <string>("InsertDefault", prop.Attributes.ToString(), "Attributes.InsertDefault invalid");

            prop = (ScalarPropertyDefinition)entity.GetProperty("TestNullabe");

            Assert.AreEqual <Type>(typeof(int?), prop.PropertyType.ClrType);
            Assert.IsFalse(prop.Disabled, "Disabled false");

            prop = (ScalarPropertyDefinition)entity.GetProperty("TestDisabled");
            Assert.IsTrue(prop.Disabled, "Disabled true");
        }