public void run_multiple_tasks() { var m = new Migration1(_sb); _runner.Run(m, new Migration2(_sb)); Assert.Equal("12", _sb.ToString()); }
public void run_task() { var m = new Migration1(_sb); _runner.Run(m); Assert.Equal("1", _sb.ToString()); }
public void versioning_attribute() { var d = new Migration1(new StringBuilder()); Assert.Equal("1.0.0", d.CurrentVersion); Assert.Equal("1.0.1", d.NextVersion); }
public void SetUp() { Migration1.Reset(); Migration2.Reset(); this.connection = new Mock <DbConnection>() { DefaultValue = DefaultValue.Mock, }; this.migrationProvider = new Mock <IMigrationProvider>(); this.databaseProvider = new Mock <MockDatabaseProvider>() { CallBase = true, }; this.databaseProvider.Object.Connection = this.connection.Object; this.logger = new Mock <ILogger>(); this.migrator = new SimpleMigrator <DbConnection, Migration>(this.migrationProvider.Object, this.databaseProvider.Object, this.logger.Object); this.migrations = new List <MigrationData>() { new MigrationData(1, "Migration 1", typeof(Migration1).GetTypeInfo()), new MigrationData(2, "Migration 2", typeof(Migration2).GetTypeInfo()), }; this.migrationProvider.Setup(x => x.LoadMigrations()).Returns(this.migrations); }
public void Init() { _dataClientMock = new Mock<IDataClient>(); _databaseMock = new Mock<IDatabase>(); _dataClientMock.SetupGet(d => d.Database).Returns(_databaseMock.Object); _migration1 = new Migration1(); _migration1.SetDataClient(_dataClientMock.Object); }
public MigrationTests() { _dataClientMock = new Mock <IDataClient>(); _databaseMock = new Mock <IDatabase>(); _dataClientMock.SetupGet(d => d.Database).Returns(_databaseMock.Object); _migration1 = new Migration1(); _migration1.SetDataClient(_dataClientMock.Object); }
public void TestMigrationSort() { IMigration migration1 = new Migration1(); IMigration migration2 = new Migration2(); List<IMigration> migrations = new List<IMigration>{ migration2, migration1 }; migrations.Sort(MigrationService.MigrationSorter); Assert.AreSame(migrations[0], migration1); migrations = new List<IMigration>{ migration1, migration2 }; migrations.Sort(MigrationService.MigrationSorter); Assert.AreSame(migrations[0], migration1); }
public void TestRunDownMigrationsToBogusVersion() { IMigration migration1 = new Migration1(); IMigration migration2 = new Migration2(); var migrations = new List<IMigration> { migration1, migration2 }; try { const int SCHEMA_VERSION = 2; versionDataSource.SetVersionNumber(SCHEMA_VERSION); const int DOWNGRADE_TO_VERSION = 5; runner.Migrations = migrations; runner.RunDownMigrations(DOWNGRADE_TO_VERSION); runner.RunDownMigrations(SCHEMA_VERSION); // Assert that we did not run the bogus downgrade and that the schema version did not change Assert.IsTrue(versionDataSource.GetVersionNumber() == SCHEMA_VERSION); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void TestGetMigrationAttributes() { Migration1 foo = new Migration1(); MigrationAttribute attr = MigrationService.GetMigrationsAttributes(foo); Assert.AreEqual(attr.Version, 1.0); }
public void TestGetMigrationVersionNumber() { IMigration migration1 = new Migration1(); Assert.AreEqual(1.0, MigrationService.GetMigrationVersionNumber(migration1)); }
public void TestRunUpMigrationsTo() { IMigration migration1 = new Migration1(); IMigration migration2 = new Migration2(); List<IMigration> migrations = new List<IMigration>() { migration1, migration2 }; try { const int UPGRADE_TO_VERSION = 2; this.runner.Migrations = migrations; this.runner.RunUpMigrations(UPGRADE_TO_VERSION); // Assert that we ran two upgrade migrations, are at version UGRADE_TO_VERSION Assert.IsTrue(this.versionDataSource.GetVersionNumber() == UPGRADE_TO_VERSION); } catch(Exception ex) { Assert.Fail(ex.Message); } }
public void TestRunUpMigrationsToBogus() { IMigration migration1 = new Migration1(); IMigration migration2 = new Migration2(); List<IMigration> migrations = new List<IMigration>() { migration1, migration2 }; try { const int SCHEMA_VERSION = 2; this.versionDataSource.SetVersionNumber(SCHEMA_VERSION); const int UPGRADE_TO_VERSION = 1; this.runner.Migrations = migrations; this.runner.RunUpMigrations(UPGRADE_TO_VERSION); // Assert that we did not run the bogus upgrade and that the schema version did not change Assert.IsTrue(this.versionDataSource.GetVersionNumber() == SCHEMA_VERSION); } catch(Exception ex) { Assert.Fail(ex.Message); } }
public void TestRunDownMigrations() { IMigration migration1 = new Migration1(); IMigration migration2 = new Migration2(); List<IMigration> migrations = new List<IMigration>() { migration1, migration2 }; try { this.versionDataSource.SetVersionNumber(2); this.runner.Migrations = migrations; this.runner.RunDownMigrations(); // Assert that we end up downgraded to version 0 Assert.IsTrue(this.versionDataSource.GetVersionNumber() == 0); } catch(Exception ex) { Assert.Fail(ex.Message); } }
public void TestRunMigrateTo() { IMigration migration1 = new Migration1(); IMigration migration2 = new Migration2(); List<IMigration> migrations = new List<IMigration>() { migration1, migration2 }; try { int SCHEMA_VERSION = 2; int MIGRATE_TO_VERSION = 1; this.runner.Migrations = migrations; // Migrate down this.versionDataSource.SetVersionNumber(SCHEMA_VERSION); this.runner.MigrateToVersion(MIGRATE_TO_VERSION); Assert.IsTrue(this.versionDataSource.GetVersionNumber() == MIGRATE_TO_VERSION); // Migrate up SCHEMA_VERSION = 1; MIGRATE_TO_VERSION = 2; this.versionDataSource.SetVersionNumber(SCHEMA_VERSION); this.runner.MigrateToVersion(MIGRATE_TO_VERSION); Assert.IsTrue(this.versionDataSource.GetVersionNumber() == MIGRATE_TO_VERSION); // no change SCHEMA_VERSION = 1; MIGRATE_TO_VERSION = 1; this.versionDataSource.SetVersionNumber(SCHEMA_VERSION); this.runner.MigrateToVersion(MIGRATE_TO_VERSION); Assert.IsTrue(this.versionDataSource.GetVersionNumber() == SCHEMA_VERSION); } catch(Exception ex) { Assert.Fail(ex.Message); } }
public void TestRunDownMigrationsTo() { IMigration migration1 = new Migration1(); IMigration migration2 = new Migration2(); var migrations = new List<IMigration> { migration1, migration2 }; try { const int DOWNGRADE_TO_VERSION = 1; const int SCHEMA_VERSION = 2; versionDataSource.SetVersionNumber(SCHEMA_VERSION); runner.Migrations = migrations; runner.RunDownMigrations(DOWNGRADE_TO_VERSION); // Assert that we ran two downgrade migrations, are at version DOWNGRADE_TO_VERSION Assert.IsTrue(versionDataSource.GetVersionNumber() == DOWNGRADE_TO_VERSION); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void TestIndexSet() { var m1 = new Migration1(); this.runner.Migrations.Add(m1); var m2 = new Migration2(); this.runner[0] = m2; Assert.AreEqual(m2, this.runner.Migrations[0]); }
public void TestIndexerGet() { var m1 = new Migration1(); this.runner.Migrations.Add(m1); Assert.AreSame(m1, this.runner[0]); }
public void TestRunUpMigrations() { IMigration migration1 = new Migration1(); IMigration migration2 = new Migration2(); var migrations = new List<IMigration> { migration1, migration2 }; try { runner.Migrations = migrations; runner.RunUpMigrations(); // Assert that we ran two upgrade migrations, are at version 2 Assert.IsTrue(versionDataSource.GetVersionNumber() == 2); } catch (Exception ex) { Assert.Fail(ex.Message); } }
public void TestRunUpMigrationsWithVersionsSkipped() { IMigration migration1 = new Migration1(); IMigration migration3 = new Migration3(); var migrations = new List<IMigration> { migration1, migration3 }; try { runner.Migrations = migrations; runner.RunUpMigrations(); // Assert that we ran two upgrade migrations, are at version UGRADE_TO_VERSION Assert.IsTrue(versionDataSource.GetVersionNumber() == 3); } catch (Exception ex) { Assert.Fail(ex.Message); } }