public void When_duplicate_name_found_with_embedded_file_Throws_EvolveException() { var loader = new EmbeddedResourceMigrationLoader( assemblies: new[] { typeof(TestContext).Assembly }, filters: new[] { "Evolve.Tests.Resources" }); Assert.Throws <EvolveConfigurationException>(() => loader.GetMigrations("R", "__", ".sql")); }
public void Load_repeatable_file_migrations_with_embedded_file_works() { // Arrange var loader = new EmbeddedResourceMigrationLoader( assemblies: new[] { typeof(TestContext).Assembly }, filters: new[] { "Evolve.Tests.Resources.Scripts_1", "Evolve.Tests.Resources.Scripts_2" }); // Act var scripts = loader.GetRepeatableMigrations("R", "__", ".sql").ToList(); // Assert Assert.Equal(4, scripts.Count); AssertMigration(scripts[0], "R__desc_a.sql", "desc a"); AssertMigration(scripts[1], "R__desc_b.sql", "desc b"); AssertMigration(scripts[2], "R__desc_c.sql", "desc c"); AssertMigration(scripts[3], "r__desc_ci.sql", "desc ci"); void AssertMigration(MigrationScript migration, string name, string description) { Assert.Equal(MetadataType.RepeatableMigration, migration.Type); Assert.Null(migration.Version); Assert.Equal(name, migration.Name); Assert.Equal(description, migration.Description); } }
public void Load_embedded_resource_migrations_with_embedded_file_loader_works() { // Arrange var loader = new EmbeddedResourceMigrationLoader( assemblies: new[] { typeof(TestContext).Assembly }, filters: new[] { "Evolve.Tests.Resources.Scripts_1", "Evolve.Tests.Resources.Scripts_2" }); // Act var scripts = loader.GetMigrations("V", "__", ".sql").ToList(); // Assert Assert.Equal(8, scripts.Count); AssertMigration(scripts[0], "1.3.0", "V1_3_0__desc.sql", "desc"); AssertMigration(scripts[1], "1.3.1", "V1_3_1__desc.sql", "desc"); AssertMigration(scripts[2], "1.4.0", "V1_4_0__desc.sql", "desc"); AssertMigration(scripts[3], "1.5.0", "V1_5_0__desc.sql", "desc"); AssertMigration(scripts[4], "2.0.0", "V2_0_0__desc.sql", "desc"); AssertMigration(scripts[5], "2.4.0", "V2_4_0__desc.sql", "desc"); AssertMigration(scripts[6], "3.0.0", "v3_0_0__CI.sql", "CI"); AssertMigration(scripts[7], "3.0.1", "V3_0_1__CI.Sql", "CI"); void AssertMigration(MigrationScript migration, string version, string name, string description) { Assert.Equal(MetadataType.Migration, migration.Type); Assert.Equal(version, migration.Version.Label); Assert.Equal(name, migration.Name); Assert.Equal(description, migration.Description); } }
public void TestSameMigrationMatchesWithNormalization() { IList <IMigrationScript> scripts = new FileMigrationLoader(normalizeLineEndingsForChecksum: true).GetMigrations(new List <string> { "Resources/scripts." }, "V", "__", ".sql").ToList(); IList <IMigrationScript> embedded = new EmbeddedResourceMigrationLoader(GetType().Assembly, normalizeLineEndingsForChecksum: true).GetMigrations(new List <string> { "Evolve.Test.Resources.scripts." }, "V", "__", ".sql").ToList(); Assert.Equal(2, scripts.Count); Assert.Equal(2, embedded.Count); Assert.True(scripts.Zip(embedded, Tuple.Create).All(AreEqual)); }
public void LoadEmbeddedResources() { IList <IMigrationScript> scripts = new EmbeddedResourceMigrationLoader(GetType().Assembly).GetMigrations(new List <string> { "Evolve.Test.Resources.scripts." }, "V", "__", ".sql").ToList(); Assert.Equal(2, scripts.Count); var script = scripts.First(); Assert.Equal("V1_0_0__Test-Migration.sql", script.Name); Assert.Equal("Test-Migration", script.Description); Assert.NotNull(script.CheckSum); Assert.Equal("select 1;", script.LoadSqlStatements(null, "GO").FirstOrDefault()); }
public void Load_embedded_resource_migrations_works() { // Arrange var loader = new EmbeddedResourceMigrationLoader( assemblies: new[] { typeof(TestContext).Assembly }, filters: new[] { "Evolve.Tests.Resources.Scripts_1" }); // Act var scripts = loader.GetMigrations("V", "__", ".sql").ToList(); // Assert Assert.Equal("1.3.0", scripts[0].Version.Label); Assert.Equal("1.3.1", scripts[1].Version.Label); Assert.Equal("1.5.0", scripts[2].Version.Label); Assert.Equal("2.0.0", scripts[3].Version.Label); }
public void Load_embedded_resource_migrations_with_embedded_file_loader_works() { // Arrange var loader = new EmbeddedResourceMigrationLoader(new EvolveConfiguration { EmbeddedResourceAssemblies = new[] { typeof(TestContext).Assembly }, EmbeddedResourceFilters = new[] { "EvolveDb.Tests.Resources.Scripts_1", "EvolveDb.Tests.Resources.Scripts_2" } }); // Act var scripts = loader.GetMigrations().ToList(); // Assert Assert.Equal(8, scripts.Count); AssertMigration(scripts[0], "1.3.0", "V1_3_0__desc.sql", "desc"); AssertMigration(scripts[1], "1.3.1", "V1_3_1__desc.sql", "desc"); AssertMigration(scripts[2], "1.4.0", "V1_4_0__desc.sql", "desc"); AssertMigration(scripts[3], "1.5.0", "V1_5_0__desc.sql", "desc"); AssertMigration(scripts[4], "2.0.0", "V2_0_0__desc.sql", "desc"); AssertMigration(scripts[5], "2.4.0", "V2_4_0__desc.sql", "desc"); AssertMigration(scripts[6], "3.0.0", "v3_0_0__CI.sql", "CI"); AssertMigration(scripts[7], "3.0.1", "V3_0_1__CI.Sql", "CI");
public void When_duplicate_version_found_Throws_EvolveException() { var loader = new EmbeddedResourceMigrationLoader(assemblies: new[] { typeof(TestContext).Assembly }, filters: null); Assert.Throws <EvolveConfigurationException>(() => loader.GetMigrations("V", "__", ".sql")); }