public void InstantiateTasksSuccess()
        {
            SqlScriptMigrationTaskSource source = new SqlScriptMigrationTaskSource();
            IList<IMigrationTask> tasks =
                source.GetMigrationTasks(Directory.GetCurrentDirectory() + "\\..\\..\\sql");

            Assert.Less(0, tasks.Count);
        }
        public void InstantiateTasksNoTasks()
        {
            SqlScriptMigrationTaskSource source = new SqlScriptMigrationTaskSource();
            IList<IMigrationTask> tasks =
                source.GetMigrationTasks(Directory.GetCurrentDirectory() + "\\..\\..\\sql\\empty-directory");

            Assert.AreEqual(0, tasks.Count);
        }
예제 #3
0
        public void GetNextPatchLevelNoTasks()
        {
            TestMigrationContext context = new TestMigrationContext();
            FakeSqlMigrationProcess process = new FakeSqlMigrationProcess();
            SqlScriptMigrationTaskSource taskSource = new SqlScriptMigrationTaskSource();
            process.AddPatchResourceDirectory(Directory.GetCurrentDirectory() + "\\..\\..\\sql\\empty-directory");
            process.AddMigrationTaskSource(taskSource);
            int nextLevel = process.NextPatchLevel;

            Assert.AreEqual(nextLevel, 1);
        }
예제 #4
0
        public void DoPostPatchMigrationsReadOnly()
        {
            TestMigrationContext context = new TestMigrationContext();
            FakeSqlMigrationProcess process = new FakeSqlMigrationProcess();
            SqlScriptMigrationTaskSource taskSource = new SqlScriptMigrationTaskSource();
            process.AddPostPatchResourceAssembly(typeof(MigrationTask1).Assembly.Location);
            process.AddPostPatchResourceDirectory(Directory.GetCurrentDirectory() + "\\..\\..");
            process.AddMigrationTaskSource(taskSource);
            process.ReadOnly = true;
            int count = process.DoPostPatchMigrations(context);

            Assert.AreEqual(0, count, "No post-patch tasks were supposed to be run in readonly mode");
            Assert.AreEqual(0, context.ExecutionLog.Count, "The execution log should not have recorded anything in readonly mode");
        }
예제 #5
0
        public void DoPostPatchMigrationsNoTasks()
        {
            TestMigrationContext context = new TestMigrationContext();
            FakeSqlMigrationProcess process = new FakeSqlMigrationProcess();
            SqlScriptMigrationTaskSource taskSource = new SqlScriptMigrationTaskSource();
            process.AddPostPatchResourceDirectory(Directory.GetCurrentDirectory() + "\\..\\..\\sql\\empty-directory");
            process.AddMigrationTaskSource(taskSource);
            int tasksRun = process.DoPostPatchMigrations(context);

            Assert.AreEqual(0, tasksRun);
        }
예제 #6
0
        public void DoPostPatchMigrationsFromSqlFileAndClasses()
        {
            TestMigrationContext context = new TestMigrationContext();
            FakeSqlMigrationProcess process = new FakeSqlMigrationProcess();
            SqlScriptMigrationTaskSource taskSource = new SqlScriptMigrationTaskSource();
            process.AddPostPatchResourceAssembly(typeof(MigrationTask1).Assembly.Location);
            process.AddPostPatchResourceDirectory(Directory.GetCurrentDirectory() + "\\..\\..");
            process.AddMigrationTaskSource(taskSource);
            process.DoPostPatchMigrations(context);

            // There currently are 2 .NET code and 3 SQL patches for tests
            Assert.IsTrue(context.HasExecuted(new MigrationTask1().Name),
                "MigrationTask1 was supposed to be run");
            Assert.IsTrue(context.HasExecuted(new MigrationTask2().Name),
                "MigrationTask2 was supposed to be run");
            Assert.IsTrue(context.HasExecuted("patch0003_dummy_SQL_file"),
                "patch0003_dummy_SQL_file was supposed to be run");
            Assert.IsTrue(context.HasExecuted("patch0004_fourth_patch"),
                "patch0004_fourth_patch was supposed to be run");
            Assert.IsTrue(context.HasExecuted("patch0005_fifth_patch"),
                "patch0005_fifth_patch was supposed to be run");
        }
예제 #7
0
        public void DoMigrationsFromSqlFile()
        {
            TestMigrationContext context = new TestMigrationContext();
            FakeSqlMigrationProcess process = new FakeSqlMigrationProcess();
            SqlScriptMigrationTaskSource taskSource = new SqlScriptMigrationTaskSource();
            process.AddPatchResourceDirectory(Directory.GetCurrentDirectory() + "\\..\\..");
            process.AddMigrationTaskSource(taskSource);
            process.DoMigrations(2, context);

            Assert.IsTrue(context.HasExecuted("patch0003_dummy_SQL_file"),
                "patch0003_dummy_SQL_file was supposed to be run");
            Assert.IsTrue(context.HasExecuted("patch0004_fourth_patch"),
                "patch0004_fourth_patch was supposed to be run");
            Assert.IsTrue(context.HasExecuted("patch0005_fifth_patch"),
                "patch0005_fifth_patch was supposed to be run");
        }
 public void InstantiateTasksNullResourcePath()
 {
     SqlScriptMigrationTaskSource source = new SqlScriptMigrationTaskSource();
     source.GetMigrationTasks(null);
 }