public void ItShouldNotApplyMigrationsSinceLastVersionWhenVersionBiggerThanMigration() { var database = new DatabaseStub(3); var logger = new LoggerStub(); var schema = new Schema(database, logger); var migrator = new Migrator(schema, typeof(FirstMigration).Assembly, logger); migrator.MigrateToLatest(); Assert.That(database.Statements.Any(x => x.Contains("FirstMigration")), Is.False); }
public void ItShouldFindFirstMigrationInAssembly() { var database = new DatabaseStub(); var logger = new LoggerStub(); var schema = new Schema(database, logger); var migrator = new Migrator(schema, typeof(FirstMigration).Assembly, logger); migrator.MigrateToLatest(); Assert.That(logger.Logs.Any(x => x.Contains(@"Found 1 Migrations"))); }
public void ItShouldInformIfNoMigrationsFoundInAssembly() { var database = new DatabaseStub(); var logger = new LoggerStub(); var schema = new Schema(database, logger); var migrator = new Migrator(schema, typeof (Schema).Assembly, logger); migrator.MigrateToLatest(); Assert.That(logger.Logs.Any(x=>x.Contains(@"No Migrations Found"))); }
public void ItShouldApplyMigrationsSinceLastVersionAndUpdateSchemaTable() { var database = new DatabaseStub(); var logger = new LoggerStub(); var schema = new Schema(database, logger); var migrator = new Migrator(schema, typeof(FirstMigration).Assembly, logger); migrator.MigrateToLatest(); Assert.That(database.Statements.Any(x => x.Contains("FirstMigration"))); }
public void ItShouldNotUpdateSchemaVersionTo1IfMigrationNotApplicable() { var database = new DatabaseStub(3); var logger = new LoggerStub(); var schema = new Schema(database, logger); var migrator = new Migrator(schema, typeof(FirstMigration).Assembly, logger); migrator.MigrateToLatest(); Assert.That(database.Statements.Any(x => x.Contains(@"INSERT INTO [dbo].[SchemaInfo] ([Version]) VALUES (1)")), Is.False); }