Exemplo n.º 1
0
        public void ExecuteVersion101OnlyTest()
        {
            Assert.IsTrue(_loadStatus);

            _migrator.MigrationsConfig.DbVersion = "1.0.0";
            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 ExecutesAllMigrationsTest()
        {
            // use execution directory (explicitly)
            using (var migrator = new NPocoMigrator("."))
            {
                migrator.LoadConfig();
                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();
            }
        }