Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/IUpliftVanCalculator.cs =================================================================== diff -u -r0f736d81afe800a482dff027fe93128a5e967114 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/IUpliftVanCalculator.cs (.../IUpliftVanCalculator.cs) (revision 0f736d81afe800a482dff027fe93128a5e967114) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/IUpliftVanCalculator.cs (.../IUpliftVanCalculator.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -47,7 +47,9 @@ /// /// Performs the validation. /// - /// A list of validation messages. + /// An of . + /// Thrown when an error + /// occurs during the validation. IEnumerable Validate(); } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs =================================================================== diff -u -r7822834024ae12c82ec93ba3f57556cb4a503296 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision 7822834024ae12c82ec93ba3f57556cb4a503296) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanCalculator.cs (.../UpliftVanCalculator.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -67,12 +67,12 @@ try { IUpliftVanKernel upliftVanKernel = CreateUpliftVanKernel(); - List> results = upliftVanKernel.Validate(); - var upliftValidationResults = new List(); - foreach (Tuple result in results) + IEnumerable results = upliftVanKernel.Validate(); + var upliftVanValidationResults = new List(); + foreach (ValidationResult result in results) { UpliftVanValidationResultType type; - switch (result.Item1) + switch (result.MessageType) { case ValidationResultType.Error: type = UpliftVanValidationResultType.Error; @@ -83,9 +83,9 @@ default: continue; } - upliftValidationResults.Add(new UpliftVanValidationResult(type, result.Item2)); + upliftVanValidationResults.Add(new UpliftVanValidationResult(type, result.Text)); } - return upliftValidationResults; + return upliftVanValidationResults; } catch (UpliftVanKernelWrapperException e) { Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanValidationResult.cs =================================================================== diff -u -r6d3eb061666110382fd3379594f4da711cc9ad1e -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanValidationResult.cs (.../UpliftVanValidationResult.cs) (revision 6d3eb061666110382fd3379594f4da711cc9ad1e) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanValidationResult.cs (.../UpliftVanValidationResult.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -24,15 +24,17 @@ namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan { /// - /// The validation result of an Uplift Van calculation. + /// Class representing a validation result of an Uplift Van calculation. /// public class UpliftVanValidationResult { /// /// Creates a new instance of . /// - /// The result type of the validation result - /// The message of the validation result + /// The type of the validation result. + /// The message of the validation result. + /// Thrown when + /// is null. public UpliftVanValidationResult(UpliftVanValidationResultType type, string message) { if (message == null) @@ -44,7 +46,7 @@ } /// - /// Gets the type of the validation result message. + /// Gets the type of the validation result. /// public UpliftVanValidationResultType ResultType { get; } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanValidationResultType.cs =================================================================== diff -u -r6d3eb061666110382fd3379594f4da711cc9ad1e -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanValidationResultType.cs (.../UpliftVanValidationResultType.cs) (revision 6d3eb061666110382fd3379594f4da711cc9ad1e) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/UpliftVan/UpliftVanValidationResultType.cs (.../UpliftVanValidationResultType.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -22,11 +22,11 @@ namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan { /// - /// Indicates what log level the validation result represents. + /// Indicates what log level an Uplift Van validation result represents. /// public enum UpliftVanValidationResultType { - Warning, - Error + Warning = 1, + Error = 2 } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/IUpliftVanKernel.cs =================================================================== diff -u -r7822834024ae12c82ec93ba3f57556cb4a503296 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/IUpliftVanKernel.cs (.../IUpliftVanKernel.cs) (revision 7822834024ae12c82ec93ba3f57556cb4a503296) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/IUpliftVanKernel.cs (.../IUpliftVanKernel.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using Deltares.WTIStability; using Deltares.WTIStability.Data.Geo; @@ -148,8 +147,9 @@ /// /// Validates the input for the Uplift Van calculation. /// - /// A list of tuples containing the validation result type and message, - /// or an empty list if there are no validation results. - List> Validate(); + /// An of objects. + /// Thrown when + /// an error occurs when performing the validation. + IEnumerable Validate(); } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs =================================================================== diff -u -r7822834024ae12c82ec93ba3f57556cb4a503296 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs (.../UpliftVanKernelWrapper.cs) (revision 7822834024ae12c82ec93ba3f57556cb4a503296) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Kernels/UpliftVan/UpliftVanKernelWrapper.cs (.../UpliftVanKernelWrapper.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -190,7 +190,7 @@ } } - public List> Validate() + public IEnumerable Validate() { try { @@ -199,7 +199,7 @@ string result = wtiStabilityCalculation.Validate(); ValidationResult[] deserializedResult = WTIDeserializer.DeserializeValidation(result); - return deserializedResult.Select(r => new Tuple(r.MessageType, r.Text)).ToList(); + return deserializedResult; } catch (Exception e) { Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs =================================================================== diff -u -r7822834024ae12c82ec93ba3f57556cb4a503296 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs (.../MacroStabilityInwardsCalculationService.cs) (revision 7822834024ae12c82ec93ba3f57556cb4a503296) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/MacroStabilityInwardsCalculationService.cs (.../MacroStabilityInwardsCalculationService.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -81,7 +81,7 @@ msg.Message)).ToArray()); CalculationServiceHelper.LogValidationEnd(); - return validationResults.Count(r => r.ResultType == UpliftVanValidationResultType.Error) == 0; + return validationResults.All(r => r.ResultType != UpliftVanValidationResultType.Error); } /// Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsCalculationScenarioFactoryTest.cs =================================================================== diff -u -rda648858a19daab1bd647be549652a1c33e7a45b -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsCalculationScenarioFactoryTest.cs (.../MacroStabilityInwardsCalculationScenarioFactoryTest.cs) (revision da648858a19daab1bd647be549652a1c33e7a45b) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsCalculationScenarioFactoryTest.cs (.../MacroStabilityInwardsCalculationScenarioFactoryTest.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -24,7 +24,9 @@ using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.MacroStabilityInwards.Data.SoilProfile; using Ringtoets.MacroStabilityInwards.Primitives; namespace Ringtoets.MacroStabilityInwards.Data.TestUtil.Test @@ -266,6 +268,103 @@ Assert.AreEqual(1, inputParameters.RightGrid.ZBottom.Value); Assert.AreEqual(1, inputParameters.RightGrid.NumberOfVerticalPoints); Assert.AreEqual(1, inputParameters.RightGrid.NumberOfHorizontalPoints); + + Assert.AreEqual(0, inputParameters.StochasticSoilProfile.Probability); + Assert.AreEqual(string.Empty, inputParameters.StochasticSoilProfile.SoilProfile.Name); + Assert.IsInstanceOf(inputParameters.StochasticSoilProfile.SoilProfile); + var soilProfile1D = (MacroStabilityInwardsSoilProfile1D) inputParameters.StochasticSoilProfile.SoilProfile; + Assert.AreEqual(0, soilProfile1D.Bottom); + CollectionAssert.AreEqual(new[] + { + new MacroStabilityInwardsSoilLayer1D(10.56) + { + Data = + { + IsAquifer = false, + Cohesion = new VariationCoefficientLogNormalDistribution(), + FrictionAngle = new VariationCoefficientLogNormalDistribution(), + AbovePhreaticLevel = + { + Mean = (RoundedDouble) 0.3, + CoefficientOfVariation = (RoundedDouble) 0.2, + Shift = (RoundedDouble) 0.1 + }, + BelowPhreaticLevel = + { + Mean = (RoundedDouble) 15, + CoefficientOfVariation = (RoundedDouble) 0.5, + Shift = (RoundedDouble) 0.2 + } + } + }, + new MacroStabilityInwardsSoilLayer1D(6.0) + { + Data = + { + IsAquifer = true, + Cohesion = new VariationCoefficientLogNormalDistribution(), + FrictionAngle = new VariationCoefficientLogNormalDistribution(), + AbovePhreaticLevel = + { + Mean = (RoundedDouble) 0.3, + CoefficientOfVariation = (RoundedDouble) 0.2, + Shift = (RoundedDouble) 0.1 + }, + BelowPhreaticLevel = + { + Mean = (RoundedDouble) 15, + CoefficientOfVariation = (RoundedDouble) 0.5, + Shift = (RoundedDouble) 0.2 + } + } + }, + new MacroStabilityInwardsSoilLayer1D(0.1) + { + Data = + { + IsAquifer = false, + Cohesion = new VariationCoefficientLogNormalDistribution(), + FrictionAngle = new VariationCoefficientLogNormalDistribution(), + AbovePhreaticLevel = + { + Mean = (RoundedDouble) 0.3, + CoefficientOfVariation = (RoundedDouble) 0.2, + Shift = (RoundedDouble) 0.1 + }, + BelowPhreaticLevel = + { + Mean = (RoundedDouble) 15, + CoefficientOfVariation = (RoundedDouble) 0.5, + Shift = (RoundedDouble) 0.2 + } + } + } + }, soilProfile1D.Layers); + + var expectedSurfaceLine = new MacroStabilityInwardsSurfaceLine(string.Empty); + var firstCharacteristicPointLocation = new Point3D(0.1, 0.0, 2); + var secondCharacteristicPointLocation = new Point3D(0.2, 0.0, 2); + var thirdCharacteristicPointLocation = new Point3D(0.3, 0.0, 3); + var fourthCharacteristicPointLocation = new Point3D(0.4, 0.0, 3); + var fifthCharacteristicPointLocation = new Point3D(0.5, 0.0, 1); + var sixthCharacteristicPointLocation = new Point3D(0.6, 0.0, 1); + + expectedSurfaceLine.SetGeometry(new[] + { + firstCharacteristicPointLocation, + secondCharacteristicPointLocation, + thirdCharacteristicPointLocation, + fourthCharacteristicPointLocation, + fifthCharacteristicPointLocation, + sixthCharacteristicPointLocation + }); + expectedSurfaceLine.SetSurfaceLevelOutsideAt(firstCharacteristicPointLocation); + expectedSurfaceLine.SetDikeToeAtRiverAt(secondCharacteristicPointLocation); + expectedSurfaceLine.SetDikeTopAtRiverAt(thirdCharacteristicPointLocation); + expectedSurfaceLine.SetDikeTopAtPolderAt(fourthCharacteristicPointLocation); + expectedSurfaceLine.SetDikeToeAtPolderAt(fifthCharacteristicPointLocation); + expectedSurfaceLine.SetSurfaceLevelInsideAt(sixthCharacteristicPointLocation); + Assert.AreEqual(expectedSurfaceLine, inputParameters.SurfaceLine); } private static FailureMechanismSection CreateSection() Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs =================================================================== diff -u -r1d029d025f9e8b9245b33fd1ef4cb7fa0982c138 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision 1d029d025f9e8b9245b33fd1ef4cb7fa0982c138) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanCalculatorTest.cs (.../UpliftVanCalculatorTest.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -196,21 +196,38 @@ } [Test] - public void Validate_CalculatorWithValidInput_ReturnEmptyList() + public void Validate_CalculatorWithValidInputAndKernelWithValidOutput_KernelValidateMethodCalled() { // Setup UpliftVanCalculatorInput input = CreateValidCalculatorInput(); var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); + UpliftVanKernelStub upliftVanKernel = testMacroStabilityInwardsKernelFactory.LastCreatedUpliftVanKernel; + SetValidKernelOutput(upliftVanKernel); + // Call + new UpliftVanCalculator(input, testMacroStabilityInwardsKernelFactory).Validate(); + + // Assert + Assert.IsTrue(testMacroStabilityInwardsKernelFactory.LastCreatedUpliftVanKernel.Validated); + } + + [Test] + public void Validate_CalculatorWithValidInput_ReturnEmptyEnumerable() + { + // Setup + UpliftVanCalculatorInput input = CreateValidCalculatorInput(); + var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); + + // Call IEnumerable validationResult = new UpliftVanCalculator(input, testMacroStabilityInwardsKernelFactory).Validate(); // Assert CollectionAssert.IsEmpty(validationResult); } [Test] - public void Validate_KernelReturnsValidationResults_ReturnsListWithOnlyErrorsAndWarnings() + public void Validate_KernelReturnsValidationResults_ReturnsEnumerableWithOnlyErrorsAndWarnings() { // Setup var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanValidationResultTypeTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanValidationResultTypeTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/UpliftVan/UpliftVanValidationResultTypeTest.cs (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -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 UpliftVanValidationResultTypeTest + { + [Test] + public void Values_ExpectedValues() + { + // Assert + Assert.AreEqual(2, Enum.GetValues(typeof(UpliftVanValidationResultType)).Length); + Assert.AreEqual(1, (int) UpliftVanValidationResultType.Warning); + Assert.AreEqual(2, (int) UpliftVanValidationResultType.Error); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Kernels/UpliftVan/UpliftVanKernelWrapperTest.cs =================================================================== diff -u -r5859430bf93fa658cdceb8c2731de08f0a1c1ab7 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Kernels/UpliftVan/UpliftVanKernelWrapperTest.cs (.../UpliftVanKernelWrapperTest.cs) (revision 5859430bf93fa658cdceb8c2731de08f0a1c1ab7) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Kernels/UpliftVan/UpliftVanKernelWrapperTest.cs (.../UpliftVanKernelWrapperTest.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -131,85 +131,7 @@ public void Calculate_ErrorInCalculation_ThrowsUpliftVanKernelWrapperException() { // Setup - var point1 = new Point2D(0, 0); - var point2 = new Point2D(1, 1); - var point3 = new Point2D(2, 2); - var point4 = new Point2D(3, 3); - var curve1 = new GeometryCurve(point1, point2); - var curve2 = new GeometryCurve(point2, point3); - var curve3 = new GeometryCurve(point3, point4); - var curve4 = new GeometryCurve(point4, point1); - var loop = new GeometryLoop - { - CurveList = - { - curve1, - curve2, - curve3, - curve4 - } - }; - var geometrySurface = new GeometrySurface - { - OuterLoop = loop - }; - var soil = new Soil(); - var kernel = new UpliftVanKernelWrapper - { - SurfaceLine = new SurfaceLine2(), - LocationExtreme = new StabilityLocation(), - LocationDaily = new StabilityLocation(), - SoilProfile = new SoilProfile2D - { - Geometry = new GeometryData - { - Points = - { - point1, - point2, - point3, - point4 - }, - Curves = - { - curve1, - curve2, - curve3, - curve4 - }, - Loops = - { - loop - }, - Surfaces = - { - geometrySurface - } - }, - Surfaces = - { - new SoilLayer2D - { - GeometrySurface = geometrySurface, - Soil = soil - } - } - }, - SoilModel = new SoilModel - { - Soils = - { - soil - } - }, - SlipPlaneUpliftVan = new SlipPlaneUpliftVan(), - MoveGrid = true, - AutomaticForbiddenZones = true, - CreateZones = true, - SlipPlaneMinimumDepth = 0, - MaximumSliceWidth = 0, - SlipPlaneMinimumLength = 0 - }; + UpliftVanKernelWrapper kernel = CreateInvalidKernel(new Soil()); // Call TestDelegate test = () => kernel.Calculate(); @@ -259,6 +181,19 @@ public void Validate_InvalidInput_ThrowsUpliftVanKernelWrapperException() { // Setup + UpliftVanKernelWrapper kernel = CreateInvalidKernel(null); + + // Call + TestDelegate test = () => kernel.Validate(); + + // Assert + var exception = Assert.Throws(test); + Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual(exception.InnerException.Message, exception.Message); + } + + private UpliftVanKernelWrapper CreateInvalidKernel(Soil soil) + { var point1 = new Point2D(0, 0); var point2 = new Point2D(1, 1); var point3 = new Point2D(2, 2); @@ -277,8 +212,12 @@ curve4 } }; - var kernel = new UpliftVanKernelWrapper + var geometrySurface = new GeometrySurface { + OuterLoop = loop + }; + return new UpliftVanKernelWrapper + { SurfaceLine = new SurfaceLine2(), LocationExtreme = new StabilityLocation(), LocationDaily = new StabilityLocation(), @@ -303,24 +242,26 @@ Loops = { loop + }, + Surfaces = + { + geometrySurface } }, Surfaces = { new SoilLayer2D { - GeometrySurface = new GeometrySurface - { - OuterLoop = loop - } + GeometrySurface = geometrySurface, + Soil = soil } } }, SoilModel = new SoilModel { Soils = { - new Soil() + soil } }, SlipPlaneUpliftVan = new SlipPlaneUpliftVan(), @@ -331,14 +272,6 @@ MaximumSliceWidth = 0, SlipPlaneMinimumLength = 0 }; - - // Call - TestDelegate test = () => kernel.Validate(); - - // Assert - var exception = Assert.Throws(test); - Assert.IsInstanceOf(exception.InnerException); - Assert.AreEqual(exception.InnerException.Message, exception.Message); } private static void AssertIrrelevantValues(StabilityModel stabilityModel) Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj =================================================================== diff -u -r5859430bf93fa658cdceb8c2731de08f0a1c1ab7 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 5859430bf93fa658cdceb8c2731de08f0a1c1ab7) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -75,6 +75,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Calculators/UpliftVan/UpliftVanCalculatorStubTest.cs =================================================================== diff -u -r0f736d81afe800a482dff027fe93128a5e967114 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Calculators/UpliftVan/UpliftVanCalculatorStubTest.cs (.../UpliftVanCalculatorStubTest.cs) (revision 0f736d81afe800a482dff027fe93128a5e967114) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Calculators/UpliftVan/UpliftVanCalculatorStubTest.cs (.../UpliftVanCalculatorStubTest.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -42,6 +42,7 @@ Assert.IsInstanceOf(calculator); Assert.IsNull(calculator.Input); Assert.IsNull(calculator.Output); + Assert.IsFalse(calculator.ThrowExceptionOnCalculate); Assert.IsFalse(calculator.ReturnValidationWarning); Assert.IsFalse(calculator.ReturnValidationError); } @@ -84,7 +85,7 @@ } [Test] - public void Validate_ReturnValidationResultsFalse_ReturnsEmptyValidationResult() + public void Validate_ReturnValidationErrorAndWarningFalse_ReturnsEmptyEnumerable() { // Setup var calculator = new UpliftVanCalculatorStub(); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/UpliftVanKernelStubTest.cs =================================================================== diff -u -r136fec781013393636cee5f7375a88013d8c5ba6 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/UpliftVanKernelStubTest.cs (.../UpliftVanKernelStubTest.cs) (revision 136fec781013393636cee5f7375a88013d8c5ba6) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Test/Kernels/UpliftVan/UpliftVanKernelStubTest.cs (.../UpliftVanKernelStubTest.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.Linq; using Deltares.WTIStability.Data.Standard; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels.UpliftVan; @@ -78,10 +79,14 @@ Assert.AreEqual($"Message 1{Environment.NewLine}Message 2", exception.Message); Assert.IsNotNull(exception.InnerException); Assert.IsFalse(kernel.Calculated); + Assert.IsFalse(kernel.Validated); + Assert.IsTrue(kernel.ThrowExceptionOnCalculate); + Assert.IsFalse(kernel.ThrowExceptionOnValidate); + Assert.IsFalse(kernel.ReturnValidationResults); } [Test] - public void Validate_ThrowExceptionOnValidateAndReturnValidationResultsFalse_SetValidatedTrue() + public void Validate_ThrowExceptionOnValidateFalse_SetValidatedTrue() { // Setup var kernel = new UpliftVanKernelStub(); @@ -90,7 +95,7 @@ Assert.IsFalse(kernel.Validated); // Call - kernel.Validate(); + kernel.Validate().ToList(); // Assert Assert.IsTrue(kernel.Validated); @@ -106,17 +111,15 @@ }; // Call - List> results = calculator.Validate(); + IEnumerable results = calculator.Validate().ToList(); // Assert - Assert.IsFalse(calculator.Validated); - CollectionAssert.AreEqual(new List> - { - new Tuple(ValidationResultType.Warning, "Validation Warning"), - new Tuple(ValidationResultType.Error, "Validation Error"), - new Tuple(ValidationResultType.Info, "Validation Info"), - new Tuple(ValidationResultType.Debug, "Validation Debug") - }, results); + Assert.IsTrue(calculator.Validated); + Assert.AreEqual(4, results.Count()); + AssertValidationResult(new ValidationResult(ValidationResultType.Warning, "Validation Warning"), results.ElementAt(0)); + AssertValidationResult(new ValidationResult(ValidationResultType.Error, "Validation Error"), results.ElementAt(1)); + AssertValidationResult(new ValidationResult(ValidationResultType.Info, "Validation Info"), results.ElementAt(2)); + AssertValidationResult(new ValidationResult(ValidationResultType.Debug, "Validation Debug"), results.ElementAt(3)); } [Test] @@ -132,13 +135,19 @@ Assert.IsFalse(kernel.Validated); // Call - TestDelegate test = () => kernel.Validate(); + TestDelegate test = () => kernel.Validate().ToList(); // Assert var exception = Assert.Throws(test); Assert.AreEqual($"Message 1{Environment.NewLine}Message 2", exception.Message); Assert.IsNotNull(exception.InnerException); Assert.IsFalse(kernel.Validated); } + + private void AssertValidationResult(IValidationResult expected, IValidationResult actual) + { + Assert.AreEqual(expected.MessageType, actual.MessageType); + Assert.AreEqual(expected.Text, actual.Text); + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/UpliftVan/UpliftVanCalculatorStub.cs =================================================================== diff -u -r0f736d81afe800a482dff027fe93128a5e967114 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/UpliftVan/UpliftVanCalculatorStub.cs (.../UpliftVanCalculatorStub.cs) (revision 0f736d81afe800a482dff027fe93128a5e967114) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/UpliftVan/UpliftVanCalculatorStub.cs (.../UpliftVanCalculatorStub.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -33,14 +33,29 @@ /// public class UpliftVanCalculatorStub : IUpliftVanCalculator { + /// + /// Gets or sets the Uplift Van calculator input. + /// public UpliftVanCalculatorInput Input { get; set; } + /// + /// Gets or sets the Uplift Van calculator output. + /// public UpliftVanCalculatorResult Output { get; private set; } + /// + /// Indicator whether an exception must be thrown when performing the calculation. + /// public bool ThrowExceptionOnCalculate { get; set; } + /// + /// Indicator whether an error message must be returned when performing the validation. + /// public bool ReturnValidationError { get; set; } + /// + /// Indicator whether a warning message must be returned when performing the validation. + /// public bool ReturnValidationWarning { get; set; } public UpliftVanCalculatorResult Calculate() @@ -54,16 +69,14 @@ public IEnumerable Validate() { - var validationResults = new List(); if (ReturnValidationError) { - validationResults.Add(new UpliftVanValidationResult(UpliftVanValidationResultType.Error, "Validation Error")); + yield return new UpliftVanValidationResult(UpliftVanValidationResultType.Error, "Validation Error"); } if (ReturnValidationWarning) { - validationResults.Add(new UpliftVanValidationResult(UpliftVanValidationResultType.Warning, "Validation Warning")); + yield return new UpliftVanValidationResult(UpliftVanValidationResultType.Warning, "Validation Warning"); } - return validationResults; } private static UpliftVanCalculatorResult CreateUpliftVanCalculatorResult() Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/UpliftVanKernelStub.cs =================================================================== diff -u -r7822834024ae12c82ec93ba3f57556cb4a503296 -rcf7e0b124334ae558a5d8dee4fc515577d5f6f25 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/UpliftVanKernelStub.cs (.../UpliftVanKernelStub.cs) (revision 7822834024ae12c82ec93ba3f57556cb4a503296) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Kernels/UpliftVan/UpliftVanKernelStub.cs (.../UpliftVanKernelStub.cs) (revision cf7e0b124334ae558a5d8dee4fc515577d5f6f25) @@ -106,7 +106,7 @@ Calculated = true; } - public List> Validate() + public IEnumerable Validate() { if (ThrowExceptionOnValidate) { @@ -115,17 +115,13 @@ if (ReturnValidationResults) { - return new List> - { - new Tuple(ValidationResultType.Warning, "Validation Warning"), - new Tuple(ValidationResultType.Error, "Validation Error"), - new Tuple(ValidationResultType.Info, "Validation Info"), - new Tuple(ValidationResultType.Debug, "Validation Debug") - }; + yield return new ValidationResult(ValidationResultType.Warning, "Validation Warning"); + yield return new ValidationResult(ValidationResultType.Error, "Validation Error"); + yield return new ValidationResult(ValidationResultType.Info, "Validation Info"); + yield return new ValidationResult(ValidationResultType.Debug, "Validation Debug"); } Validated = true; - return new List>(); } } } \ No newline at end of file