Example #1
0
        public void TestThrowsExceptionForUnknownMigration()
        {
            var migrationsA = "a,b,c,d";
            var migrationsB = "a,b,x,y,z";

            var contextA = MigrationContext.FromCommaSeparatedStrings("a", migrationsA, "");
            var contextB = MigrationContext.FromCommaSeparatedStrings("b", migrationsB, "");

            Assert.Throws <MigrationException>(() =>
            {
                var difference = contextA.Difference(contextB);
            });
            try
            {
                var difference2 = contextA.Difference(contextB);
                Assert.True(false); // should never reach
            }
            catch (MigrationException e)
            {
                Assert.True(e.RelatedMigrations.Count == 3);
                Assert.Contains(e.RelatedMigrations, migration => migration.Id == "x");
                Assert.Contains(e.RelatedMigrations, migration => migration.Id == "y");
                Assert.Contains(e.RelatedMigrations, migration => migration.Id == "z");
            }
        }
Example #2
0
        public void TestDifferenceIsMissingHotfixes()
        {
            var migrationsA = "a,b,c,d";
            var migrationsB = "a,b";
            var hotfixesA   = "x,y,z";
            var hotfixesB   = "m,x,n";

            var contextA = MigrationContext.FromCommaSeparatedStrings("a", migrationsA, hotfixesA);
            var contextB = MigrationContext.FromCommaSeparatedStrings("b", migrationsB, hotfixesB);

            var difference = contextA.Difference(contextB);

            // intentionally invalid migrations path
            var expectedDifference = new List <Migration>()
            {
                new Migration()
                {
                    Id = "y"
                },
                new Migration()
                {
                    Id = "z"
                }
            };

            Assert.Equal(expectedDifference, difference.Hotfixes);
        }
Example #3
0
        public void TestThrowsExceptionForOutOfOrderMigrations()
        {
            var migrationsA = "a,b,c,d";
            var migrationsB = "b,a,c";

            var contextA = MigrationContext.FromCommaSeparatedStrings("a", migrationsA, "");
            var contextB = MigrationContext.FromCommaSeparatedStrings("a", migrationsB, "");

            Assert.Throws <MigrationException>(() =>
            {
                var difference = contextA.Difference(contextB);
            });
        }
Example #4
0
        public void TestDifferenceIsMissingMigrations2()
        {
            var migrationsA = "a,b,c,d";
            var migrationsB = "a,b";

            var contextA = MigrationContext.FromCommaSeparatedStrings("a", migrationsA, "");
            var contextB = MigrationContext.FromCommaSeparatedStrings("b", migrationsB, "");

            var difference = contextA.Difference(contextB);

            // intentionally invalid migrations path
            var expectedDifference = new List <Migration>()
            {
                new Migration()
                {
                    Id = "c", ParentId = "b"
                },
                new Migration()
                {
                    Id = "d", ParentId = "a"
                }
            };

            Assert.NotEqual(expectedDifference, difference.Migrations);

            expectedDifference = new List <Migration>()
            {
                new Migration()
                {
                    Id = "something else", ParentId = "b"
                },
                new Migration()
                {
                    Id = "d", ParentId = "c"
                }
            };
            Assert.NotEqual(expectedDifference, difference.Migrations);
        }
Example #5
0
        public void TestDifferenceIsMissingMigrations()
        {
            var migrationsA = "a,b,c,d";
            var migrationsB = "a,b";

            var contextA = MigrationContext.FromCommaSeparatedStrings("a", migrationsA, "");
            var contextB = MigrationContext.FromCommaSeparatedStrings("b", migrationsB, "");

            var difference = contextA.Difference(contextB);

            var expectedDifference = new List <Migration>()
            {
                new Migration()
                {
                    Id = "c", ParentId = "b"
                },
                new Migration()
                {
                    Id = "d", ParentId = "c"
                }
            };

            Assert.Equal(expectedDifference, difference.Migrations);
        }