Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs
===================================================================
diff -u -rd553274ef37ce5c444dbc8a1d2c9ed359dd1af4c -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision d553274ef37ce5c444dbc8a1d2c9ed359dd1af4c)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -104,7 +104,7 @@
}
catch (UpliftVanKernelWrapperException e)
{
- throw new UpliftVanCalculatorException(e.Message, e);
+ throw new UpliftVanCalculatorException(e.Message, e, MacroStabilityInwardsKernelMessagesCreator.CreateFromLogMessages(e.LogMessages));
}
return upliftVanKernel;
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculatorException.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculatorException.cs (.../UpliftVanCalculatorException.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculatorException.cs (.../UpliftVanCalculatorException.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -20,6 +20,8 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Runtime.Serialization;
namespace Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan
@@ -53,6 +55,21 @@
public UpliftVanCalculatorException(string message, Exception inner) : base(message, inner) {}
///
+ /// Initializes a new instance of the class
+ /// with a specified error message and a reference to the inner exception that is
+ /// the cause of this exception.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception,
+ /// or a null reference if no inner exception is specified.
+ /// The messages provided by the kernel.
+ public UpliftVanCalculatorException(string message, Exception inner, IEnumerable kernelMessages)
+ : base(message, inner)
+ {
+ KernelMessages = kernelMessages;
+ }
+
+ ///
/// Initializes a new instance of with
/// serialized data.
/// The that holds the serialized
@@ -64,5 +81,10 @@
/// The class name is null or
/// is zero (0).
protected UpliftVanCalculatorException(SerializationInfo info, StreamingContext context) : base(info, context) {}
+
+ ///
+ /// Gets the kernel messages.
+ ///
+ public IEnumerable KernelMessages { get; } = Enumerable.Empty();
}
}
\ No newline at end of file
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs
===================================================================
diff -u -r6bc65102a16d453d3e9f031aac2827130eef2b38 -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs (.../UpliftVanKernelWrapper.cs) (revision 6bc65102a16d453d3e9f031aac2827130eef2b38)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs (.../UpliftVanKernelWrapper.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -23,7 +23,6 @@
using System.Collections.Generic;
using System.IO;
using System.Linq;
-using Core.Common.Util.Extensions;
using Deltares.MacroStability.Data;
using Deltares.MacroStability.Geometry;
using Deltares.MacroStability.Interface;
@@ -168,19 +167,20 @@
public void Calculate()
{
+ var kernelCalculation = new KernelCalculation();
+
try
{
- var kernelCalculation = new KernelCalculation();
kernelCalculation.Run(kernelModel);
WriteXmlFile();
- SetResults();
CalculationMessages = kernelCalculation.LogMessages ?? Enumerable.Empty();
+ SetResults();
}
catch (Exception e) when (!(e is UpliftVanKernelWrapperException))
{
- throw new UpliftVanKernelWrapperException(e.Message, e);
+ throw new UpliftVanKernelWrapperException(e.Message, e, CalculationMessages.Where(lm => lm.MessageType == LogMessageType.Error || lm.MessageType == LogMessageType.FatalError));
}
}
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapperException.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapperException.cs (.../UpliftVanKernelWrapperException.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapperException.cs (.../UpliftVanKernelWrapperException.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -20,7 +20,10 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
+using System.Linq;
using System.Runtime.Serialization;
+using Deltares.MacroStability.Standard;
namespace Riskeer.MacroStabilityInwards.KernelWrapper.Kernels.UpliftVan
{
@@ -53,6 +56,21 @@
public UpliftVanKernelWrapperException(string message, Exception inner) : base(message, inner) {}
///
+ /// Initializes a new instance of the class
+ /// with a specified error message and a reference to the inner exception that is
+ /// the cause of this exception.
+ ///
+ /// The error message that explains the reason for the exception.
+ /// The exception that is the cause of the current exception,
+ /// or a null reference if no inner exception is specified.
+ /// The messages provided by the kernel.
+ public UpliftVanKernelWrapperException(string message, Exception inner, IEnumerable logMessages)
+ : base(message, inner)
+ {
+ LogMessages = logMessages;
+ }
+
+ ///
/// Initializes a new instance of with
/// serialized data.
/// The that holds the serialized
@@ -64,5 +82,10 @@
/// The class name is null or
/// is zero (0).
protected UpliftVanKernelWrapperException(SerializationInfo info, StreamingContext context) : base(info, context) {}
+
+ ///
+ /// Gets the log messages.
+ ///
+ public IEnumerable LogMessages { get; } = Enumerable.Empty();
}
}
\ No newline at end of file
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs
===================================================================
diff -u -rd2c7d08b8a0b896ce33582cd9e67efe2a59d06da -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs (.../MacroStabilityInwardsCalculationService.cs) (revision d2c7d08b8a0b896ce33582cd9e67efe2a59d06da)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs (.../MacroStabilityInwardsCalculationService.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using System.Text;
using Core.Common.Base.Data;
using log4net;
using Riskeer.Common.Service;
@@ -149,7 +150,15 @@
}
catch (UpliftVanCalculatorException e)
{
- CalculationServiceHelper.LogExceptionAsError(RiskeerCommonServiceResources.CalculationService_Calculate_unexpected_error, e);
+ var stringBuilder = new StringBuilder();
+ stringBuilder.AppendLine(Resources.MacroStabilityInwardsCalculationService_Calculate_Kernel_provides_messages);
+
+ foreach (MacroStabilityInwardsKernelMessage kernelMessage in e.KernelMessages)
+ {
+ stringBuilder.AppendLine(string.Format(Resources.MacroStabilityInwardsCalculationService_Calculate_LogMessageType_0_LogMessage_1, kernelMessage.Type, kernelMessage.Message));
+ }
+
+ CalculationServiceHelper.LogExceptionAsError($"{RiskeerCommonServiceResources.CalculationService_Calculate_unexpected_error} {stringBuilder}", e);
CalculationServiceHelper.LogCalculationEnd();
throw;
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/Properties/Resources.Designer.cs
===================================================================
diff -u -r85f426aa7f7fcc6216c54f1cada6828dcefea862 -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 85f426aa7f7fcc6216c54f1cada6828dcefea862)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -92,6 +92,24 @@
}
///
+ /// Looks up a localized string similar to De kernel geeft de volgende meldingen:.
+ ///
+ internal static string MacroStabilityInwardsCalculationService_Calculate_Kernel_provides_messages {
+ get {
+ return ResourceManager.GetString("MacroStabilityInwardsCalculationService_Calculate_Kernel_provides_messages", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to [{0}] {1}.
+ ///
+ internal static string MacroStabilityInwardsCalculationService_Calculate_LogMessageType_0_LogMessage_1 {
+ get {
+ return ResourceManager.GetString("MacroStabilityInwardsCalculationService_Calculate_LogMessageType_0_LogMessage_1", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Er zijn een of meerdere waarschuwingsberichten. Klik op details voor meer informatie..
///
internal static string MacroStabilityInwardsCalculationService_Calculate_Warnings_in_MacroStabilityInwards_calculation {
Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/Properties/Resources.resx
===================================================================
diff -u -r85f426aa7f7fcc6216c54f1cada6828dcefea862 -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/Properties/Resources.resx (.../Resources.resx) (revision 85f426aa7f7fcc6216c54f1cada6828dcefea862)
+++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/Properties/Resources.resx (.../Resources.resx) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -153,4 +153,10 @@
Validatie van waterspanningen in dagelijkse omstandigheden is gestart.
+
+ De kernel geeft de volgende meldingen:
+
+
+ [{0}] {1}
+
\ No newline at end of file
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorExceptionTest.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorExceptionTest.cs (.../UpliftVanCalculatorExceptionTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorExceptionTest.cs (.../UpliftVanCalculatorExceptionTest.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -20,12 +20,39 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
+using System.Linq;
using Core.Common.TestUtil;
using NUnit.Framework;
+using Riskeer.MacroStabilityInwards.KernelWrapper.Calculators;
using Riskeer.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan;
namespace Riskeer.MacroStabilityInwards.KernelWrapper.Test.Calculators.UpliftVan
{
[TestFixture]
- public class UpliftVanCalculatorExceptionTest : CustomExceptionDesignGuidelinesTestFixture {}
+ public class UpliftVanCalculatorExceptionTest : CustomExceptionDesignGuidelinesTestFixture
+ {
+ [Test]
+ public void MessageAndInnerExceptionAndKernelMessagesConstructor_ExpectedValues()
+ {
+ // Setup
+ const string messageText = "Message";
+ var innerException = new Exception();
+ IEnumerable kernelMessages = Enumerable.Empty();
+
+ // Call
+ var exception = new UpliftVanCalculatorException(messageText, innerException, kernelMessages);
+
+ // Assert
+ Assert.IsInstanceOf(exception);
+ Assert.AreEqual(messageText, exception.Message);
+ Assert.IsNull(exception.HelpLink);
+ Assert.AreEqual(innerException, exception.InnerException);
+ Assert.IsNull(exception.Source);
+ Assert.IsNull(exception.StackTrace);
+ Assert.IsNull(exception.TargetSite);
+ CollectionAssert.IsEmpty(exception.Data);
+ Assert.AreSame(kernelMessages, exception.KernelMessages);
+ }
+ }
}
\ No newline at end of file
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs
===================================================================
diff -u -r81032dec3576239e5c912e62f05a61c50e108ac6 -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision 81032dec3576239e5c912e62f05a61c50e108ac6)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -247,10 +247,46 @@
var exception = Assert.Throws(Call);
Assert.IsInstanceOf(exception.InnerException);
Assert.AreEqual(exception.InnerException.Message, exception.Message);
+ CollectionAssert.IsEmpty(exception.KernelMessages);
}
}
[Test]
+ public void Calculate_KernelThrowsUpliftVanKernelWrapperExceptionWithLogMessages_ThrowUpliftVanCalculatorException()
+ {
+ // Setup
+ UpliftVanCalculatorInput input = CreateCompleteCalculatorInput();
+
+ using (new MacroStabilityInwardsKernelFactoryConfig())
+ {
+ var factory = (TestMacroStabilityInwardsKernelFactory) MacroStabilityInwardsKernelWrapperFactory.Instance;
+ UpliftVanKernelStub upliftVanKernel = factory.LastCreatedUpliftVanKernel;
+ upliftVanKernel.ThrowExceptionOnCalculate = true;
+ upliftVanKernel.ReturnLogMessages = true;
+
+ // Call
+ void Call() => new UpliftVanCalculator(input, factory).Calculate();
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.IsInstanceOf(exception.InnerException);
+ Assert.AreEqual(exception.InnerException.Message, exception.Message);
+
+ IEnumerable expectedMessages = GetSupportLogMessages(upliftVanKernel.CalculationMessages);
+ Assert.AreEqual(expectedMessages.Count(), exception.KernelMessages.Count());
+
+ for (var i = 0; i < expectedMessages.Count(); i++)
+ {
+ LogMessage upliftVanKernelCalculationMessage = expectedMessages.ElementAt(i);
+ MacroStabilityInwardsKernelMessage exceptionKernelMessage = exception.KernelMessages.ElementAt(i);
+
+ Assert.AreEqual(upliftVanKernelCalculationMessage.Message, exceptionKernelMessage.Message);
+ Assert.AreEqual(GetMessageType(upliftVanKernelCalculationMessage.MessageType), exceptionKernelMessage.Type);
+ }
+ }
+ }
+
+ [Test]
public void Validate_CalculatorWithValidInput_KernelValidateMethodCalled()
{
// Setup
@@ -296,7 +332,7 @@
// Call
IEnumerable kernelMessages = new UpliftVanCalculator(CreateCompleteCalculatorInput(),
- factory).Validate().ToList();
+ factory).Validate().ToList();
// Assert
Assert.AreEqual(2, kernelMessages.Count());
@@ -329,6 +365,25 @@
}
}
+ private static IEnumerable GetSupportLogMessages(IEnumerable messages)
+ {
+ return messages.Where(lm => lm.MessageType == LogMessageType.Error || lm.MessageType == LogMessageType.FatalError || lm.MessageType == LogMessageType.Warning);
+ }
+
+ private MacroStabilityInwardsKernelMessageType GetMessageType(LogMessageType logMessageType)
+ {
+ switch (logMessageType)
+ {
+ case LogMessageType.Error:
+ case LogMessageType.FatalError:
+ return MacroStabilityInwardsKernelMessageType.Error;
+ case LogMessageType.Warning:
+ return MacroStabilityInwardsKernelMessageType.Warning;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+
private static UpliftVanCalculatorInput CreateCompleteCalculatorInput()
{
var random = new Random(21);
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Kernels/UpliftVan/UpliftVanKernelWrapperExceptionTest.cs
===================================================================
diff -u -r86594ccd7329d320872573a1d066fe18959d3cea -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Kernels/UpliftVan/UpliftVanKernelWrapperExceptionTest.cs (.../UpliftVanKernelWrapperExceptionTest.cs) (revision 86594ccd7329d320872573a1d066fe18959d3cea)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.Test/Kernels/UpliftVan/UpliftVanKernelWrapperExceptionTest.cs (.../UpliftVanKernelWrapperExceptionTest.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -20,13 +20,40 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
+using System.Linq;
using Core.Common.TestUtil;
+using Deltares.MacroStability.Standard;
using NUnit.Framework;
using Riskeer.MacroStabilityInwards.KernelWrapper.Kernels.UpliftVan;
namespace Riskeer.MacroStabilityInwards.KernelWrapper.Test.Kernels.UpliftVan
{
[TestFixture]
public class UpliftVanKernelWrapperExceptionTest
- : CustomExceptionDesignGuidelinesTestFixture {}
+ : CustomExceptionDesignGuidelinesTestFixture
+ {
+ [Test]
+ public void MessageAndInnerExceptionAndKernelMessagesConstructor_ExpectedValues()
+ {
+ // Setup
+ const string messageText = "Message";
+ var innerException = new Exception();
+ IEnumerable logMessages = Enumerable.Empty();
+
+ // Call
+ var exception = new UpliftVanKernelWrapperException(messageText, innerException, logMessages);
+
+ // Assert
+ Assert.IsInstanceOf(exception);
+ Assert.AreEqual(messageText, exception.Message);
+ Assert.IsNull(exception.HelpLink);
+ Assert.AreEqual(innerException, exception.InnerException);
+ Assert.IsNull(exception.Source);
+ Assert.IsNull(exception.StackTrace);
+ Assert.IsNull(exception.TargetSite);
+ CollectionAssert.IsEmpty(exception.Data);
+ Assert.AreSame(logMessages, exception.LogMessages);
+ }
+ }
}
\ No newline at end of file
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/UpliftVan/UpliftVanCalculatorStub.cs
===================================================================
diff -u -r06e2edac81720cc78648214d048743f910edc686 -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/UpliftVan/UpliftVanCalculatorStub.cs (.../UpliftVanCalculatorStub.cs) (revision 06e2edac81720cc78648214d048743f910edc686)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/UpliftVan/UpliftVanCalculatorStub.cs (.../UpliftVanCalculatorStub.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -76,11 +76,6 @@
public UpliftVanCalculatorResult Calculate()
{
- if (ThrowExceptionOnCalculate)
- {
- throw new UpliftVanCalculatorException($"Message 1{Environment.NewLine}Message 2");
- }
-
var calculationMessages = new List();
if (ReturnCalculationError)
@@ -103,6 +98,11 @@
calculationMessages.Add(new MacroStabilityInwardsKernelMessage(MacroStabilityInwardsKernelMessageType.Warning, "Calculation Warning 2"));
}
+ if (ThrowExceptionOnCalculate)
+ {
+ throw new UpliftVanCalculatorException($"Message 1{Environment.NewLine}Message 2", null, calculationMessages);
+ }
+
return Output ?? (Output = CreateUpliftVanCalculatorResult(calculationMessages));
}
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/UpliftVanKernelStub.cs
===================================================================
diff -u -rca9e457de56679e8bdbba7953235b02543cbfac3 -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/UpliftVanKernelStub.cs (.../UpliftVanKernelStub.cs) (revision ca9e457de56679e8bdbba7953235b02543cbfac3)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/UpliftVanKernelStub.cs (.../UpliftVanKernelStub.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -218,11 +218,6 @@
public void Calculate()
{
- if (ThrowExceptionOnCalculate)
- {
- throw new UpliftVanKernelWrapperException($"Message 1{Environment.NewLine}Message 2", new Exception());
- }
-
if (ReturnLogMessages)
{
CalculationMessages = new[]
@@ -240,6 +235,11 @@
CalculationMessages = new LogMessage[0];
}
+ if (ThrowExceptionOnCalculate)
+ {
+ throw new UpliftVanKernelWrapperException($"Message 1{Environment.NewLine}Message 2", new Exception(), CalculationMessages);
+ }
+
Calculated = true;
}
Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs
===================================================================
diff -u -rd2c7d08b8a0b896ce33582cd9e67efe2a59d06da -rba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b
--- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision d2c7d08b8a0b896ce33582cd9e67efe2a59d06da)
+++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision ba564a2ca0ec7d9ad0c8e5bc2cf05abf4fd7f15b)
@@ -625,6 +625,7 @@
{
var calculatorFactory = (TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance;
calculatorFactory.LastCreatedUpliftVanCalculator.ThrowExceptionOnCalculate = true;
+ calculatorFactory.LastCreatedUpliftVanCalculator.ReturnCalculationError = true;
// Precondition
Assert.IsTrue(MacroStabilityInwardsCalculationService.Validate(testCalculation, normativeAssessmentLevel));
@@ -652,8 +653,12 @@
CalculationServiceTestHelper.AssertCalculationStartMessage(messages[0].Item1);
+ string expectedMessage = "Er is een onverwachte fout opgetreden tijdens het uitvoeren van de berekening. De kernel geeft de volgende meldingen:" + Environment.NewLine +
+ "[Error] Calculation Error 1" + Environment.NewLine +
+ "[Error] Calculation Error 2" + Environment.NewLine;
+
Tuple tuple1 = messages[1];
- Assert.AreEqual("Er is een onverwachte fout opgetreden tijdens het uitvoeren van de berekening.", tuple1.Item1);
+ Assert.AreEqual(expectedMessage, tuple1.Item1);
Assert.AreEqual(Level.Error, tuple1.Item2);
Assert.IsInstanceOf(tuple1.Item3);