Example #1
0
 public NamespaceMigrationInformationLoader(string @namespace,
                                            IFilteringMigrationSource source, DefaultMigrationInformationLoader inner)
 {
     _namespace = @namespace;
     _source    = source;
     _inner     = inner;
 }
Example #2
0
        public void ObsoleteShouldThrowExceptionIfDuplicateVersionNumbersAreLoaded()
        {
            var conventions     = new MigrationRunnerConventions();
            var asm             = Assembly.GetExecutingAssembly();
            var migrationLoader = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Unit.DuplicateVersionNumbers", null);

            Assert.Throws <DuplicateMigrationException>(() => migrationLoader.LoadMigrations());
        }
Example #3
0
        public void ObsoleteHandlesMigrationThatDoesNotInheritFromMigrationBaseClass()
        {
            var conventions = new MigrationRunnerConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Unit.DoesNotInheritFromBaseClass", null);

            Assert.That(loader.LoadMigrations().Count(), Is.EqualTo(1));
        }
Example #4
0
        public void ObsoleteDefaultBehaviorIsToNotLoadNestedNamespaces()
        {
            var conventions = new MigrationRunnerConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Nested", null);

            loader.LoadNestedNamespaces.ShouldBe(false);
        }
Example #5
0
        public void ObsoleteHandlesNotFindingMigrations()
        {
            var conventions = new MigrationRunnerConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Unit.EmptyNamespace", null);

            Assert.Throws <MissingMigrationsException>(() => loader.LoadMigrations());
        }
Example #6
0
        public void ObsoleteCanFindMigrationsInNamespace()
        {
            var conventions = new MigrationRunnerConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass1", null);

            var migrationList = loader.LoadMigrations();

            migrationList.Select(x => x.Value.Migration.GetType()).ShouldNotContain(typeof(VersionedMigration));
            migrationList.Count().ShouldBeGreaterThan(0);
        }
        public void HandlesNotFindingMigrations()
        {
            var conventions = new MigrationConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Unit.EmptyNamespace", null);

            var list = loader.LoadMigrations();

            Assert.That(list, Is.Not.Null);
            Assert.That(list.Count(), Is.EqualTo(0));
        }
Example #8
0
        public void ObsoleteCanFindMigrationsInAssembly()
        {
            var conventions = new MigrationRunnerConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass1", null);

            SortedList <long, IMigrationInfo> migrationList = loader.LoadMigrations();

            //if this works, there will be at least one migration class because i've included on in this code file
            int count = migrationList.Count();

            count.ShouldBeGreaterThan(0);
        }
Example #9
0
        public void ObsoleteDoesNotFindsMigrationsInNestedNamespaceWhenLoadNestedNamespacesDisabled()
        {
            var conventions = new MigrationRunnerConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Nested", false, null);

            List <Type> expected = new List <Type>
            {
                typeof(Integration.Migrations.Nested.NotGrouped),
            };

            var         migrationList = loader.LoadMigrations();
            List <Type> actual        = migrationList.Select(m => m.Value.Migration.GetType()).ToList();

            CollectionAssert.AreEquivalent(expected, actual);
        }
Example #10
0
        public void ObsoleteShouldHandleTransactionlessMigrations()
        {
            var conventions = new MigrationRunnerConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Unit.DoesHandleTransactionLessMigrations", null);

            var list = loader.LoadMigrations().ToList();

            list.Count().ShouldBe(2);

            list[0].Value.Migration.GetType().ShouldBe(typeof(DoesHandleTransactionLessMigrations.MigrationThatIsTransactionLess));
            list[0].Value.TransactionBehavior.ShouldBe(TransactionBehavior.None);
            list[0].Value.Version.ShouldBe(1);

            list[1].Value.Migration.GetType().ShouldBe(typeof(DoesHandleTransactionLessMigrations.MigrationThatIsNotTransactionLess));
            list[1].Value.TransactionBehavior.ShouldBe(TransactionBehavior.Default);
            list[1].Value.Version.ShouldBe(2);
        }
        public void FindsMigrationsInNestedNamespaceWhenLoadNestedNamespacesEnabled()
        {
            var conventions = new MigrationConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Nested", true, null);

            List <Type> expected = new List <Type>
            {
                typeof(Integration.Migrations.Nested.NotGrouped),
                typeof(Integration.Migrations.Nested.Group1.FromGroup1),
                typeof(Integration.Migrations.Nested.Group1.AnotherFromGroup1),
                typeof(Integration.Migrations.Nested.Group2.FromGroup2),
            };

            var         migrationList = loader.LoadMigrations();
            List <Type> actual        = migrationList.Select(m => m.Value.Migration.GetType()).ToList();

            CollectionAssert.AreEquivalent(expected, actual);
        }
        public void CanFindMigrationsInAssembly()
        {
            var conventions = new MigrationConventions();
            var asm         = Assembly.GetExecutingAssembly();
            var loader      = new DefaultMigrationInformationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass1", null);

            SortedList <long, IMigrationInfo> migrationList = loader.LoadMigrations();

            //if this works, there will be at least one migration class because i've included on in this code file
            var en    = migrationList.GetEnumerator();
            int count = 0;

            while (en.MoveNext())
            {
                count++;
            }

            count.ShouldBeGreaterThan(0);
        }
Example #13
0
        public void ObsoleteDoesNotFindMigrationsThatDoNotHaveMatchingTags()
        {
            var asm           = Assembly.GetExecutingAssembly();
            var migrationType = typeof(TaggedMigration);
            var tagsToMatch   = new[] { "UK", "Production" };

            var conventionsMock = new Mock <IMigrationRunnerConventions>();

            conventionsMock.SetupGet(m => m.GetMigrationInfoForMigration).Returns(DefaultMigrationRunnerConventions.Instance.GetMigrationInfoForMigration);
            conventionsMock.SetupGet(m => m.TypeIsMigration).Returns(t => true);
            conventionsMock.SetupGet(m => m.TypeHasTags).Returns(t => migrationType == t);
            conventionsMock.SetupGet(m => m.TypeHasMatchingTags).Returns((type, tags) => false);

            var loader = new DefaultMigrationInformationLoader(conventionsMock.Object, asm, migrationType.Namespace, tagsToMatch);

            var expected = new List <Type> {
                typeof(UntaggedMigration)
            };

            var actual = loader.LoadMigrations().Select(m => m.Value.Migration.GetType()).ToList();

            CollectionAssert.AreEquivalent(expected, actual);
        }