public RelationalDatabaseModelFactoryTest()
        {
            var factory = new TestLoggerFactory();
            _logger = factory.Logger;

            _factory = new FakeScaffoldingModelFactory(factory);
        }
        public RelationalDatabaseModelFactoryTest()
        {
            var factory = new TestLoggerFactory();

            _logger = factory.Logger;

            _factory = new FakeScaffoldingModelFactory(factory);
        }
Example #3
0
        public void Pluralization_of_collection_navigations()
        {
            var blogTable = new TableModel {
                Name = "Blog", Columns = { IdColumn }
            };
            var postTable = new TableModel
            {
                Name    = "Post",
                Columns =
                {
                    IdColumn,
                    new ColumnModel {
                        Name = "BlogId",DataType             = "long", IsNullable = true
                    }
                }
            };

            postTable.ForeignKeys.Add(new ForeignKeyModel
            {
                Table          = postTable,
                PrincipalTable = blogTable,
                OnDelete       = ReferentialAction.Cascade,
                Columns        =
                {
                    new ForeignKeyColumnModel
                    {
                        Ordinal         = 1,
                        Column          = postTable.Columns.ElementAt(1),
                        PrincipalColumn = blogTable.Columns.ElementAt(0)
                    }
                }
            });

            var info = new DatabaseModel
            {
                Tables = { blogTable, postTable }
            };

            var factory = new FakeScaffoldingModelFactory(new TestLogger <LoggerCategory.Scaffolding>(), new FakePluralizer());
            var model   = factory.Create(info);

            Assert.Collection(model.GetEntityTypes().OrderBy(t => t.Name).Cast <EntityType>(),
                              entity =>
            {
                Assert.Equal("Blog", entity.Name);
                Assert.Equal("Posts", entity.GetNavigations().Single().Name);
            },
                              entity =>
            {
                Assert.Equal("Post", entity.Name);
                Assert.Equal("Blog", entity.GetNavigations().Single().Name);
            }
                              );
        }
Example #4
0
        public void Pluralization_of_entity_and_DbSet()
        {
            var info = new DatabaseModel
            {
                Tables =
                {
                    new TableModel
                    {
                        Name    = "Blog",
                        Columns ={ IdColumn               }
                    },
                    new TableModel
                    {
                        Name    = "Posts",
                        Columns ={ IdColumn               }
                    }
                }
            };

            var factory = new FakeScaffoldingModelFactory(new TestLogger <LoggerCategory.Scaffolding>(), new FakePluralizer());
            var model   = factory.Create(info);

            Assert.Collection(model.GetEntityTypes().OrderBy(t => t.Name).Cast <EntityType>(),
                              entity =>
            {
                Assert.Equal("Blog", entity.Relational().TableName);
                Assert.Equal("Blog", entity.Name);
                Assert.Equal("Blogs", entity.Scaffolding().DbSetName);
            },
                              entity =>
            {
                Assert.Equal("Posts", entity.Relational().TableName);
                Assert.Equal("Post", entity.Name);
                Assert.Equal("Posts", entity.Scaffolding().DbSetName);
            }
                              );
        }
Example #5
0
        public RelationalDatabaseModelFactoryTest()
        {
            _logger = new TestLogger <LoggerCategory.Scaffolding>();

            _factory = new FakeScaffoldingModelFactory(_logger);
        }