Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs =================================================================== diff -u -r736f04ea6f24399148ab8efd7f3b03ae8f8f56b5 -r7044ef7d789aec3c3d9dd2c6f38b3699bea0444b --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs (.../ClosingStructuresCalculationServiceTest.cs) (revision 736f04ea6f24399148ab8efd7f3b03ae8f8f56b5) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Service.Test/ClosingStructuresCalculationServiceTest.cs (.../ClosingStructuresCalculationServiceTest.cs) (revision 7044ef7d789aec3c3d9dd2c6f38b3699bea0444b) @@ -1138,6 +1138,7 @@ }); Assert.IsTrue(exceptionThrown); Assert.IsNull(calculation.Output); + Assert.AreEqual(calculator.LastErrorFileContent, exceptionMessage); } mockRepository.VerifyAll(); } Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs =================================================================== diff -u -r736f04ea6f24399148ab8efd7f3b03ae8f8f56b5 -r7044ef7d789aec3c3d9dd2c6f38b3699bea0444b --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 736f04ea6f24399148ab8efd7f3b03ae8f8f56b5) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/DesignWaterLevelCalculationServiceTest.cs (.../DesignWaterLevelCalculationServiceTest.cs) (revision 7044ef7d789aec3c3d9dd2c6f38b3699bea0444b) @@ -176,7 +176,7 @@ // Assert AssessmentLevelCalculationInput expectedInput = CreateInput(hydraulicBoundaryLocation, norm); - AssertInput(expectedInput, calculator.ReceivedInputs.First()); + AssertInput(expectedInput, calculator.ReceivedInputs.Single()); Assert.IsFalse(calculator.IsCanceled); } mockRepository.VerifyAll(); Index: Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs =================================================================== diff -u -r736f04ea6f24399148ab8efd7f3b03ae8f8f56b5 -r7044ef7d789aec3c3d9dd2c6f38b3699bea0444b --- Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision 736f04ea6f24399148ab8efd7f3b03ae8f8f56b5) +++ Ringtoets/Common/test/Ringtoets.Common.Service.Test/WaveHeightCalculationServiceTest.cs (.../WaveHeightCalculationServiceTest.cs) (revision 7044ef7d789aec3c3d9dd2c6f38b3699bea0444b) @@ -175,7 +175,7 @@ // Assert AssessmentLevelCalculationInput expectedInput = CreateInput(hydraulicBoundaryLocation, norm); - AssertInput(expectedInput, calculator.ReceivedInputs.First()); + AssertInput(expectedInput, calculator.ReceivedInputs.Single()); Assert.IsFalse(calculator.IsCanceled); } mockRepository.VerifyAll(); Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneErosionBoundaryCalculationServiceTest.cs =================================================================== diff -u -r736f04ea6f24399148ab8efd7f3b03ae8f8f56b5 -r7044ef7d789aec3c3d9dd2c6f38b3699bea0444b --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneErosionBoundaryCalculationServiceTest.cs (.../DuneErosionBoundaryCalculationServiceTest.cs) (revision 736f04ea6f24399148ab8efd7f3b03ae8f8f56b5) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Service.Test/DuneErosionBoundaryCalculationServiceTest.cs (.../DuneErosionBoundaryCalculationServiceTest.cs) (revision 7044ef7d789aec3c3d9dd2c6f38b3699bea0444b) @@ -497,6 +497,7 @@ }); Assert.IsTrue(exceptionThrown); Assert.IsNull(duneLocation.Output); + Assert.AreEqual(calculator.LastErrorFileContent, exceptionMessage); } mockRepository.VerifyAll(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs =================================================================== diff -u -r736f04ea6f24399148ab8efd7f3b03ae8f8f56b5 -r7044ef7d789aec3c3d9dd2c6f38b3699bea0444b --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs (.../GrassCoverErosionInwardsCalculationServiceTest.cs) (revision 736f04ea6f24399148ab8efd7f3b03ae8f8f56b5) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs (.../GrassCoverErosionInwardsCalculationServiceTest.cs) (revision 7044ef7d789aec3c3d9dd2c6f38b3699bea0444b) @@ -1050,7 +1050,7 @@ var overtoppingCalculator = new TestOvertoppingCalculator { LastErrorFileContent = "An error occurred", - EndInFailure = true + EndInFailure = false }; var calculatorFactory = mockRepository.StrictMock(); calculatorFactory.Expect(cf => cf.CreateOvertoppingCalculator(testDataPath)).Return(overtoppingCalculator); @@ -1069,7 +1069,7 @@ using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) { - var exceptionThrown = false; + HydraRingCalculationException exception = null; // Call Action call = () => @@ -1082,9 +1082,9 @@ failureMechanism.Contribution, validFile); } - catch (HydraRingCalculationException) + catch (HydraRingCalculationException e) { - exceptionThrown = true; + exception = e; } }; @@ -1098,8 +1098,9 @@ StringAssert.StartsWith("De overloop en overslag berekening is uitgevoerd op de tijdelijke locatie", msgs[2]); Assert.AreEqual($"Berekening van '{calculation.Name}' beëindigd.", msgs[3]); }); - Assert.IsTrue(exceptionThrown); + Assert.IsInstanceOf(exception); Assert.IsNull(calculation.Output); + Assert.AreEqual(overtoppingCalculator.LastErrorFileContent, exception.Message); } } @@ -1258,7 +1259,8 @@ validFile); var dikeHeightCalculator = new TestHydraulicLoadsCalculator { - LastErrorFileContent = "An error occurred" + LastErrorFileContent = "An error occurred", + EndInFailure = false }; var calculatorFactory = mockRepository.StrictMock(); calculatorFactory.Expect(cf => cf.CreateOvertoppingCalculator(testDataPath)).Return(new TestOvertoppingCalculator()); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Service.Test/GrassCoverErosionOutwardsWaveConditionsCalculationServiceTest.cs =================================================================== diff -u -r736f04ea6f24399148ab8efd7f3b03ae8f8f56b5 -r7044ef7d789aec3c3d9dd2c6f38b3699bea0444b --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Service.Test/GrassCoverErosionOutwardsWaveConditionsCalculationServiceTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationServiceTest.cs) (revision 736f04ea6f24399148ab8efd7f3b03ae8f8f56b5) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Service.Test/GrassCoverErosionOutwardsWaveConditionsCalculationServiceTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationServiceTest.cs) (revision 7044ef7d789aec3c3d9dd2c6f38b3699bea0444b) @@ -667,7 +667,10 @@ var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)).Return(calculatorThatFails).Repeat.Times(3); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(calculatorThatFails) + .Repeat + .Times(3); IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, mockRepository); mockRepository.ReplayAll(); @@ -732,6 +735,93 @@ mockRepository.VerifyAll(); } + [Test] + [TestCaseSource(typeof(WaveConditionsCosineCalculatorTestHelper), nameof(WaveConditionsCosineCalculatorTestHelper.FailingWaveConditionsCosineCalculators))] + public void Calculate_OneOutOfThreeCalculationsFails_ReturnsOutputsAndLogError(TestWaveConditionsCosineCalculator calculatorThatFails, + string detailedReport) + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + Contribution = 20 + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.StrictMock(); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(calculatorThatFails); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(new TestWaveConditionsCosineCalculator()) + .Repeat + .Twice(); + IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository); + mockRepository.ReplayAll(); + + GrassCoverErosionOutwardsWaveConditionsCalculation calculation = GetValidCalculation(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + // Call + Action call = () => + { + new GrassCoverErosionOutwardsWaveConditionsCalculationService().Calculate(calculation, + failureMechanism, + assessmentSectionStub, + validFilePath); + }; + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(12, msgs.Length); + + Assert.AreEqual($"Berekening van '{calculation.Name}' gestart.", msgs[0]); + + RoundedDouble[] waterLevels = calculation.InputParameters.WaterLevels.ToArray(); + RoundedDouble waterLevelUpperBoundaryRevetment = waterLevels[0]; + RoundedDouble waterLevelMiddleRevetment = waterLevels[1]; + RoundedDouble waterLevelLowerBoundaryRevetment = waterLevels[2]; + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelUpperBoundaryRevetment}' gestart.", msgs[1]); + Assert.AreEqual($"Berekening '{calculation.Name}' is mislukt voor waterstand '{waterLevelUpperBoundaryRevetment}'. {detailedReport}", msgs[2]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[3]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelUpperBoundaryRevetment}' beëindigd.", msgs[4]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelMiddleRevetment}' gestart.", msgs[5]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[6]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelMiddleRevetment}' beëindigd.", msgs[7]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelLowerBoundaryRevetment}' gestart.", msgs[8]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[9]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelLowerBoundaryRevetment}' beëindigd.", msgs[10]); + + Assert.AreEqual($"Berekening van '{calculation.Name}' beëindigd.", msgs[11]); + }); + + WaveConditionsOutput[] waveConditionsOutputs = calculation.Output.Items.ToArray(); + Assert.AreEqual(3, waveConditionsOutputs.Length); + AssertFailedCalculationOutput(waveConditionsOutputs[0]); + } + mockRepository.VerifyAll(); + } + + private static void AssertFailedCalculationOutput(WaveConditionsOutput actual) + { + Assert.IsNotNull(actual); + Assert.AreEqual(RoundedDouble.NaN, actual.WaterLevel); + Assert.AreEqual(RoundedDouble.NaN, actual.WaveHeight); + Assert.AreEqual(RoundedDouble.NaN, actual.WavePeakPeriod); + Assert.AreEqual(RoundedDouble.NaN, actual.WaveAngle); + Assert.AreEqual(RoundedDouble.NaN, actual.WaveDirection); + Assert.AreEqual(double.NaN, actual.TargetProbability); + Assert.AreEqual(RoundedDouble.NaN, actual.TargetReliability); + Assert.AreEqual(double.NaN, actual.CalculatedProbability); + Assert.AreEqual(RoundedDouble.NaN, actual.CalculatedReliability); + Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, actual.CalculationConvergence); + } + private static GrassCoverErosionOutwardsWaveConditionsCalculation GetValidCalculation() { var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/Calculator/TestHydraRingCalculatorFactory.cs =================================================================== diff -u -rb7ce4e17d62bcc006615bb14f4f91030831cdb79 -r7044ef7d789aec3c3d9dd2c6f38b3699bea0444b --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/Calculator/TestHydraRingCalculatorFactory.cs (.../TestHydraRingCalculatorFactory.cs) (revision b7ce4e17d62bcc006615bb14f4f91030831cdb79) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/Calculator/TestHydraRingCalculatorFactory.cs (.../TestHydraRingCalculatorFactory.cs) (revision 7044ef7d789aec3c3d9dd2c6f38b3699bea0444b) @@ -114,7 +114,6 @@ { public readonly List ReceivedInputs = new List(); public event EventHandler CalculationFinishedHandler; - public string HydraulicBoundaryDatabaseDirectory { get; set; } public bool EndInFailure { get; set; } public bool IsCanceled { get; set; } Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs =================================================================== diff -u -r736f04ea6f24399148ab8efd7f3b03ae8f8f56b5 -r7044ef7d789aec3c3d9dd2c6f38b3699bea0444b --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs (.../StabilityStoneCoverWaveConditionsCalculationServiceTest.cs) (revision 736f04ea6f24399148ab8efd7f3b03ae8f8f56b5) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs (.../StabilityStoneCoverWaveConditionsCalculationServiceTest.cs) (revision 7044ef7d789aec3c3d9dd2c6f38b3699bea0444b) @@ -28,6 +28,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data; @@ -485,7 +486,6 @@ Assert.AreEqual(18, msgs.Length); Assert.AreEqual($"Berekening van '{calculation.Name}' gestart.", msgs[0]); - Assert.AreEqual($"Berekening '{calculation.Name}' voor blokken gestart.", msgs[1]); var i = 2; @@ -795,6 +795,201 @@ mockRepository.VerifyAll(); } + [Test] + [TestCaseSource(typeof(WaveConditionsCosineCalculatorTestHelper), nameof(WaveConditionsCosineCalculatorTestHelper.FailingWaveConditionsCosineCalculators))] + public void Calculate_OneOutOfThreeBlocksCalculationsFails_ReturnsOutputsAndLogError(TestWaveConditionsCosineCalculator calculatorThatFails, + string detailedReport) + { + // Setup + var failureMechanism = new StabilityStoneCoverFailureMechanism + { + Contribution = 20 + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.Stub(); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(calculatorThatFails); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(new TestWaveConditionsCosineCalculator()) + .Repeat + .Times(5); + + IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( + failureMechanism, mockRepository); + mockRepository.ReplayAll(); + + StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + var service = new StabilityStoneCoverWaveConditionsCalculationService(); + + // Call + Action call = () => service.Calculate(calculation, + assessmentSectionStub, + failureMechanism.GeneralInput, + validFilePath); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(25, msgs.Length); + + RoundedDouble[] waterLevels = calculation.InputParameters.WaterLevels.ToArray(); + RoundedDouble waterLevelUpperBoundaryRevetment = waterLevels[0]; + RoundedDouble waterLevelMiddleRevetment = waterLevels[1]; + RoundedDouble waterLevelLowerBoundaryRevetment = waterLevels[2]; + + Assert.AreEqual($"Berekening van '{calculation.Name}' gestart.", msgs[0]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor blokken gestart.", msgs[1]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelUpperBoundaryRevetment}' gestart.", msgs[2]); + Assert.AreEqual($"Berekening '{calculation.Name}' is mislukt voor waterstand '{waterLevelUpperBoundaryRevetment}'. {detailedReport}", msgs[3]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[4]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelUpperBoundaryRevetment}' beëindigd.", msgs[5]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelMiddleRevetment}' gestart.", msgs[6]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[7]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelMiddleRevetment}' beëindigd.", msgs[8]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelLowerBoundaryRevetment}' gestart.", msgs[9]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[10]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelLowerBoundaryRevetment}' beëindigd.", msgs[11]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor blokken beëindigd.", msgs[12]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor zuilen gestart.", msgs[13]); + + var i = 14; + foreach (RoundedDouble waterLevel in calculation.InputParameters.WaterLevels) + { + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevel}' gestart.", msgs[i++]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[i++]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevel}' beëindigd.", msgs[i++]); + } + + Assert.AreEqual($"Berekening '{calculation.Name}' voor zuilen beëindigd.", msgs[23]); + Assert.AreEqual($"Berekening van '{calculation.Name}' beëindigd.", msgs[24]); + }); + + WaveConditionsOutput[] blocksWaveConditionsOutputs = calculation.Output.BlocksOutput.ToArray(); + Assert.AreEqual(3, blocksWaveConditionsOutputs.Length); + AssertFailedCalculationOutput(blocksWaveConditionsOutputs[0]); + + WaveConditionsOutput[] columnsWaveConditionsOutputs = calculation.Output.ColumnsOutput.ToArray(); + Assert.AreEqual(3, columnsWaveConditionsOutputs.Length); + } + mockRepository.VerifyAll(); + } + + [Test] + [TestCaseSource(typeof(WaveConditionsCosineCalculatorTestHelper), nameof(WaveConditionsCosineCalculatorTestHelper.FailingWaveConditionsCosineCalculators))] + public void Calculate_OneOutOfThreeColumnsCalculationsFails_ReturnsOutputsAndLogError(TestWaveConditionsCosineCalculator calculatorThatFails, + string detailedReport) + { + // Setup + var failureMechanism = new StabilityStoneCoverFailureMechanism + { + Contribution = 20 + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.Stub(); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(new TestWaveConditionsCosineCalculator()) + .Repeat + .Times(3); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(calculatorThatFails); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(new TestWaveConditionsCosineCalculator()) + .Repeat + .Twice(); + + IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( + failureMechanism, mockRepository); + mockRepository.ReplayAll(); + + StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + var service = new StabilityStoneCoverWaveConditionsCalculationService(); + + // Call + Action call = () => service.Calculate(calculation, + assessmentSectionStub, + failureMechanism.GeneralInput, + validFilePath); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(25, msgs.Length); + + Assert.AreEqual($"Berekening van '{calculation.Name}' gestart.", msgs[0]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor blokken gestart.", msgs[1]); + + var i = 2; + foreach (RoundedDouble waterLevel in calculation.InputParameters.WaterLevels) + { + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevel}' gestart.", msgs[i++]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[i++]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevel}' beëindigd.", msgs[i++]); + } + + Assert.AreEqual($"Berekening '{calculation.Name}' voor blokken beëindigd.", msgs[11]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor zuilen gestart.", msgs[12]); + + RoundedDouble[] waterLevels = calculation.InputParameters.WaterLevels.ToArray(); + RoundedDouble waterLevelUpperBoundaryRevetment = waterLevels[0]; + RoundedDouble waterLevelMiddleRevetment = waterLevels[1]; + RoundedDouble waterLevelLowerBoundaryRevetment = waterLevels[2]; + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelUpperBoundaryRevetment}' gestart.", msgs[13]); + Assert.AreEqual($"Berekening '{calculation.Name}' is mislukt voor waterstand '{waterLevelUpperBoundaryRevetment}'. {detailedReport}", msgs[14]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[15]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelUpperBoundaryRevetment}' beëindigd.", msgs[16]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelMiddleRevetment}' gestart.", msgs[17]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[18]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelMiddleRevetment}' beëindigd.", msgs[19]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelLowerBoundaryRevetment}' gestart.", msgs[20]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[21]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelLowerBoundaryRevetment}' beëindigd.", msgs[22]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor zuilen beëindigd.", msgs[23]); + Assert.AreEqual($"Berekening van '{calculation.Name}' beëindigd.", msgs[24]); + }); + + WaveConditionsOutput[] blocksWaveConditionsOutputs = calculation.Output.BlocksOutput.ToArray(); + Assert.AreEqual(3, blocksWaveConditionsOutputs.Length); + + WaveConditionsOutput[] columnsWaveConditionsOutputs = calculation.Output.ColumnsOutput.ToArray(); + Assert.AreEqual(3, columnsWaveConditionsOutputs.Length); + AssertFailedCalculationOutput(columnsWaveConditionsOutputs[0]); + } + mockRepository.VerifyAll(); + } + + private static void AssertFailedCalculationOutput(WaveConditionsOutput actual) + { + Assert.IsNotNull(actual); + Assert.AreEqual(RoundedDouble.NaN, actual.WaterLevel); + Assert.AreEqual(RoundedDouble.NaN, actual.WaveHeight); + Assert.AreEqual(RoundedDouble.NaN, actual.WavePeakPeriod); + Assert.AreEqual(RoundedDouble.NaN, actual.WaveAngle); + Assert.AreEqual(RoundedDouble.NaN, actual.WaveDirection); + Assert.AreEqual(double.NaN, actual.TargetProbability); + Assert.AreEqual(RoundedDouble.NaN, actual.TargetReliability); + Assert.AreEqual(double.NaN, actual.CalculatedProbability); + Assert.AreEqual(RoundedDouble.NaN, actual.CalculatedReliability); + Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, actual.CalculationConvergence); + } + private static StabilityStoneCoverWaveConditionsCalculation GetValidCalculation() { return new StabilityStoneCoverWaveConditionsCalculation Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Service.Test/WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs =================================================================== diff -u -r736f04ea6f24399148ab8efd7f3b03ae8f8f56b5 -r7044ef7d789aec3c3d9dd2c6f38b3699bea0444b --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Service.Test/WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs) (revision 736f04ea6f24399148ab8efd7f3b03ae8f8f56b5) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Service.Test/WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationServiceTest.cs) (revision 7044ef7d789aec3c3d9dd2c6f38b3699bea0444b) @@ -28,6 +28,7 @@ using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.Data; @@ -652,8 +653,12 @@ var mockRepository = new MockRepository(); var calculatorFactory = mockRepository.StrictMock(); - calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)).Return(calculatorThatFails).Repeat.Times(3); - IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase(failureMechanism, mockRepository); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(calculatorThatFails) + .Repeat + .Times(3); + IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( + failureMechanism, mockRepository); mockRepository.ReplayAll(); WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetValidCalculation(); @@ -683,7 +688,7 @@ TestHelper.AssertLogMessages(call, messages => { string[] msgs = messages.ToArray(); - // Assert.AreEqual(15, msgs.Length); + Assert.AreEqual(15, msgs.Length); Assert.AreEqual($"Berekening van '{calculation.Name}' gestart.", msgs[0]); @@ -717,6 +722,94 @@ mockRepository.VerifyAll(); } + [Test] + [TestCaseSource(typeof(WaveConditionsCosineCalculatorTestHelper), nameof(WaveConditionsCosineCalculatorTestHelper.FailingWaveConditionsCosineCalculators))] + public void Calculate_OneOutOfThreeCalculationsFails_ReturnsOutputsAndLogError(TestWaveConditionsCosineCalculator calculatorThatFails, + string detailedReport) + { + // Setup + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism + { + Contribution = 20 + }; + + var mockRepository = new MockRepository(); + var calculatorFactory = mockRepository.Stub(); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(calculatorThatFails); + calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(testDataPath)) + .Return(new TestWaveConditionsCosineCalculator()) + .Repeat + .Twice(); + + IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( + failureMechanism, mockRepository); + mockRepository.ReplayAll(); + + WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetValidCalculation(); + + using (new HydraRingCalculatorFactoryConfig(calculatorFactory)) + { + var service = new WaveImpactAsphaltCoverWaveConditionsCalculationService(); + + // Call + Action call = () => service.Calculate(calculation, + assessmentSectionStub, + failureMechanism.GeneralInput, + validFilePath); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(12, msgs.Length); + + RoundedDouble[] waterLevels = calculation.InputParameters.WaterLevels.ToArray(); + RoundedDouble waterLevelUpperBoundaryRevetment = waterLevels[0]; + RoundedDouble waterLevelMiddleRevetment = waterLevels[1]; + RoundedDouble waterLevelLowerBoundaryRevetment = waterLevels[2]; + + Assert.AreEqual($"Berekening van '{calculation.Name}' gestart.", msgs[0]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelUpperBoundaryRevetment}' gestart.", msgs[1]); + Assert.AreEqual($"Berekening '{calculation.Name}' is mislukt voor waterstand '{waterLevelUpperBoundaryRevetment}'. {detailedReport}", msgs[2]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[3]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelUpperBoundaryRevetment}' beëindigd.", msgs[4]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelMiddleRevetment}' gestart.", msgs[5]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[6]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelMiddleRevetment}' beëindigd.", msgs[7]); + + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelLowerBoundaryRevetment}' gestart.", msgs[8]); + StringAssert.StartsWith("Golfcondities berekening is uitgevoerd op de tijdelijke locatie", msgs[9]); + Assert.AreEqual($"Berekening '{calculation.Name}' voor waterstand '{waterLevelLowerBoundaryRevetment}' beëindigd.", msgs[10]); + + Assert.AreEqual($"Berekening van '{calculation.Name}' beëindigd.", msgs[11]); + }); + + WaveConditionsOutput[] waveConditionsOutputs = calculation.Output.Items.ToArray(); + Assert.AreEqual(3, waveConditionsOutputs.Length); + + AssertFailedCalculationOutput(waveConditionsOutputs[0]); + } + mockRepository.VerifyAll(); + } + + private static void AssertFailedCalculationOutput(WaveConditionsOutput actual) + { + Assert.IsNotNull(actual); + Assert.AreEqual(RoundedDouble.NaN, actual.WaterLevel); + Assert.AreEqual(RoundedDouble.NaN, actual.WaveHeight); + Assert.AreEqual(RoundedDouble.NaN, actual.WavePeakPeriod); + Assert.AreEqual(RoundedDouble.NaN, actual.WaveAngle); + Assert.AreEqual(RoundedDouble.NaN, actual.WaveDirection); + Assert.AreEqual(double.NaN, actual.TargetProbability); + Assert.AreEqual(RoundedDouble.NaN, actual.TargetReliability); + Assert.AreEqual(double.NaN, actual.CalculatedProbability); + Assert.AreEqual(RoundedDouble.NaN, actual.CalculatedReliability); + Assert.AreEqual(CalculationConvergence.CalculatedNotConverged, actual.CalculationConvergence); + } + private static WaveImpactAsphaltCoverWaveConditionsCalculation GetValidCalculation() { var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation