public bool GetSteps_HistoryIsEmpty(NonNegativeInt stepsCount) { //arrange var(_, steps) = MigrationTestsContext.GenerateMigrationState(stepsCount.Item, missingCount: 0); //act var result = MigrationHandler.GetSteps(steps, allHistory: new List <MigrationHistory>(), lastLegacyMigrationVersion: new Version("1.1.1.1")); var originalVersions = steps.Select(x => x.Version.ToString()); var filteredVersions = result.Select(r => r.Version.ToString()); //assert return(originalVersions.SequenceEqual(filteredVersions)); }
public bool TryExecuteSteps_WithoutFailure(NonNegativeInt stepsCount) { //arrange var(_, steps) = MigrationTestsContext.GenerateMigrationState(0, stepsCount); //act var(executionHistory, executionResult) = MigrationHandler.TryExecuteSteps(steps); var originalVersions = steps.Select(x => x.Version.ToString()); var executedVersions = executionHistory.Reverse().Select(r => r.Version.ToString()); //assert return(executionResult.Type is ExecutionResultType.Success && originalVersions.SequenceEqual(executedVersions)); }
public Property GetMissingSteps(NonNegativeInt present, NonNegativeInt missing) { bool Predicate() { //arrange var(history, steps) = MigrationTestsContext.GenerateMigrationState(present, missing); //act var result = MigrationHandler.GetMissingSteps(steps, history, steps[present.Item - 1].Version); var originalVersions = steps.Skip(present.Item).Select(x => x.Version.ToString()); var filteredVersions = result.Select(r => r.Version.ToString()); //assert return(originalVersions.SequenceEqual(filteredVersions)); } return(new Func <bool>(Predicate).When(present.Item > 0)); }
public Property TryExecuteSteps_WithFailure(NonNegativeInt stepsCount, NonNegativeInt failurePosition) { bool Predicate() { //arrange var(_, steps) = MigrationTestsContext.GenerateMigrationState(0, stepsCount); steps[failurePosition.Item - 1] = MigrationTestsContext.MigrationItem(steps[failurePosition.Item - 1].Version, ExecutionResult.Failure(null)); //act var(executionHistory, executionResult) = MigrationHandler.TryExecuteSteps(steps); var originalVersions = steps.Take(failurePosition.Item).Select(x => x.Version.ToString()); var executedVersions = executionHistory.Reverse().Select(r => r.Version.ToString()); //assert return(executionResult.Type is ExecutionResultType.Failure && originalVersions.SequenceEqual(executedVersions)); } return(new Func <bool>(Predicate).When(stepsCount.Item >= failurePosition.Item && failurePosition.Item > 0)); }
public Property GetSteps_HistoryIsNotEmpty(NonNegativeInt present, NonNegativeInt missing, NonNegativeInt lastLegacyMigrationVersionNumber) { bool Predicate() { //arrange var(history, steps) = MigrationTestsContext.GenerateMigrationState(present, missing); var lastLegacyMigrationVersion = steps[lastLegacyMigrationVersionNumber.Item - 1]; //act var result = MigrationHandler.GetSteps(steps, history, lastLegacyMigrationVersion.Version); var originalVersions = steps.Skip(present.Item).Select(x => x.Version.ToString()); var filteredVersions = result.Select(r => r.Version.ToString()); //assert return(originalVersions.SequenceEqual(filteredVersions)); } return(new Func <bool>(Predicate).When( present.Item > 0 && lastLegacyMigrationVersionNumber.Item > 0 && lastLegacyMigrationVersionNumber.Item <= present.Item + missing.Item && lastLegacyMigrationVersionNumber.Item >= present.Item)); }