public void CanFindMigrationsInNamespace() { var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new MigrationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Interleaved.Pass1", null, new AppliedVersions()); var migrationList = loader.FindMigrations(); migrationList.Select(x => x.Type).ShouldNotContain(typeof(VersionedMigration)); migrationList.Count().ShouldBeGreaterThan(0); }
public void DoesFindMigrationsThatHaveMatchingTags() { var asm = Assembly.GetExecutingAssembly(); var migrationType = typeof(TaggedMigraion); var tagsToMatch = new[] { "UK", "Production" }; var conventionsMock = new Mock<IMigrationConventions>(); conventionsMock.SetupGet(m => m.GetMetadataForMigration).Returns(DefaultMigrationConventions.GetMetadataForMigration); 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) => (migrationType == type && tagsToMatch == tags)); var loader = new MigrationLoader(conventionsMock.Object, asm, migrationType.Namespace, tagsToMatch, new AppliedVersions()); var expected = new List<Type> { typeof(UntaggedMigration), migrationType }; var actual = loader.FindMigrations().Select(m => m.Type).ToList(); CollectionAssert.AreEquivalent(expected, actual); }
public void HandlesNotFindingMigrations() { var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new MigrationLoader(conventions, asm, "FluentMigrator.Tests.Unit.EmptyNamespace", null); var list = loader.FindMigrations(); Assert.That(list, Is.Not.Null); Assert.That(list.Count(), Is.EqualTo(0)); }
public void FindsMigrationsInNestedNamepsaceWhenLoadNestedNamespacesEnabled() { var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new MigrationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Nested", true, null, new AppliedVersions()); 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.FindMigrations(); List<Type> actual = migrationList.Select(m => m.Type).ToList(); CollectionAssert.AreEquivalent(expected, actual); }
public void DoesNotFindsMigrationsInNestedNamepsaceWhenLoadNestedNamespacesDisabled() { var conventions = new MigrationConventions(); var asm = Assembly.GetExecutingAssembly(); var loader = new MigrationLoader(conventions, asm, "FluentMigrator.Tests.Integration.Migrations.Nested", false, null); List<Type> expected = new List<Type> { typeof(Integration.Migrations.Nested.NotGrouped), }; var migrationList = loader.FindMigrations(); List<Type> actual = migrationList.Select(m => m.Type).ToList(); CollectionAssert.AreEquivalent(expected, actual); }