public void Dispatches_visitor() { var operation = new RenameSequenceOperation("dbo.MySequence", "RenamedSequence"); var sqlGeneratorMock = MigrationsTestHelpers.MockSqlGenerator(); var sqlBuilder = new SqlBatchBuilder(); operation.GenerateSql(sqlGeneratorMock.Object, sqlBuilder); sqlGeneratorMock.Verify(g => g.Generate(operation, sqlBuilder), Times.Once()); var codeGeneratorMock = new Mock <MigrationCodeGenerator>(new Mock <ModelCodeGenerator>().Object); var codeBuilder = new IndentedStringBuilder(); operation.GenerateCode(codeGeneratorMock.Object, codeBuilder); codeGeneratorMock.Verify(g => g.Generate(operation, codeBuilder), Times.Once()); var visitorMock = new Mock <MigrationOperationVisitor <object> >(); var context = new object(); operation.Accept(visitorMock.Object, context); visitorMock.Verify(v => v.Visit(operation, context), Times.Once()); }
public void Dispatches_visitor() { var operation = new AddUniqueConstraintOperation("dbo.MyTable", "MyUC", new[] { "Foo", "Bar" }); var sqlGeneratorMock = MigrationsTestHelpers.MockSqlGenerator(); var sqlBuilder = new SqlBatchBuilder(); operation.GenerateSql(sqlGeneratorMock.Object, sqlBuilder); sqlGeneratorMock.Verify(g => g.Generate(operation, sqlBuilder), Times.Once()); var codeGeneratorMock = new Mock <MigrationCodeGenerator>(new Mock <ModelCodeGenerator>().Object); var codeBuilder = new IndentedStringBuilder(); operation.GenerateCode(codeGeneratorMock.Object, codeBuilder); codeGeneratorMock.Verify(g => g.Generate(operation, codeBuilder), Times.Once()); var visitorMock = new Mock <MigrationOperationVisitor <object> >(); var context = new object(); operation.Accept(visitorMock.Object, context); visitorMock.Verify(v => v.Visit(operation, context), Times.Once()); }
private static MigrationOperationSqlGenerator SqlGenerator(IModel targetModel = null) { var sqlGenerator = MigrationsTestHelpers.MockSqlGenerator(callBase: true).Object; sqlGenerator.TargetModel = targetModel ?? new Entity.Metadata.Model(); return(sqlGenerator); }
public void Dispatches_visitor() { var renameIndexOperation = new RenameIndexOperation("dbo.MyTable", "MyIndex", "MyIndex2"); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); renameIndexOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(renameIndexOperation, builder.Object), Times.Once()); }
public void Dispatches_visitor() { var sqlOperation = new SqlOperation("MySql"); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); sqlOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(sqlOperation, builder.Object), Times.Once()); }
public void Dispatches_visitor() { var createSequenceOperation = new CreateSequenceOperation("dbo.MySequence"); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); createSequenceOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(createSequenceOperation, builder.Object), Times.Once()); }
public void Dispatches_visitor() { var addColumnOperation = new AddColumnOperation("dbo.MyTable", new Column("Foo", typeof(int))); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); addColumnOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(addColumnOperation, builder.Object), Times.Once()); }
public void Dispatches_visitor() { var dropDefaultConstraintOperation = new DropDefaultConstraintOperation("dbo.MyTable", "Foo"); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); dropDefaultConstraintOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(dropDefaultConstraintOperation, builder.Object), Times.Once()); }
public void Dispatches_visitor() { var addPrimaryKeyOperation = new AddPrimaryKeyOperation( "dbo.MyTable", "MyPK", new[] { "Foo", "Bar" }, isClustered: true); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); addPrimaryKeyOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(addPrimaryKeyOperation, builder.Object), Times.Once()); }
public void Dispatches_visitor() { var createIndexOperation = new CreateIndexOperation( "dbo.MyTable", "MyIndex", new[] { "Foo", "Bar" }, isUnique: true, isClustered: true); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); createIndexOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(createIndexOperation, builder.Object), Times.Once()); }
public void Dispatches_visitor() { var addForeignKeyOperation = new AddForeignKeyOperation( "dbo.MyTable", "MyFK", new[] { "Foo", "Bar" }, "dbo.MyTable2", new[] { "Foo2", "Bar2" }, cascadeDelete: true); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); addForeignKeyOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(addForeignKeyOperation, builder.Object), Times.Once()); }
public void Dispatches_visitor() { var newColumn = new Column("Foo", typeof(int)) { IsNullable = true }; var alterColumnOperation = new AlterColumnOperation( "dbo.MyTable", newColumn, isDestructiveChange: true); var mockVisitor = MigrationsTestHelpers.MockSqlGenerator(); var builder = new Mock <SqlBatchBuilder>(); alterColumnOperation.GenerateSql(mockVisitor.Object, builder.Object); mockVisitor.Verify(g => g.Generate(alterColumnOperation, builder.Object), Times.Once()); }