public async Task ExecuteAsync_MatchesModulesByWildcard() { var migrations = new[] { Substitute.For <IDatabaseMigration>() }; migrationRegistry.SearchModules("app-*").Returns(new[] { "appmodule-foo" }); migrationExecutionOptions.MigrateOnlySpecifiedModules.Returns(new[] { new DatabaseMigrationSearchSpecifier("app-*", null) }); migrationSelector.SelectMigrationsAsync( Arg.Is <DatabaseMigrationSpecifier[]>(x => x.SequenceEqual(new[] { new DatabaseMigrationSpecifier("appmodule-foo", null) })), Arg.Any <string[]>()) .Returns(migrations.Select(x => new SelectedModuleMigrations(new DatabaseMigrationSpecifier("appmodule-foo", null), migrations)).ToArray()); migrationProviders[0].SupportsMigration(migrations[0]).Returns(true); await sut.ExecuteAsync(); migrationProviders[0].Received(1).ApplyMigrationsAsync(migrations); }
private List <DatabaseMigrationSpecifier> SearchModules(IReadOnlyCollection <DatabaseMigrationSearchSpecifier> searchedModules) { var result = new List <DatabaseMigrationSpecifier>(); foreach (var searchedModule in searchedModules) { var matchingModules = migrationRegistry.SearchModules(searchedModule.ModuleNameWildcard) .Select(x => new DatabaseMigrationSpecifier(x, searchedModule.Version)) .ToArray(); foreach (var matchingModule in matchingModules) { if (!result.Contains(matchingModule)) { result.Add(matchingModule); } } } return(result); }