public IDictionary <string, List <MigrationStep> > SelectMigrations() { var all = _migrationFinder.FindMigrations(); var selected = new Dictionary <string, List <MigrationStep> >(); selected[string.Empty] = new List <MigrationStep>(); if (all.Count == 0) { return(selected); } var versionStates = _versionStateFactory.CreateVersionState(all); foreach (var state in versionStates) { selected[state.Key] = new List <MigrationStep>(); } foreach (var migration in all) { var version = versionStates[migration.ConfigurationKey]; if (version.IsApplicable(migration)) { var step = new MigrationStep(migration, version.IsReverting); selected[migration.ConfigurationKey].Add(step); } } foreach (var pair in versionStates) { if (pair.Value.IsReverting) { selected[pair.Key].Reverse(); } } return(selected); }
void SetupMocks(long desired, IEnumerable <long> applied) { SetupResult.For(_versionStateFactory.CreateVersionState(_migrations)).Return(new Dictionary <string, VersionState>() { { string.Empty, new VersionState(4, desired, applied) } }); SetupResult.For(_migrationFinder.FindMigrations()).Return(_migrations); }