Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil.Test/SubCalculator/UpliftCalculatorStubTest.cs =================================================================== diff -u -r85fcfb3e47d742a46200fcfb93f7cd4b155b9a94 -r913ebbe5aaf7355a6242dfb4a3168a7c6ff98d36 --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil.Test/SubCalculator/UpliftCalculatorStubTest.cs (.../UpliftCalculatorStubTest.cs) (revision 85fcfb3e47d742a46200fcfb93f7cd4b155b9a94) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil.Test/SubCalculator/UpliftCalculatorStubTest.cs (.../UpliftCalculatorStubTest.cs) (revision 913ebbe5aaf7355a6242dfb4a3168a7c6ff98d36) @@ -19,7 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; +using Deltares.WTIPiping; using NUnit.Framework; using Ringtoets.Piping.KernelWrapper.TestUtil.SubCalculator; @@ -35,6 +37,7 @@ var upliftCalculator = new UpliftCalculatorStub(); // Assert + Assert.IsFalse(upliftCalculator.ThrowExceptionOnCalculate); Assert.AreEqual(0, upliftCalculator.EffectiveStress); Assert.AreEqual(0, upliftCalculator.HExit); Assert.AreEqual(0, upliftCalculator.HRiver); @@ -43,7 +46,6 @@ Assert.AreEqual(0, upliftCalculator.PhiPolder); Assert.AreEqual(0, upliftCalculator.RExit); Assert.AreEqual(0, upliftCalculator.VolumetricWeightOfWater); - Assert.AreEqual(0, upliftCalculator.FoSu); Assert.AreEqual(0, upliftCalculator.Zu); } @@ -74,5 +76,24 @@ // Assert Assert.IsTrue(upliftCalculator.Calculated); } + + [Test] + public void Calculate_ThrowExceptionOnCalculateTrue_ThrowWTIUpliftCalculatorException() + { + // Setup + var upliftCalculator = new UpliftCalculatorStub + { + ThrowExceptionOnCalculate = true + }; + + // Call + TestDelegate test = () => upliftCalculator.Calculate(); + + // Assert + var exception = Assert.Throws(test); + Assert.IsNull(exception.InnerException); + Assert.AreEqual($"Message 1{Environment.NewLine}Message 2", exception.Message); + Assert.IsFalse(upliftCalculator.Calculated); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/SubCalculator/UpliftCalculatorStub.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r913ebbe5aaf7355a6242dfb4a3168a7c6ff98d36 --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/SubCalculator/UpliftCalculatorStub.cs (.../UpliftCalculatorStub.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/SubCalculator/UpliftCalculatorStub.cs (.../UpliftCalculatorStub.cs) (revision 913ebbe5aaf7355a6242dfb4a3168a7c6ff98d36) @@ -19,7 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; +using Deltares.WTIPiping; using Ringtoets.Piping.KernelWrapper.SubCalculator; namespace Ringtoets.Piping.KernelWrapper.TestUtil.SubCalculator @@ -39,6 +41,11 @@ /// public bool Validated { get; private set; } + /// + /// Indicator whether an exception must be thrown when performing the calculation. + /// + public bool ThrowExceptionOnCalculate { get; set; } + public double EffectiveStress { get; set; } public double HExit { get; set; } public double HRiver { get; set; } @@ -52,6 +59,11 @@ public void Calculate() { + if (ThrowExceptionOnCalculate) + { + throw new WTIUpliftCalculatorException($"Message 1{Environment.NewLine}Message 2"); + } + Calculated = true; }