public void CreateVersionState_Always_SetsApplied() { using (_mocks.Record()) { SetupResult.For(_configuration.DesiredVersion).Return((long)2); SetupResult.For(_schemaStateManager.GetAppliedMigrationVersions(null)).Return(new long[] { 1, 2, 3 }); } VersionState actual = _target.CreateVersionState(_migrations)[string.Empty]; CollectionAssert.AreEqual(new long[] { 1, 2, 3 }, new List <long>(actual.Applied)); }
VersionState GetVersionState(string key, ICollection <MigrationReference> migrations) { _configuration.ActiveConfigurationKey = key; var applied = _schemaStateManager.GetAppliedMigrationVersions(_configuration.Scope); _configuration.ActiveConfigurationKey = null; long desired = _configuration.DesiredVersion; long last = 0; if (migrations.Count > 0) { List <MigrationReference> all = new List <MigrationReference>(migrations); last = all[all.Count - 1].Version; } if (desired > last) { throw new ArgumentException("DesiredVersion is greater than maximum migration!"); } if (desired < 0) { desired = last; } return(new VersionState(last, desired, applied)); }