Ejemplo n.º 1
0
        public void ClearTest()
        {
            if (_loadStatus)
            {
                _migrator.MigrationsConfig.DbVersion = "0.0.0";
                _migrator.SaveConfig();

                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 ClearTest()
        {
            _migrator   = new NPocoMigrator();
            _loadStatus = _migrator.LoadConfig();

            if (_loadStatus)
            {
                _migrator.MigrationsConfig.DbVersion = "0.0.0";
                _migrator.SaveConfig();
                _loadStatus = _migrator.LoadMigrations();
            }
        }
        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();
            }
        }