Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/IUpliftVanCalculator.cs =================================================================== diff -u -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/IUpliftVanCalculator.cs (.../IUpliftVanCalculator.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/IUpliftVanCalculator.cs (.../IUpliftVanCalculator.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -47,9 +47,9 @@ /// /// Performs the validation. /// - /// An of . + /// An of . /// Thrown when an error /// occurs during the validation. - IEnumerable Validate(); + IEnumerable Validate(); } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/Output/UpliftVanCalculatorResult.cs =================================================================== diff -u -r6d704f970fe97f343fe3b567661a9789a4f44fd9 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/Output/UpliftVanCalculatorResult.cs (.../UpliftVanCalculatorResult.cs) (revision 6d704f970fe97f343fe3b567661a9789a4f44fd9) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/Output/UpliftVanCalculatorResult.cs (.../UpliftVanCalculatorResult.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan.Output { @@ -33,10 +34,12 @@ /// /// The sliding curve result. /// The calculation grid result. + /// The messages returned by the calculation. /// The container of the properties for the . /// Thrown when any parameter is null. internal UpliftVanCalculatorResult(UpliftVanSlidingCurveResult slidingCurveResult, UpliftVanCalculationGridResult calculationGridResult, + IEnumerable calculationMessages, ConstructionProperties properties) { if (slidingCurveResult == null) @@ -47,6 +50,10 @@ { throw new ArgumentNullException(nameof(calculationGridResult)); } + if (calculationMessages == null) + { + throw new ArgumentNullException(nameof(calculationMessages)); + } if (properties == null) { throw new ArgumentNullException(nameof(properties)); @@ -59,6 +66,8 @@ ZValue = properties.ZValue; ForbiddenZonesXEntryMin = properties.ForbiddenZonesXEntryMin; ForbiddenZonesXEntryMax = properties.ForbiddenZonesXEntryMax; + + CalculationMessages = calculationMessages; } /// @@ -130,6 +139,12 @@ /// public double ForbiddenZonesXEntryMax { get; } + /// + /// Gets the messages returned by the kernel during + /// the calculation. + /// + public IEnumerable CalculationMessages { get; } + #endregion } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs =================================================================== diff -u -r177a86fe2d7c3390004138070a95e52b6e3b13ae -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision 177a86fe2d7c3390004138070a95e52b6e3b13ae) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -63,30 +63,30 @@ this.factory = factory; } - public IEnumerable Validate() + public IEnumerable Validate() { try { IUpliftVanKernel upliftVanKernel = CreateUpliftVanKernel(); IEnumerable results = upliftVanKernel.Validate(); - var upliftVanValidationResults = new List(); + var upliftVanKernelMessages = new List(); foreach (ValidationResult result in results) { - UpliftVanValidationResultType type; + UpliftVanKernelMessageType type; switch (result.MessageType) { case ValidationResultType.Error: - type = UpliftVanValidationResultType.Error; + type = UpliftVanKernelMessageType.Error; break; case ValidationResultType.Warning: - type = UpliftVanValidationResultType.Warning; + type = UpliftVanKernelMessageType.Warning; break; default: continue; } - upliftVanValidationResults.Add(new UpliftVanValidationResult(type, result.Text)); + upliftVanKernelMessages.Add(new UpliftVanKernelMessage(type, result.Text)); } - return upliftVanValidationResults; + return upliftVanKernelMessages; } catch (UpliftVanKernelWrapperException e) { @@ -101,6 +101,7 @@ return new UpliftVanCalculatorResult( UpliftVanSlidingCurveResultCreator.Create(upliftVanKernel.SlidingCurveResult), UpliftVanCalculationGridResultCreator.Create(upliftVanKernel.SlipPlaneResult), + UpliftVanKernelMessagesCreator.Create(upliftVanKernel.CalculationMessages), new UpliftVanCalculatorResult.ConstructionProperties { FactorOfStability = upliftVanKernel.FactorOfStability, Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanKernelMessage.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanKernelMessage.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanKernelMessage.cs (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -0,0 +1,58 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan +{ + /// + /// Class representing a message returned by the Uplift Van kernel. + /// + public class UpliftVanKernelMessage + { + /// + /// Creates a new instance of . + /// + /// The type of the message. + /// The text of the message. + /// Thrown when + /// is null. + public UpliftVanKernelMessage(UpliftVanKernelMessageType type, string message) + { + if (message == null) + { + throw new ArgumentNullException(nameof(message)); + } + ResultType = type; + Message = message; + } + + /// + /// Gets the type of the message. + /// + public UpliftVanKernelMessageType ResultType { get; } + + /// + /// Gets the text of the message. + /// + public string Message { get; } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanKernelMessageType.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanKernelMessageType.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanKernelMessageType.cs (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -0,0 +1,32 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan +{ + /// + /// Indicates what log level an Uplift Van kernel message represents. + /// + public enum UpliftVanKernelMessageType + { + Warning = 1, + Error = 2 + } +} \ No newline at end of file Fisheye: Tag 72b12726b73e7e011bed836163635b64220c23f1 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanValidationResult.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 72b12726b73e7e011bed836163635b64220c23f1 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanValidationResultType.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/Output/UpliftVanKernelMessagesCreator.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/Output/UpliftVanKernelMessagesCreator.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/Output/UpliftVanKernelMessagesCreator.cs (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -0,0 +1,69 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Deltares.WTIStability.Data.Standard; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Output +{ + /// + /// Creates an of instances. + /// + internal static class UpliftVanKernelMessagesCreator + { + /// + /// Creates an of + /// based on the information given in the . + /// + /// The log messages to create the result for. + /// A new of with information + /// taken from the . + /// Thrown when + /// is null. + public static IEnumerable Create(IEnumerable logMessages) + { + if (logMessages == null) + { + throw new ArgumentNullException(nameof(logMessages)); + } + + foreach (LogMessage logMessage in logMessages) + { + UpliftVanKernelMessageType type; + switch (logMessage.MessageType) + { + case LogMessageType.Error: + case LogMessageType.FatalError: + type = UpliftVanKernelMessageType.Error; + break; + case LogMessageType.Warning: + type = UpliftVanKernelMessageType.Warning; + break; + default: + continue; + } + yield return new UpliftVanKernelMessage(type, logMessage.Message); + } + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/IUpliftVanKernel.cs =================================================================== diff -u -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/IUpliftVanKernel.cs (.../IUpliftVanKernel.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/IUpliftVanKernel.cs (.../IUpliftVanKernel.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -138,6 +138,12 @@ SlipPlaneUpliftVan SlipPlaneResult { get; } /// + /// Gets the messages returned by the kernel during + /// the calculation. + /// + IEnumerable CalculationMessages { get; } + + /// /// Performs the Uplift Van calculation. /// /// Thrown when Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs =================================================================== diff -u -r701b27e6e958f5f52706bf4eec3b1c35efde9f68 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs (.../UpliftVanKernelWrapper.cs) (revision 701b27e6e958f5f52706bf4eec3b1c35efde9f68) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs (.../UpliftVanKernelWrapper.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -21,7 +21,6 @@ using System; using System.Collections.Generic; -using System.Linq; using Deltares.WTIStability; using Deltares.WTIStability.Calculation.Wrapper; using Deltares.WTIStability.Data.Geo; @@ -181,6 +180,8 @@ public SlipPlaneUpliftVan SlipPlaneResult { get; private set; } + public IEnumerable CalculationMessages { get; private set; } + public void Calculate() { try @@ -225,19 +226,15 @@ { StabilityAssessmentCalculationResult convertedResult = WTIDeserializer.DeserializeResult(result); - if (convertedResult.Messages.Any()) - { - string message = convertedResult.Messages.Aggregate(string.Empty, (current, logMessage) => current + $"{logMessage}{Environment.NewLine}").Trim(); - throw new UpliftVanKernelWrapperException(message); - } - FactorOfStability = convertedResult.FactorOfSafety; ZValue = convertedResult.ZValue; ForbiddenZonesXEntryMin = convertedResult.XMinEntry; ForbiddenZonesXEntryMax = convertedResult.XMaxEntry; SlidingCurveResult = (SlidingDualCircle) convertedResult.Curve; SlipPlaneResult = convertedResult.SlipPlaneUpliftVan; + + CalculationMessages = convertedResult.Messages; } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj =================================================================== diff -u -r1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision 1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -56,8 +56,8 @@ - - + + @@ -85,6 +85,7 @@ + Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs =================================================================== diff -u -r24ef82baac0966895b34ff927c61e560509806a6 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs (.../MacroStabilityInwardsCalculationService.cs) (revision 24ef82baac0966895b34ff927c61e560509806a6) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs (.../MacroStabilityInwardsCalculationService.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -75,10 +75,10 @@ UpliftVanCalculatorInput upliftVanCalculatorInput = CreateInputFromData(calculation.InputParameters); IUpliftVanCalculator calculator = MacroStabilityInwardsCalculatorFactory.Instance.CreateUpliftVanCalculator(upliftVanCalculatorInput, MacroStabilityInwardsKernelWrapperFactory.Instance); - UpliftVanValidationResult[] validationResults; + UpliftVanKernelMessage[] kernelMessages; try { - validationResults = calculator.Validate().ToArray(); + kernelMessages = calculator.Validate().ToArray(); } catch (UpliftVanCalculatorException e) { @@ -87,13 +87,13 @@ return false; } - CalculationServiceHelper.LogMessagesAsError(validationResults.Where(msg => msg.ResultType == UpliftVanValidationResultType.Error) - .Select(msg => msg.Message).ToArray()); - CalculationServiceHelper.LogMessagesAsWarning(validationResults.Where(msg => msg.ResultType == UpliftVanValidationResultType.Warning) - .Select(msg => msg.Message).ToArray()); + CalculationServiceHelper.LogMessagesAsError(kernelMessages.Where(msg => msg.ResultType == UpliftVanKernelMessageType.Error) + .Select(msg => msg.Message).ToArray()); + CalculationServiceHelper.LogMessagesAsWarning(kernelMessages.Where(msg => msg.ResultType == UpliftVanKernelMessageType.Warning) + .Select(msg => msg.Message).ToArray()); CalculationServiceHelper.LogValidationEnd(); - return validationResults.All(r => r.ResultType != UpliftVanValidationResultType.Error); + return kernelMessages.All(r => r.ResultType != UpliftVanKernelMessageType.Error); } /// @@ -121,16 +121,36 @@ MacroStabilityInwardsKernelWrapperFactory.Instance); UpliftVanCalculatorResult macroStabilityInwardsResult = calculator.Calculate(); - calculation.Output = new MacroStabilityInwardsOutput( - MacroStabilityInwardsSlidingCurveConverter.Convert(macroStabilityInwardsResult.SlidingCurveResult), - MacroStabilityInwardsSlipPlaneUpliftVanConverter.Convert(macroStabilityInwardsResult.CalculationGridResult), - new MacroStabilityInwardsOutput.ConstructionProperties + if (macroStabilityInwardsResult.CalculationMessages.Count(cm => cm.ResultType == UpliftVanKernelMessageType.Error) == 0) + { + calculation.Output = new MacroStabilityInwardsOutput( + MacroStabilityInwardsSlidingCurveConverter.Convert(macroStabilityInwardsResult.SlidingCurveResult), + MacroStabilityInwardsSlipPlaneUpliftVanConverter.Convert(macroStabilityInwardsResult.CalculationGridResult), + new MacroStabilityInwardsOutput.ConstructionProperties + { + FactorOfStability = macroStabilityInwardsResult.FactorOfStability, + ZValue = macroStabilityInwardsResult.ZValue, + ForbiddenZonesXEntryMin = macroStabilityInwardsResult.ForbiddenZonesXEntryMin, + ForbiddenZonesXEntryMax = macroStabilityInwardsResult.ForbiddenZonesXEntryMax + }); + } + else + { + CalculationServiceHelper.LogMessagesAsError(macroStabilityInwardsResult.CalculationMessages + .Where(cm => cm.ResultType == UpliftVanKernelMessageType.Error) + .Select(cm => cm.Message).ToArray()); + } + + if (macroStabilityInwardsResult.CalculationMessages.Count(cm => cm.ResultType == UpliftVanKernelMessageType.Warning) > 0) + { + CalculationServiceHelper.LogMessagesAsWarning(new[] { - FactorOfStability = macroStabilityInwardsResult.FactorOfStability, - ZValue = macroStabilityInwardsResult.ZValue, - ForbiddenZonesXEntryMin = macroStabilityInwardsResult.ForbiddenZonesXEntryMin, - ForbiddenZonesXEntryMax = macroStabilityInwardsResult.ForbiddenZonesXEntryMax + Resources.MacroStabilityInwardsCalculationService_Calculate_Warnings_in_MacroStabilityInwards_calculation + Environment.NewLine + + macroStabilityInwardsResult.CalculationMessages + .Where(cm => cm.ResultType == UpliftVanKernelMessageType.Warning) + .Aggregate(string.Empty, (current, logMessage) => current + $"* {logMessage.Message}{Environment.NewLine}").Trim() }); + } } catch (UpliftVanCalculatorException e) { Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Properties/Resources.Designer.cs =================================================================== diff -u -r509e11006e2a4dd1db6f9dd03271b1a5c8dd7790 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 509e11006e2a4dd1db6f9dd03271b1a5c8dd7790) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -92,6 +92,16 @@ } /// + /// Looks up a localized string similar to Er zijn waarschuwingsberichten naar aanleiding van de berekening. Klik op details voor meer informatie.. + /// + internal static string MacroStabilityInwardsCalculationService_Calculate_Warnings_in_MacroStabilityInwards_calculation { + get { + return ResourceManager.GetString("MacroStabilityInwardsCalculationService_Calculate_Warnings_in_MacroStabilityInwar" + + "ds_calculation", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Macrostabiliteit binnenwaarts validatie mislukt.. /// internal static string MacroStabilityInwardsCalculationService_Validate_Error_in_MacroStabilityInwards_validation { Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Properties/Resources.resx =================================================================== diff -u -r509e11006e2a4dd1db6f9dd03271b1a5c8dd7790 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Properties/Resources.resx (.../Resources.resx) (revision 509e11006e2a4dd1db6f9dd03271b1a5c8dd7790) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Properties/Resources.resx (.../Resources.resx) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -132,6 +132,9 @@ Macrostabiliteit binnenwaarts berekening mislukt. + + Er zijn waarschuwingsberichten naar aanleiding van de berekening. Klik op details voor meer informatie. + Macrostabiliteit binnenwaarts validatie mislukt. Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/Output/UpliftVanCalculatorResultTest.cs =================================================================== diff -u -r0f736d81afe800a482dff027fe93128a5e967114 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/Output/UpliftVanCalculatorResultTest.cs (.../UpliftVanCalculatorResultTest.cs) (revision 0f736d81afe800a482dff027fe93128a5e967114) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/Output/UpliftVanCalculatorResultTest.cs (.../UpliftVanCalculatorResultTest.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using System.Collections.Generic; using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan.Output; using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Calculators.UpliftVan; using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Calculators.UpliftVan.Output; @@ -34,7 +36,7 @@ public void Constructor_SlidingCurveResultNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => new UpliftVanCalculatorResult(null, CreateGridResult(), new UpliftVanCalculatorResult.ConstructionProperties()); + TestDelegate call = () => new UpliftVanCalculatorResult(null, CreateGridResult(), new UpliftVanKernelMessage[0], new UpliftVanCalculatorResult.ConstructionProperties()); // Assert var exception = Assert.Throws(call); @@ -48,21 +50,35 @@ UpliftVanSlidingCurveResult slidingCurveResult = UpliftVanSlidingCurveResultTestFactory.Create(); // Call - TestDelegate call = () => new UpliftVanCalculatorResult(slidingCurveResult, null, new UpliftVanCalculatorResult.ConstructionProperties()); + TestDelegate call = () => new UpliftVanCalculatorResult(slidingCurveResult, null, new UpliftVanKernelMessage[0], new UpliftVanCalculatorResult.ConstructionProperties()); // Assert var exception = Assert.Throws(call); Assert.AreEqual("calculationGridResult", exception.ParamName); } [Test] + public void Constructor_CalculationMessagesNull_ThrowsArgumentNullException() + { + // Setup + UpliftVanSlidingCurveResult slidingCurveResult = UpliftVanSlidingCurveResultTestFactory.Create(); + + // Call + TestDelegate call = () => new UpliftVanCalculatorResult(slidingCurveResult, CreateGridResult(), null, new UpliftVanCalculatorResult.ConstructionProperties()); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("calculationMessages", exception.ParamName); + } + + [Test] public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException() { // Setup UpliftVanSlidingCurveResult slidingCurveResult = UpliftVanSlidingCurveResultTestFactory.Create(); // Call - TestDelegate call = () => new UpliftVanCalculatorResult(slidingCurveResult, CreateGridResult(), null); + TestDelegate call = () => new UpliftVanCalculatorResult(slidingCurveResult, CreateGridResult(), new UpliftVanKernelMessage[0], null); // Assert var exception = Assert.Throws(call); @@ -75,13 +91,19 @@ // Setup UpliftVanSlidingCurveResult slidingCurveResult = UpliftVanSlidingCurveResultTestFactory.Create(); UpliftVanCalculationGridResult calculationGridResult = CreateGridResult(); + IEnumerable calculationMessages = new List + { + new UpliftVanKernelMessage(UpliftVanKernelMessageType.Error, "Error"), + new UpliftVanKernelMessage(UpliftVanKernelMessageType.Warning, "Warning") + }; // Call - var result = new UpliftVanCalculatorResult(slidingCurveResult, calculationGridResult, new UpliftVanCalculatorResult.ConstructionProperties()); + var result = new UpliftVanCalculatorResult(slidingCurveResult, calculationGridResult, calculationMessages, new UpliftVanCalculatorResult.ConstructionProperties()); // Assert Assert.AreSame(slidingCurveResult, result.SlidingCurveResult); Assert.AreSame(calculationGridResult, result.CalculationGridResult); + Assert.AreSame(calculationMessages, result.CalculationMessages); } [Test] @@ -91,7 +113,7 @@ UpliftVanSlidingCurveResult slidingCurveResult = UpliftVanSlidingCurveResultTestFactory.Create(); // Call - var result = new UpliftVanCalculatorResult(slidingCurveResult, CreateGridResult(), new UpliftVanCalculatorResult.ConstructionProperties()); + var result = new UpliftVanCalculatorResult(slidingCurveResult, CreateGridResult(), new UpliftVanKernelMessage[0], new UpliftVanCalculatorResult.ConstructionProperties()); // Assert Assert.IsNaN(result.FactorOfStability); @@ -121,7 +143,7 @@ UpliftVanSlidingCurveResult slidingCurveResult = UpliftVanSlidingCurveResultTestFactory.Create(); // Call - var result = new UpliftVanCalculatorResult(slidingCurveResult, CreateGridResult(), constructionProperties); + var result = new UpliftVanCalculatorResult(slidingCurveResult, CreateGridResult(), new UpliftVanKernelMessage[0], constructionProperties); // Assert Assert.AreEqual(factorOfStability, result.FactorOfStability); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs =================================================================== diff -u -rbd0a78dc9dd218a799c43b114725f6efa4da1687 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision bd0a78dc9dd218a799c43b114725f6efa4da1687) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -26,6 +26,7 @@ using Core.Common.TestUtil; using Deltares.WTIStability; using Deltares.WTIStability.Data.Geo; +using Deltares.WTIStability.Data.Standard; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input; @@ -155,6 +156,7 @@ Assert.AreEqual(input.AutomaticForbiddenZones, upliftVanKernel.AutomaticForbiddenZones); Assert.AreEqual(input.SlipPlaneMinimumDepth, upliftVanKernel.SlipPlaneMinimumDepth); Assert.AreEqual(input.SlipPlaneMinimumLength, upliftVanKernel.SlipPlaneMinimumLength); + CollectionAssert.IsEmpty(upliftVanKernel.CalculationMessages); } [Test] @@ -183,6 +185,41 @@ } [Test] + public void Calculate_KernelReturnsLogMessages_ReturnsExpectedLogMessages() + { + // Setup + UpliftVanCalculatorInput input = CreateValidCalculatorInput(); + var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); + + UpliftVanKernelStub upliftVanKernel = testMacroStabilityInwardsKernelFactory.LastCreatedUpliftVanKernel; + upliftVanKernel.ReturnLogMessages = true; + SetCompleteKernelOutput(upliftVanKernel); + + // Call + new UpliftVanCalculator(input, testMacroStabilityInwardsKernelFactory).Calculate(); + + // Assert + Assert.AreEqual(6, upliftVanKernel.CalculationMessages.Count()); + Assert.AreEqual("Calculation Trace", upliftVanKernel.CalculationMessages.ElementAt(0).Message); + Assert.AreEqual(LogMessageType.Trace, upliftVanKernel.CalculationMessages.ElementAt(0).MessageType); + + Assert.AreEqual("Calculation Debug", upliftVanKernel.CalculationMessages.ElementAt(1).Message); + Assert.AreEqual(LogMessageType.Debug, upliftVanKernel.CalculationMessages.ElementAt(1).MessageType); + + Assert.AreEqual("Calculation Info", upliftVanKernel.CalculationMessages.ElementAt(2).Message); + Assert.AreEqual(LogMessageType.Info, upliftVanKernel.CalculationMessages.ElementAt(2).MessageType); + + Assert.AreEqual("Calculation Warning", upliftVanKernel.CalculationMessages.ElementAt(3).Message); + Assert.AreEqual(LogMessageType.Warning, upliftVanKernel.CalculationMessages.ElementAt(3).MessageType); + + Assert.AreEqual("Calculation Error", upliftVanKernel.CalculationMessages.ElementAt(4).Message); + Assert.AreEqual(LogMessageType.Error, upliftVanKernel.CalculationMessages.ElementAt(4).MessageType); + + Assert.AreEqual("Calculation Fatal Error", upliftVanKernel.CalculationMessages.ElementAt(5).Message); + Assert.AreEqual(LogMessageType.FatalError, upliftVanKernel.CalculationMessages.ElementAt(5).MessageType); + } + + [Test] public void Calculate_KernelThrowsUpliftVanKernelWrapperException_ThrowUpliftVanCalculatorException() { // Setup @@ -223,10 +260,10 @@ var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); // Call - IEnumerable validationResult = new UpliftVanCalculator(input, testMacroStabilityInwardsKernelFactory).Validate(); + IEnumerable kernelMessages = new UpliftVanCalculator(input, testMacroStabilityInwardsKernelFactory).Validate(); // Assert - CollectionAssert.IsEmpty(validationResult); + CollectionAssert.IsEmpty(kernelMessages); } [Test] @@ -238,14 +275,15 @@ upliftVanKernel.ReturnValidationResults = true; // Call - IEnumerable results = new UpliftVanCalculator(CreateValidCalculatorInput(), testMacroStabilityInwardsKernelFactory).Validate(); + IEnumerable kernelMessages = new UpliftVanCalculator(CreateValidCalculatorInput(), + testMacroStabilityInwardsKernelFactory).Validate().ToList(); // Assert - Assert.AreEqual(2, results.Count()); - Assert.AreEqual("Validation Warning", results.ElementAt(0).Message); - Assert.AreEqual(UpliftVanValidationResultType.Warning, results.ElementAt(0).ResultType); - Assert.AreEqual("Validation Error", results.ElementAt(1).Message); - Assert.AreEqual(UpliftVanValidationResultType.Error, results.ElementAt(1).ResultType); + Assert.AreEqual(2, kernelMessages.Count()); + Assert.AreEqual("Validation Warning", kernelMessages.ElementAt(0).Message); + Assert.AreEqual(UpliftVanKernelMessageType.Warning, kernelMessages.ElementAt(0).ResultType); + Assert.AreEqual("Validation Error", kernelMessages.ElementAt(1).Message); + Assert.AreEqual(UpliftVanKernelMessageType.Error, kernelMessages.ElementAt(1).ResultType); } [Test] Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanKernelMessageTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanKernelMessageTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanKernelMessageTest.cs (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -0,0 +1,57 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Calculators.UpliftVan +{ + [TestFixture] + public class UpliftVanKernelMessageTest + { + [Test] + public void Constructor_MessageNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new UpliftVanKernelMessage(UpliftVanKernelMessageType.Error, null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("message", exception.ParamName); + } + + [Test] + public void Constructor_ValidArguments_ReturnsExpectedValues() + { + // Setup + const UpliftVanKernelMessageType resultType = UpliftVanKernelMessageType.Error; + const string message = "Error in validation"; + + // Call + var kernelMessage = new UpliftVanKernelMessage(resultType, message); + + // Assert + Assert.AreEqual(message, kernelMessage.Message); + Assert.AreEqual(resultType, kernelMessage.ResultType); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanKernelMessageTypeTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanKernelMessageTypeTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanKernelMessageTypeTest.cs (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -0,0 +1,40 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Calculators.UpliftVan +{ + [TestFixture] + public class UpliftVanKernelMessageTypeTest + { + [Test] + public void Values_ExpectedValues() + { + // Assert + Assert.AreEqual(2, Enum.GetValues(typeof(UpliftVanKernelMessageType)).Length); + Assert.AreEqual(1, (int) UpliftVanKernelMessageType.Warning); + Assert.AreEqual(2, (int) UpliftVanKernelMessageType.Error); + } + } +} \ No newline at end of file Fisheye: Tag 72b12726b73e7e011bed836163635b64220c23f1 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanValidationResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 72b12726b73e7e011bed836163635b64220c23f1 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanValidationResultTypeTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/Output/UpliftVanKernelMessagesCreatorTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/Output/UpliftVanKernelMessagesCreatorTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/Output/UpliftVanKernelMessagesCreatorTest.cs (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -0,0 +1,73 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Linq; +using Deltares.WTIStability.Data.Standard; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Output; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Creators.Output +{ + [TestFixture] + public class UpliftVanKernelMessagesCreatorTest + { + [Test] + public void Create_LogMessagesNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => UpliftVanKernelMessagesCreator.Create(null).ToList(); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("logMessages", exception.ParamName); + } + + [Test] + public void Create_WithLogMessages_ReturnUpliftVanKernelMessages() + { + // Setup + var logMessages = new[] + { + new LogMessage(LogMessageType.Trace, "subject", "Calculation Trace"), + new LogMessage(LogMessageType.Debug, "subject", "Calculation Debug"), + new LogMessage(LogMessageType.Info, "subject", "Calculation Info"), + new LogMessage(LogMessageType.Warning, "subject", "Calculation Warning"), + new LogMessage(LogMessageType.Error, "subject", "Calculation Error"), + new LogMessage(LogMessageType.FatalError, "subject", "Calculation Fatal Error") + }; + + // Call + IEnumerable kernelMessages = UpliftVanKernelMessagesCreator.Create(logMessages).ToList(); + + // Assert + Assert.AreEqual(3, kernelMessages.Count()); + Assert.AreEqual("Calculation Warning", kernelMessages.ElementAt(0).Message); + Assert.AreEqual(UpliftVanKernelMessageType.Warning, kernelMessages.ElementAt(0).ResultType); + Assert.AreEqual("Calculation Error", kernelMessages.ElementAt(1).Message); + Assert.AreEqual(UpliftVanKernelMessageType.Error, kernelMessages.ElementAt(1).ResultType); + Assert.AreEqual("Calculation Fatal Error", kernelMessages.ElementAt(2).Message); + Assert.AreEqual(UpliftVanKernelMessageType.Error, kernelMessages.ElementAt(2).ResultType); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Kernels/UpliftVan/UpliftVanKernelWrapperTest.cs =================================================================== diff -u -r701b27e6e958f5f52706bf4eec3b1c35efde9f68 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Kernels/UpliftVan/UpliftVanKernelWrapperTest.cs (.../UpliftVanKernelWrapperTest.cs) (revision 701b27e6e958f5f52706bf4eec3b1c35efde9f68) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Kernels/UpliftVan/UpliftVanKernelWrapperTest.cs (.../UpliftVanKernelWrapperTest.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -130,22 +130,6 @@ } [Test] - public void Calculate_ErrorInCalculation_ThrowsUpliftVanKernelWrapperException() - { - // Setup - UpliftVanKernelWrapper kernel = CreateInvalidKernel(new Soil()); - - // Call - TestDelegate test = () => kernel.Calculate(); - - // Assert - var exception = Assert.Throws(test); - Assert.AreEqual($"Index was out of range. Must be non-negative and less than the size of the collection.{Environment.NewLine}" + - $"Parameter name: index{Environment.NewLine}" + - "Fatale fout in Uplift-Van berekening", exception.Message); - } - - [Test] public void Calculate_ExceptionDuringCalculation_OutputPropertiesNotSet() { // Setup Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj =================================================================== diff -u -r1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 1ac34cc0c84df6f54d67ab8c1886ca96387dd7dd) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -75,8 +75,8 @@ - - + + @@ -99,6 +99,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Calculators/UpliftVan/UpliftVanCalculatorStubTest.cs =================================================================== diff -u -r701b27e6e958f5f52706bf4eec3b1c35efde9f68 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Calculators/UpliftVan/UpliftVanCalculatorStubTest.cs (.../UpliftVanCalculatorStubTest.cs) (revision 701b27e6e958f5f52706bf4eec3b1c35efde9f68) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Calculators/UpliftVan/UpliftVanCalculatorStubTest.cs (.../UpliftVanCalculatorStubTest.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -46,9 +46,46 @@ Assert.IsFalse(calculator.ThrowExceptionOnValidate); Assert.IsFalse(calculator.ReturnValidationWarning); Assert.IsFalse(calculator.ReturnValidationError); + Assert.IsFalse(calculator.ReturnCalculationError); + Assert.IsFalse(calculator.ReturnCalculationWarning); } [Test] + public void Calculate_ReturnCalculationErrorAndWarningFalse_ReturnsEmptyEnumerable() + { + // Setup + var calculator = new UpliftVanCalculatorStub(); + + // Call + calculator.Calculate(); + + // Assert + CollectionAssert.IsEmpty(calculator.Output.CalculationMessages); + } + + [Test] + public void Calculate_ReturnCalculationErrorAndWarningTrue_ReturnsKernelMessages() + { + // Setup + var calculator = new UpliftVanCalculatorStub + { + ReturnCalculationError = true, + ReturnCalculationWarning = true + }; + + // Call + calculator.Calculate(); + + // Assert + IEnumerable messages = calculator.Output.CalculationMessages.ToList(); + Assert.AreEqual(2, messages.Count()); + Assert.AreEqual("Calculation Error", messages.ElementAt(0).Message); + Assert.AreEqual(UpliftVanKernelMessageType.Error, messages.ElementAt(0).ResultType); + Assert.AreEqual("Calculation Warning", messages.ElementAt(1).Message); + Assert.AreEqual(UpliftVanKernelMessageType.Warning, messages.ElementAt(1).ResultType); + } + + [Test] public void Calculate_ThrowExceptionOnCalculateFalse_ReturnResult() { // Setup @@ -92,14 +129,14 @@ var calculator = new UpliftVanCalculatorStub(); // Call - IEnumerable result = calculator.Validate(); + IEnumerable messages = calculator.Validate(); // Assert - CollectionAssert.IsEmpty(result); + CollectionAssert.IsEmpty(messages); } [Test] - public void Validate_ReturnValidationErrorAndWarningTrue_ReturnsValidationResults() + public void Validate_ReturnValidationErrorAndWarningTrue_ReturnsKernelMessages() { // Setup var calculator = new UpliftVanCalculatorStub @@ -109,14 +146,14 @@ }; // Call - IEnumerable results = calculator.Validate(); + IEnumerable messages = calculator.Validate().ToList(); // Assert - Assert.AreEqual(2, results.Count()); - Assert.AreEqual("Validation Error", results.ElementAt(0).Message); - Assert.AreEqual(UpliftVanValidationResultType.Error, results.ElementAt(0).ResultType); - Assert.AreEqual("Validation Warning", results.ElementAt(1).Message); - Assert.AreEqual(UpliftVanValidationResultType.Warning, results.ElementAt(1).ResultType); + Assert.AreEqual(2, messages.Count()); + Assert.AreEqual("Validation Error", messages.ElementAt(0).Message); + Assert.AreEqual(UpliftVanKernelMessageType.Error, messages.ElementAt(0).ResultType); + Assert.AreEqual("Validation Warning", messages.ElementAt(1).Message); + Assert.AreEqual(UpliftVanKernelMessageType.Warning, messages.ElementAt(1).ResultType); } [Test] Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/UpliftVanKernelStubTest.cs =================================================================== diff -u -r701b27e6e958f5f52706bf4eec3b1c35efde9f68 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/UpliftVanKernelStubTest.cs (.../UpliftVanKernelStubTest.cs) (revision 701b27e6e958f5f52706bf4eec3b1c35efde9f68) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/UpliftVanKernelStubTest.cs (.../UpliftVanKernelStubTest.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -83,9 +83,51 @@ Assert.IsTrue(kernel.ThrowExceptionOnCalculate); Assert.IsFalse(kernel.ThrowExceptionOnValidate); Assert.IsFalse(kernel.ReturnValidationResults); + Assert.IsFalse(kernel.ReturnLogMessages); } [Test] + public void Calculate_ReturnLogMessagesTrue_ReturnsLogMessages() + { + // Setup + var calculator = new UpliftVanKernelStub + { + ReturnLogMessages = true + }; + + // Call + calculator.Calculate(); + + // Assert + IEnumerable results = calculator.CalculationMessages.ToList(); + Assert.IsTrue(calculator.Calculated); + Assert.AreEqual(6, results.Count()); + AssertLogMessage(new LogMessage(LogMessageType.Trace, "subject", "Calculation Trace"), results.ElementAt(0)); + AssertLogMessage(new LogMessage(LogMessageType.Debug, "subject", "Calculation Debug"), results.ElementAt(1)); + AssertLogMessage(new LogMessage(LogMessageType.Info, "subject", "Calculation Info"), results.ElementAt(2)); + AssertLogMessage(new LogMessage(LogMessageType.Warning, "subject", "Calculation Warning"), results.ElementAt(3)); + AssertLogMessage(new LogMessage(LogMessageType.Error, "subject", "Calculation Error"), results.ElementAt(4)); + AssertLogMessage(new LogMessage(LogMessageType.FatalError, "subject", "Calculation Fatal Error"), results.ElementAt(5)); + } + + [Test] + public void Calculate_ReturnLogMessagesFalse_ReturnsNoLogMessages() + { + // Setup + var calculator = new UpliftVanKernelStub + { + ReturnLogMessages = false + }; + + // Call + calculator.Calculate(); + + // Assert + Assert.IsTrue(calculator.Calculated); + CollectionAssert.IsEmpty(calculator.CalculationMessages); + } + + [Test] public void Validate_ThrowExceptionOnValidateFalse_SetValidatedTrue() { // Setup @@ -158,13 +200,20 @@ // Assert Assert.IsTrue(calculator.Validated); - Assert.AreEqual(0, results.Count()); + CollectionAssert.IsEmpty(results); } private static void AssertValidationResult(IValidationResult expected, IValidationResult actual) { Assert.AreEqual(expected.MessageType, actual.MessageType); Assert.AreEqual(expected.Text, actual.Text); } + + private static void AssertLogMessage(LogMessage expected, LogMessage actual) + { + Assert.AreEqual(expected.MessageType, actual.MessageType); + Assert.AreEqual(expected.Message, actual.Message); + Assert.AreEqual(expected.Subject, actual.Subject); + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/UpliftVan/UpliftVanCalculatorStub.cs =================================================================== diff -u -r701b27e6e958f5f52706bf4eec3b1c35efde9f68 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/UpliftVan/UpliftVanCalculatorStub.cs (.../UpliftVanCalculatorStub.cs) (revision 701b27e6e958f5f52706bf4eec3b1c35efde9f68) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/UpliftVan/UpliftVanCalculatorStub.cs (.../UpliftVanCalculatorStub.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -44,6 +44,16 @@ public UpliftVanCalculatorResult Output { get; private set; } /// + /// Indicator whether an error message must be returned when performing the calculation. + /// + public bool ReturnCalculationError { get; set; } + + /// + /// Indicator whether a warning message must be returned when performing the calculation. + /// + public bool ReturnCalculationWarning { get; set; } + + /// /// Indicator whether an exception must be thrown when performing the calculation. /// public bool ThrowExceptionOnCalculate { get; set; } @@ -69,10 +79,21 @@ { throw new UpliftVanCalculatorException($"Message 1{Environment.NewLine}Message 2"); } - return Output ?? (Output = CreateUpliftVanCalculatorResult()); + + var calculationMessages = new List(); + if (ReturnCalculationError) + { + calculationMessages.Add(new UpliftVanKernelMessage(UpliftVanKernelMessageType.Error, "Calculation Error")); + } + if (ReturnCalculationWarning) + { + calculationMessages.Add(new UpliftVanKernelMessage(UpliftVanKernelMessageType.Warning, "Calculation Warning")); + } + + return Output ?? (Output = CreateUpliftVanCalculatorResult(calculationMessages)); } - public IEnumerable Validate() + public IEnumerable Validate() { if (ThrowExceptionOnValidate) { @@ -81,15 +102,15 @@ if (ReturnValidationError) { - yield return new UpliftVanValidationResult(UpliftVanValidationResultType.Error, "Validation Error"); + yield return new UpliftVanKernelMessage(UpliftVanKernelMessageType.Error, "Validation Error"); } if (ReturnValidationWarning) { - yield return new UpliftVanValidationResult(UpliftVanValidationResultType.Warning, "Validation Warning"); + yield return new UpliftVanKernelMessage(UpliftVanKernelMessageType.Warning, "Validation Warning"); } } - private static UpliftVanCalculatorResult CreateUpliftVanCalculatorResult() + private static UpliftVanCalculatorResult CreateUpliftVanCalculatorResult(IEnumerable calculationMessages) { return new UpliftVanCalculatorResult( UpliftVanSlidingCurveResultTestFactory.Create(), @@ -102,6 +123,7 @@ 2, 1.5 }), + calculationMessages, new UpliftVanCalculatorResult.ConstructionProperties { FactorOfStability = 0.1, Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/UpliftVanKernelStub.cs =================================================================== diff -u -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/UpliftVanKernelStub.cs (.../UpliftVanKernelStub.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/UpliftVanKernelStub.cs (.../UpliftVanKernelStub.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -58,6 +58,11 @@ /// public bool ReturnValidationResults { get; set; } + /// + /// Indicator whether a log message must be returned when performing the calculation. + /// + public bool ReturnLogMessages { get; set; } + public SoilModel SoilModel { get; set; } public SoilProfile2D SoilProfile { get; set; } @@ -96,12 +101,30 @@ public SlipPlaneUpliftVan SlipPlaneResult { get; set; } + public IEnumerable CalculationMessages { get; set; } + public void Calculate() { if (ThrowExceptionOnCalculate) { throw new UpliftVanKernelWrapperException($"Message 1{Environment.NewLine}Message 2", new Exception()); } + if (ReturnLogMessages) + { + CalculationMessages = new[] + { + new LogMessage(LogMessageType.Trace, "subject", "Calculation Trace"), + new LogMessage(LogMessageType.Debug, "subject", "Calculation Debug"), + new LogMessage(LogMessageType.Info, "subject", "Calculation Info"), + new LogMessage(LogMessageType.Warning, "subject", "Calculation Warning"), + new LogMessage(LogMessageType.Error, "subject", "Calculation Error"), + new LogMessage(LogMessageType.FatalError, "subject", "Calculation Fatal Error") + }; + } + else + { + CalculationMessages = new LogMessage[0]; + } Calculated = true; } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs =================================================================== diff -u -r24ef82baac0966895b34ff927c61e560509806a6 -r72b12726b73e7e011bed836163635b64220c23f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision 24ef82baac0966895b34ff927c61e560509806a6) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/MacroStabilityInwardsCalculationServiceTest.cs (.../MacroStabilityInwardsCalculationServiceTest.cs) (revision 72b12726b73e7e011bed836163635b64220c23f1) @@ -785,6 +785,90 @@ } } + [Test] + public void Calculate_KernelReturnsCalculationError_LogsErrorAndReturnsFalse() + { + // Setup + const string name = ""; + testCalculation.Name = name; + + using (new MacroStabilityInwardsCalculatorFactoryConfig()) + { + // Call + Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation); + var calculator = (TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance; + calculator.LastCreatedUpliftVanCalculator.ReturnCalculationError = true; + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual("Calculation Error", msgs[1]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[2]); + }); + } + } + + [Test] + public void Calculate_KernelReturnsCalculationWarning_LogsWarningAndReturnsTrue() + { + // Setup + const string name = ""; + testCalculation.Name = name; + + using (new MacroStabilityInwardsCalculatorFactoryConfig()) + { + // Call + Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation); + var calculator = (TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance; + calculator.LastCreatedUpliftVanCalculator.ReturnCalculationWarning = true; + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual("Er zijn waarschuwingsberichten naar aanleiding van de berekening. Klik op details voor meer informatie." + + $"{Environment.NewLine}" + + "* Calculation Warning", msgs[1]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[2]); + }); + } + } + + [Test] + public void Calculate_KernelReturnsCalculationErrorAndWarning_LogsErrorAndWarningAndReturnsFalse() + { + // Setup + const string name = ""; + testCalculation.Name = name; + + using (new MacroStabilityInwardsCalculatorFactoryConfig()) + { + // Call + Action call = () => MacroStabilityInwardsCalculationService.Calculate(testCalculation); + var calculator = (TestMacroStabilityInwardsCalculatorFactory) MacroStabilityInwardsCalculatorFactory.Instance; + calculator.LastCreatedUpliftVanCalculator.ReturnCalculationWarning = true; + calculator.LastCreatedUpliftVanCalculator.ReturnCalculationError = true; + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] msgs = messages.ToArray(); + Assert.AreEqual(4, msgs.Length); + CalculationServiceTestHelper.AssertCalculationStartMessage(msgs[0]); + Assert.AreEqual("Calculation Error", msgs[1]); + Assert.AreEqual("Er zijn waarschuwingsberichten naar aanleiding van de berekening. Klik op details voor meer informatie." + + $"{Environment.NewLine}" + + "* Calculation Warning", msgs[2]); + CalculationServiceTestHelper.AssertCalculationEndMessage(msgs[3]); + }); + } + } + private static IEnumerable SurfacelineNotOnMacroStabilityInwardsSoilProfile2D() { yield return new TestCaseData(