public void ClearTest() { _migrator = new NPocoMigrator(); _loadStatus = _migrator.LoadConfig(); if (_loadStatus) { _migrator.MigrationsConfig.DbVersion = "0.0.0"; _migrator.SaveConfig(); _loadStatus = _migrator.LoadMigrations(); } }
public void MigrationsConfigCorrectlyLoaded() { var migrator = new NPocoMigrator(); migrator.LoadConfig(); Assert.AreEqual("DevDb", migrator.MigrationsConfig.DbConnection); Assert.AreEqual("0.0.0", migrator.MigrationsConfig.DbVersion); Assert.AreEqual(new Version("0.0.0"), migrator.MigrationsConfig.SysDbVersion); Assert.AreEqual("Migrations", migrator.MigrationsConfig.MigrationsDir); Assert.AreEqual($"{AppDomain.CurrentDomain.BaseDirectory}\\{NPocoMigrationsConstants.MigrationsConfigFile}", migrator.MigrationsConfigFilePath); }
public void LoadingConfigFailsTest() { File.Move(NPocoMigrationsConstants.MigrationsConfigFile, $"_{NPocoMigrationsConstants.MigrationsConfigFile}"); var migrator = new NPocoMigrator("."); var result = migrator.LoadConfig(); File.Move($"_{NPocoMigrationsConstants.MigrationsConfigFile}", NPocoMigrationsConstants.MigrationsConfigFile); Assert.IsFalse(result); }
public void ClearTest() { using (var migrator = new NPocoMigrator(".")) { migrator.LoadConfig(); using (var db = new Database(migrator.MigrationsConfig.DbConnection)) { db.Execute("IF OBJECT_ID('dbo.GeoData', 'U') IS NOT NULL DROP TABLE dbo.GeoData"); db.Execute("IF OBJECT_ID('dbo.MemberSettings', 'U') IS NOT NULL DROP TABLE dbo.MemberSettings"); db.Execute("IF OBJECT_ID('dbo.TableColumns_v', 'V') IS NOT NULL DROP VIEW dbo.TableColumns_v"); } } }
public void ExecutesAllMigrationsTest() { Assert.IsTrue(_loadStatus); var result = _migrator.ExecuteMigrations(); Assert.IsTrue(result); var testMigrator = new NPocoMigrator(); testMigrator.LoadConfig(); Assert.AreEqual("1.0.1", testMigrator.MigrationsConfig.DbVersion); Assert.AreEqual(new Version("1.0.1"), testMigrator.MigrationsConfig.SysDbVersion); _migrator.MigrationsConfig.DbVersion = "0.0.0"; _migrator.SaveConfig(); }
public void ExecutesAllMigrationsShortTest() { // use execution directory (explicitly) using (var migrator = new NPocoMigrator(".")) { var result = migrator.Migrate(); Assert.IsTrue(result); using (var testMigrator = new NPocoMigrator()) { testMigrator.LoadConfig(); Assert.AreEqual("1.0.1", testMigrator.MigrationsConfig.DbVersion); Assert.AreEqual(new Version("1.0.1"), testMigrator.MigrationsConfig.SysDbVersion); } migrator.MigrationsConfig.DbVersion = "0.0.0"; migrator.SaveConfig(); } }
public void ExecuteVersion101OnlyTest() { // use execution directory (implicitly) using (var migrator = new NPocoMigrator()) { migrator.LoadConfig(); migrator.MigrationsConfig.DbVersion = "1.0.0"; migrator.LoadMigrations(); var result = migrator.ExecuteMigrations(); Assert.IsTrue(result); using (var testMigrator = new NPocoMigrator()) { testMigrator.LoadConfig(); Assert.AreEqual("1.0.1", testMigrator.MigrationsConfig.DbVersion); Assert.AreEqual(new Version("1.0.1"), testMigrator.MigrationsConfig.SysDbVersion); } migrator.MigrationsConfig.DbVersion = "0.0.0"; migrator.SaveConfig(); } }
public static void ClassInit(TestContext context) { _migrator = new NPocoMigrator(); _loadStatus = _migrator.LoadConfig() && _migrator.LoadMigrations(); }
public void LoadingConfigSucceedsTest() { var migrator = new NPocoMigrator(); Assert.IsTrue(migrator.LoadConfig()); }