Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -r595f353e98d132713e4f64452332eef14627140c -r9bf880dc73a6626c77988dc2b5e3fa3763ce2329 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision 595f353e98d132713e4f64452332eef14627140c) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision 9bf880dc73a6626c77988dc2b5e3fa3763ce2329) @@ -198,8 +198,8 @@ { var blocksText = string.Format(Resources.StabilityStoneCoverWaveConditionsCalculationActivity_OnRun_Calculate_blocks_waterlevel_0_, waterLevels[i]); var columnsText = string.Format(Resources.StabilityStoneCoverWaveConditionsCalculationActivity_OnRun_Calculate_columns_waterlevel_0_, waterLevels[i]); - Assert.AreEqual(progessTexts[i * 2], blocksText); - Assert.AreEqual(progessTexts[i * 2 + 1], columnsText); + Assert.AreEqual(progessTexts[i*2], blocksText); + Assert.AreEqual(progessTexts[i*2 + 1], columnsText); } } } @@ -262,6 +262,86 @@ } [Test] + public void Cancel_WhenPerformingCalculationForBlocks_CurrentAndSubsequentWaterLevelCalculationsCancelled() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection); + + var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, testDataPath, assessmentSection.StabilityStoneCover, assessmentSection); + + using (new WaveConditionsCalculationServiceConfig()) + { + activity.ProgressChanged += (sender, args) => + { + if (activity.State != ActivityState.Canceled && activity.ProgressText.Contains("Blokken")) + { + // Call + activity.Cancel(); + } + }; + + // Assert + TestHelper.AssertLogMessages(() => activity.Run(), messages => + { + string[] msgs = messages.ToArray(); + RoundedDouble firstWaterLevel = calculation.InputParameters.WaterLevels.First(); + + Assert.AreEqual(4, msgs.Length); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith(string.Format("Blokken berekening '{0}' voor waterstand '{1}' gestart om: ", calculation.Name, firstWaterLevel), msgs[1]); + StringAssert.StartsWith(string.Format("Blokken berekening '{0}' voor waterstand '{1}' beëindigd om: ", calculation.Name, firstWaterLevel), msgs[2]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[3]); + }); + + Assert.AreEqual(ActivityState.Canceled, activity.State); + } + } + + [Test] + public void Cancel_WhenPerformingCalculationForColumns_CurrentAndSubsequentWaterLevelCalculationsCancelled() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection); + + var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, testDataPath, assessmentSection.StabilityStoneCover, assessmentSection); + + using (new WaveConditionsCalculationServiceConfig()) + { + activity.ProgressChanged += (sender, args) => + { + if (activity.State != ActivityState.Canceled && activity.ProgressText.Contains("Zuilen")) + { + // Call + activity.Cancel(); + } + }; + + // Assert + TestHelper.AssertLogMessages(() => activity.Run(), messages => + { + string[] msgs = messages.ToArray(); + RoundedDouble firstWaterLevel = calculation.InputParameters.WaterLevels.First(); + + Assert.AreEqual(6, msgs.Length); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith(string.Format("Blokken berekening '{0}' voor waterstand '{1}' gestart om: ", calculation.Name, firstWaterLevel), msgs[1]); + StringAssert.StartsWith(string.Format("Blokken berekening '{0}' voor waterstand '{1}' beëindigd om: ", calculation.Name, firstWaterLevel), msgs[2]); + StringAssert.StartsWith(string.Format("Zuilen berekening '{0}' voor waterstand '{1}' gestart om: ", calculation.Name, firstWaterLevel), msgs[3]); + StringAssert.StartsWith(string.Format("Zuilen berekening '{0}' voor waterstand '{1}' beëindigd om: ", calculation.Name, firstWaterLevel), msgs[4]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[5]); + }); + + Assert.AreEqual(ActivityState.Canceled, activity.State); + } + } + + [Test] public void OnFinish_CalculationPerformed_SetsOutput() { // Setup