Index: Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs =================================================================== diff -u -r504dee06516e9e4eae43575eb3f519277baf2bfe -r58b5de6b72dc5d4667443069317f03930206f1d3 --- Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision 504dee06516e9e4eae43575eb3f519277baf2bfe) +++ Ringtoets/Piping/test/Ringtoets.Piping.Service.Test/PipingCalculationServiceTest.cs (.../PipingCalculationServiceTest.cs) (revision 58b5de6b72dc5d4667443069317f03930206f1d3) @@ -25,13 +25,15 @@ using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; +using log4net.Core; using NUnit.Framework; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Service.TestUtil; using Ringtoets.Piping.Data; using Ringtoets.Piping.Data.SoilProfile; using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.KernelWrapper; using Ringtoets.Piping.KernelWrapper.SubCalculator; using Ringtoets.Piping.KernelWrapper.TestUtil.SubCalculator; using Ringtoets.Piping.Primitives; @@ -964,6 +966,51 @@ } [Test] + public void Calculate_ErrorWhileCalculating_LogErrorMessageAndThrowException() + { + // Setup + using (new PipingSubCalculatorFactoryConfig()) + { + var calculatorFactory = (TestPipingSubCalculatorFactory) PipingSubCalculatorFactory.Instance; + calculatorFactory.LastCreatedUpliftCalculator.ThrowExceptionOnCalculate = true; + + var exceptionThrown = false; + + // Call + Action call = () => + { + try + { + PipingCalculationService.Calculate(testCalculation, AssessmentSectionHelper.GetTestAssessmentLevel()); + } + catch (Exception) + { + exceptionThrown = true; + } + }; + + // Assert + TestHelper.AssertLogMessagesWithLevelAndLoggedExceptions(call, tuples => + { + Tuple[] messages = tuples as Tuple[] ?? tuples.ToArray(); + Assert.AreEqual(3, messages.Length); + + CalculationServiceTestHelper.AssertCalculationStartMessage(messages[0].Item1); + + Tuple tuple1 = messages[1]; + Assert.AreEqual("Er is een onverwachte fout opgetreden tijdens het uitvoeren van de berekening.", tuple1.Item1); + Assert.AreEqual(Level.Error, tuple1.Item2); + Assert.IsInstanceOf(tuple1.Item3); + + CalculationServiceTestHelper.AssertCalculationEndMessage(messages[2].Item1); + }); + + Assert.IsTrue(exceptionThrown); + Assert.IsNull(testCalculation.Output); + } + } + + [Test] public void Calculate_ValidPipingCalculation_LogStartAndEndOfCalculation() { // Call