Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs =================================================================== diff -u -r1d64c85fa6d013812d3f38fa09ae4e7ec82480fe -re07044ef611f4a005447703ffba9f24b7c5acb90 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs (.../StabilityStoneCoverWaveConditionsCalculationServiceTest.cs) (revision 1d64c85fa6d013812d3f38fa09ae4e7ec82480fe) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Service.Test/StabilityStoneCoverWaveConditionsCalculationServiceTest.cs (.../StabilityStoneCoverWaveConditionsCalculationServiceTest.cs) (revision e07044ef611f4a005447703ffba9f24b7c5acb90) @@ -533,7 +533,9 @@ { // Call new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, - assessmentSectionStub, stabilityStoneCoverFailureMechanism.GeneralInput, validFilePath); + assessmentSectionStub, + stabilityStoneCoverFailureMechanism.GeneralInput, + validFilePath); // Assert Assert.IsNotNull(calculation.Output); @@ -544,6 +546,104 @@ } [Test] + public void Calculate_CalculationFailedWithExceptionAndLastErrorPresent_ExceptionThrown() + { + // Setup + var failureMechanism = new StabilityStoneCoverFailureMechanism + { + Contribution = 20 + }; + + var mockRepository = new MockRepository(); + var assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase(failureMechanism, mockRepository); + mockRepository.ReplayAll(); + + StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(); + + using (new HydraRingCalculatorFactoryConfig()) + { + var calculator = ((TestHydraRingCalculatorFactory)HydraRingCalculatorFactory.Instance).WaveConditionsCosineCalculator; + calculator.LastErrorContent = "An error occured"; + calculator.EndInFailure = true; + + // Call + TestDelegate call = () => new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, + assessmentSectionStub, + failureMechanism.GeneralInput, + testDataPath); + + // Assert + Assert.Throws(call); + } + } + + [Test] + public void Calculate_CalculationFailedWithExceptionAndNoLastErrorPresent_ExceptionThrown() + { + // Setup + var failureMechanism = new StabilityStoneCoverFailureMechanism + { + Contribution = 20 + }; + + var mockRepository = new MockRepository(); + IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository); + mockRepository.ReplayAll(); + + StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(); + + using (new HydraRingCalculatorFactoryConfig()) + { + var calculator = ((TestHydraRingCalculatorFactory)HydraRingCalculatorFactory.Instance).WaveConditionsCosineCalculator; + calculator.EndInFailure = true; + + // Call + TestDelegate call = () => new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, + assessmentSectionStub, + failureMechanism.GeneralInput, + testDataPath); + + // Assert + Assert.Throws(call); + } + } + + [Test] + public void Calculate_CalculationFailedWithoutExceptionAndWithLastErrorPresent_LogErrorAndThrowException() + { + // Setup + var failureMechanism = new StabilityStoneCoverFailureMechanism + { + Contribution = 20 + }; + + var mockRepository = new MockRepository(); + IAssessmentSection assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(failureMechanism, + mockRepository); + mockRepository.ReplayAll(); + + StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(); + + using (new HydraRingCalculatorFactoryConfig()) + { + var calculator = ((TestHydraRingCalculatorFactory)HydraRingCalculatorFactory.Instance).WaveConditionsCosineCalculator; + calculator.EndInFailure = false; + calculator.LastErrorContent = "An error occured"; + + // Call + TestDelegate call = () => new StabilityStoneCoverWaveConditionsCalculationService().Calculate(calculation, + assessmentSectionStub, + failureMechanism.GeneralInput, + testDataPath); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual(calculator.LastErrorContent, exception.Message); + } + } + + [Test] public void Calculate_InnerCalculationFails_ThrowsException() { // Setup