Example #1
0
        public void TestFillModelRelations()
        {
            MSSQLProvider p = new MSSQLProvider(GetTestDB(), null);

            SourceView sv = p.GetSourceView(null, "aspnet_Applications,aspnet_Paths");

            WXMLModel model = new WXMLModel();

            SourceToModelConnector c = new SourceToModelConnector(sv, model);

            c.ApplySourceViewToModel();

            Assert.AreEqual(2, model.GetSourceFragments().Count());

            Assert.AreEqual(2, model.GetEntities().Count());

            var aspnet_Applications = model.GetEntity("e_dbo_aspnet_Applications");

            Assert.IsNotNull(aspnet_Applications);

            var aspnet_Paths = model.GetEntity("e_dbo_aspnet_Paths");

            Assert.IsNotNull(aspnet_Paths);

            Assert.IsNotNull(aspnet_Paths.GetProperty("Application"));
            Assert.IsNotNull(aspnet_Paths.GetProperty("PathId"));
            Assert.IsNotNull(aspnet_Paths.GetProperty("Path"));
            Assert.IsNotNull(aspnet_Paths.GetProperty("LoweredPath"));

            Assert.AreEqual(1, aspnet_Applications.One2ManyRelations.Count());

            Assert.AreEqual(aspnet_Paths, aspnet_Applications.One2ManyRelations.First().Entity);
        }
Example #2
0
        public void TestFillModel()
        {
            MSSQLProvider p = new MSSQLProvider(GetTestDB(), null);

            SourceView sv = p.GetSourceView(null, "ent1,ent2,1to2");

            WXMLModel model = new WXMLModel();

            SourceToModelConnector c = new SourceToModelConnector(sv, model);

            c.ApplySourceViewToModel();

            Assert.AreEqual(3, model.GetSourceFragments().Count());

            Assert.AreEqual(2, model.GetEntities().Count());

            Assert.IsNotNull(model.GetEntity("e_dbo_ent1"));

            Assert.IsNotNull(model.GetEntity("e_dbo_ent2"));

            Assert.AreEqual(1, model.GetEntity("e_dbo_ent1").GetProperties().Count());

            Assert.AreEqual(1, model.GetEntity("e_dbo_ent1").GetPkProperties().Count());

            Assert.IsTrue(model.GetEntity("e_dbo_ent1").GetPkProperties().First().HasAttribute(Field2DbRelations.PrimaryKey));

            Assert.AreEqual(2, model.GetEntity("e_dbo_ent2").GetProperties().Count());

            Assert.AreEqual(1, model.GetRelations().Count());
        }
Example #3
0
        public void TestDropEntityProperty()
        {
            MSSQLProvider p = new MSSQLProvider(GetTestDB(), null);

            SourceView sv = p.GetSourceView(null, "aspnet_Paths, aspnet_Applications");

            Assert.AreEqual(8, sv.SourceFields.Count);

            WXMLModel model = new WXMLModel();

            SourceToModelConnector c = new SourceToModelConnector(sv, model);

            c.ApplySourceViewToModel();

            Assert.AreEqual(4, model.GetEntity("e_dbo_aspnet_Paths").GetActiveProperties().Count());

            Assert.IsTrue(sv.SourceFields.Remove(sv.SourceFields.Find(item => item.SourceFieldExpression == "[ApplicationId]" && item.SourceFragment.Name == "[aspnet_Paths]")));

            Assert.AreEqual(7, sv.SourceFields.Count);

            c.ApplySourceViewToModel(true, relation1to1.Default, true, true, false);

            Assert.AreEqual(3, model.GetEntity("e_dbo_aspnet_Paths").GetActiveProperties().Count());
        }
Example #4
0
        public void TestFillHierarchy()
        {
            MSSQLProvider p = new MSSQLProvider(GetTestDB(), null);

            SourceView sv = p.GetSourceView(null, "aspnet_Membership, aspnet_Users");

            WXMLModel model = new WXMLModel();

            SourceToModelConnector c = new SourceToModelConnector(sv, model);

            c.ApplySourceViewToModel();

            Assert.AreEqual(2, model.GetSourceFragments().Count());

            Assert.AreEqual(2, model.GetEntities().Count());

            EntityDefinition membership = model.GetEntity("e_dbo_aspnet_Membership");

            Assert.IsNotNull(membership);

            EntityDefinition users = model.GetEntity("e_dbo_aspnet_Users");

            Assert.IsNotNull(users);

            Assert.AreEqual(membership.BaseEntity, users);

            Assert.AreEqual(2, membership.GetSourceFragments().Count());

            Assert.AreEqual(1, membership.OwnSourceFragments.Count());

            Assert.AreEqual(1, users.GetSourceFragments().Count());

            Assert.AreEqual(1, users.OwnSourceFragments.Count());

            Assert.IsNull(users.BaseEntity);
        }
Example #5
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);
        }