예제 #1
0
        public void TestRunSeeder()
        {
            var service        = new MigrationAssemblyService();
            var recognizedFile = new RecognizedMigrationFile(typeof(SeederC), "SeederC", "SeederC");

            Assert.IsFalse(SeederC.IsCalled);

            service.RunSeeder(recognizedFile);

            Assert.IsTrue(SeederC.IsCalled);
        }
예제 #2
0
        public void TestRunMigration_Down()
        {
            A.DownIsCalled = false;
            A.DownIsCalled = false;

            var service        = new MigrationAssemblyService();
            var recognizedFile = new RecognizedMigrationFile(typeof(A), "A", "A");

            Assert.IsFalse(A.UpIsCalled);
            Assert.IsFalse(A.DownIsCalled);

            service.RunMigration(recognizedFile, MigrationDirection.Down);

            Assert.IsTrue(A.DownIsCalled);
            Assert.IsFalse(A.UpIsCalled);
        }
예제 #3
0
        public void TestRunMigration_Up()
        {
            C.DownIsCalled = false;
            C.DownIsCalled = false;

            var service        = new MigrationAssemblyService();
            var recognizedFile = new RecognizedMigrationFile(typeof(C), "C", "C");

            Assert.IsFalse(C.UpIsCalled);
            Assert.IsFalse(C.DownIsCalled);

            service.RunMigration(recognizedFile, MigrationDirection.Up);

            Assert.IsTrue(C.UpIsCalled);
            Assert.IsFalse(C.DownIsCalled);
        }
예제 #4
0
        public void TestFindTypes_FilterWithSeeder()
        {
            var service = new MigrationAssemblyService();
            var types   = new Type[]
            {
                typeof(SeederA),
                typeof(A),
                typeof(NotMigration)
            };

            var result = service.FindTypes <Seeder>(types);

            Assert.AreEqual(1, result.Count);
            Assert.AreEqual("SeederA", result[0].FullName);
            Assert.AreEqual("SeederA", result[0].Name);
            Assert.AreEqual(typeof(SeederA), result[0].Type);
            Assert.AreEqual(null, result[0].Version);
        }
예제 #5
0
        public void TestFindTypes_Sort()
        {
            var service = new MigrationAssemblyService();
            var types   = new Type[]
            {
                typeof(A),
                typeof(_2_A),
                typeof(_1_B),
                typeof(B),
                typeof(_1_A)
            };

            var result = service.FindTypes <Migration>(types);

            Assert.AreEqual("_1_A", result[0].FullName);
            Assert.AreEqual("A", result[0].Name);
            Assert.AreEqual(typeof(_1_A), result[0].Type);
            Assert.AreEqual("_1_", result[0].Version);

            Assert.AreEqual("_2_A", result[1].FullName);
            Assert.AreEqual("A", result[1].Name);
            Assert.AreEqual(typeof(_2_A), result[1].Type);
            Assert.AreEqual("_2_", result[1].Version);

            Assert.AreEqual("_1_B", result[2].FullName);
            Assert.AreEqual("B", result[2].Name);
            Assert.AreEqual(typeof(_1_B), result[2].Type);
            Assert.AreEqual("_1_", result[2].Version);

            Assert.AreEqual("A", result[3].FullName);
            Assert.AreEqual("A", result[3].Name);
            Assert.AreEqual(typeof(A), result[3].Type);
            Assert.AreEqual(null, result[3].Version);

            Assert.AreEqual("B", result[4].FullName);
            Assert.AreEqual("B", result[4].Name);
            Assert.AreEqual(typeof(B), result[4].Type);
            Assert.AreEqual(null, result[4].Version);
        }
예제 #6
0
        public void TestGroup()
        {
            var service = new MigrationAssemblyService();
            var types   = new Type[]
            {
                typeof(A),
                typeof(_2_A),
                typeof(_1_B),
                typeof(B),
                typeof(_1_A)
            };

            var result = service.FindTypes <Migration>(types);

            var groups = service.Group(result);

            Assert.AreEqual(2, groups.Count);

            Assert.AreEqual("A", groups["A"][0].Name);
            Assert.AreEqual("A", groups["A"][0].FullName);
            Assert.AreEqual(null, groups["A"][0].Version);

            Assert.AreEqual("A", groups["A"][1].Name);
            Assert.AreEqual("_1_A", groups["A"][1].FullName);
            Assert.AreEqual("_1_", groups["A"][1].Version);

            Assert.AreEqual("A", groups["A"][2].Name);
            Assert.AreEqual("_2_A", groups["A"][2].FullName);
            Assert.AreEqual("_2_", groups["A"][2].Version);

            Assert.AreEqual("B", groups["B"][0].Name);
            Assert.AreEqual("B", groups["B"][0].FullName);
            Assert.AreEqual(null, groups["B"][0].Version);

            Assert.AreEqual("B", groups["B"][1].Name);
            Assert.AreEqual("_1_B", groups["B"][1].FullName);
            Assert.AreEqual("_1_", groups["B"][1].Version);
        }