Exemplo n.º 1
0
        private async Task <IReadOnlyCollection <PendingModuleMigration> > SelectMigrationsAsync()
        {
            IReadOnlyCollection <PendingModuleMigration> migrations;

            if (options.MigrateOnlySpecifiedModules != null)
            {
                migrations = await SelectModuleMigrationsAsync(options.MigrateOnlySpecifiedModules.ToArray());
            }
            else
            {
                migrations = await SelectModuleMigrationsAsync(
                    migrationRegistry.GetAvailableModules()
                    .Select(x => new DatabaseMigrationSpecifier(x, null)).ToArray());
            }

            return(migrations);
        }
Exemplo n.º 2
0
        public async Task ExecuteAsync_AppliesSelected()
        {
            var migrations = new[] { Substitute.For <IDatabaseMigration>() };

            migrationRegistry.GetAvailableModules().Returns(new[] { "appModule1" });
            migrationExecutionOptions.MigrateOnlySpecifiedModules.Returns((IReadOnlyCollection <DatabaseMigrationSearchSpecifier>)null);

            migrationSelector.SelectMigrationsAsync(
                Arg.Is <DatabaseMigrationSpecifier[]>(x =>
                                                      x.SequenceEqual(new[] { new DatabaseMigrationSpecifier("appModule1", null) })),
                Arg.Is <string[]>(x => x.Length == 2 && x.Contains("providerTag") && x.Contains("optionsTag")))
            .Returns(migrations.Select(x => new SelectedModuleMigrations(new DatabaseMigrationSpecifier("appModule1", null), migrations)).ToArray());

            migrationProviders[0].SupportsMigration(migrations[0]).Returns(true);

            await sut.ExecuteAsync();

            migrationProviders[0].Received(1).ApplyMigrationsAsync(migrations);
        }