public void Visit_with_create_table_operation() { var model = new DatabaseModel(); var column0 = new Column("Id", typeof(string)); var column1 = new Column("Id", typeof(string)); var column2 = new Column("C", typeof(int)); var dependent = new Table("T1", new[] { column1, column2 }); dependent.PrimaryKey = new PrimaryKey("PK", new[] { column1 }, isClustered: false); dependent.AddForeignKey(new ForeignKey("FK", new[] { column1 }, new[] { column0 })); dependent.AddIndex(new Index("IX", new[] { column2 })); var operation = new CreateTableOperation(dependent); Assert.Equal(0, model.Tables.Count); operation.Accept(new DatabaseModelModifier(), model); Assert.Equal(1, model.Tables.Count); Assert.NotSame(dependent, model.Tables[0]); Assert.Equal("T1", model.Tables[0].Name); Assert.Equal(new[] { "Id", "C" }, model.Tables[0].Columns.Select(c => c.Name)); Assert.Equal(typeof(string), model.Tables[0].Columns[0].ClrType); Assert.Equal(typeof(int), model.Tables[0].Columns[1].ClrType); Assert.NotSame(dependent.PrimaryKey, model.Tables[0].PrimaryKey); Assert.Equal("PK", model.Tables[0].PrimaryKey.Name); Assert.Equal(new[] { "Id" }, model.Tables[0].PrimaryKey.Columns.Select(c => c.Name)); Assert.False(model.Tables[0].PrimaryKey.IsClustered); Assert.Equal(0, model.Tables[0].ForeignKeys.Count); Assert.Equal(0, model.Tables[0].Indexes.Count); }
public void Visit_with_create_table_operation() { var model = new DatabaseModel(); var table = new Table("dbo.MyTable"); var operation = new CreateTableOperation(table); Assert.Equal(0, model.Tables.Count); operation.Accept(new DatabaseModelModifier(), model); Assert.Equal(1, model.Tables.Count); Assert.Same(table, model.Tables[0]); }