Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/IWaternetCalculator.cs =================================================================== diff -u -rfc7a77a30ababe1d51f8fd39fa0fa599eb8011cd -r909bc295bbe951245e30dd57407efc924be76e12 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/IWaternetCalculator.cs (.../IWaternetCalculator.cs) (revision fc7a77a30ababe1d51f8fd39fa0fa599eb8011cd) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/IWaternetCalculator.cs (.../IWaternetCalculator.cs) (revision 909bc295bbe951245e30dd57407efc924be76e12) @@ -41,6 +41,6 @@ /// A . /// Thrown when an error /// occurs during the calculation. - void Calculate(); + WaternetCalculatorResult Calculate(); } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/WaternetCalculator.cs =================================================================== diff -u -re2fce8d8e6cf66d649e62ca10b22536f44c266c2 -r909bc295bbe951245e30dd57407efc924be76e12 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/WaternetCalculator.cs (.../WaternetCalculator.cs) (revision e2fce8d8e6cf66d649e62ca10b22536f44c266c2) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Calculators/Waternet/WaternetCalculator.cs (.../WaternetCalculator.cs) (revision 909bc295bbe951245e30dd57407efc924be76e12) @@ -24,7 +24,9 @@ using System.Linq; using Deltares.WTIStability.Data.Geo; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Input; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Output; using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Input; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Output; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels.Waternet; using SoilLayer = Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilLayer; @@ -61,9 +63,11 @@ this.factory = factory; } - public void Calculate() + public WaternetCalculatorResult Calculate() { IWaternetKernel waternetKernel = CalculateWaternet(); + + return WaternetCalculatorResultCreator.Create(waternetKernel.Waternet); } private IWaternetKernel CalculateWaternet() Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/Waternet/WaternetCalculatorTest.cs =================================================================== diff -u -r00e2b17f81b30dfe4b71e3535424256d7cd02895 -r909bc295bbe951245e30dd57407efc924be76e12 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/Waternet/WaternetCalculatorTest.cs (.../WaternetCalculatorTest.cs) (revision 00e2b17f81b30dfe4b71e3535424256d7cd02895) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Calculators/Waternet/WaternetCalculatorTest.cs (.../WaternetCalculatorTest.cs) (revision 909bc295bbe951245e30dd57407efc924be76e12) @@ -30,16 +30,19 @@ using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Input; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Output; using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Input; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels; using Ringtoets.MacroStabilityInwards.KernelWrapper.Kernels.Waternet; +using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Calculators.Waternet.Output; using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Kernels; using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Kernels.UpliftVan.Input; using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Kernels.Waternet; using Ringtoets.MacroStabilityInwards.Primitives; using Point2D = Core.Common.Base.Geometry.Point2D; using SoilLayer = Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilLayer; using SoilProfile = Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Input.SoilProfile; +using WtiStabilityWaternet = Deltares.WTIStability.Data.Geo.Waternet; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Calculators.Waternet { @@ -103,6 +106,7 @@ var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); WaternetKernelStub waternetKernel = testMacroStabilityInwardsKernelFactory.LastCreatedWaternetKernel; + SetCompleteKernelOutput(waternetKernel); // Call new WaternetCalculator(input, testMacroStabilityInwardsKernelFactory).Calculate(); @@ -119,6 +123,7 @@ var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); WaternetKernelStub waternetKernel = testMacroStabilityInwardsKernelFactory.LastCreatedWaternetKernel; + SetCompleteKernelOutput(waternetKernel); // Call new WaternetCalculator(input, testMacroStabilityInwardsKernelFactory).Calculate(); @@ -159,6 +164,78 @@ Assert.AreEqual(exception.InnerException.Message, exception.Message); } + [Test] + public void Calculate_KernelWithCompleteOutput_OutputCorrectlySetToCalculator() + { + WaternetCalculatorInput input = CreateValidCalculatorInput(); + var testMacroStabilityInwardsKernelFactory = new TestMacroStabilityInwardsKernelFactory(); + + WaternetKernelStub kernel = testMacroStabilityInwardsKernelFactory.LastCreatedWaternetKernel; + SetCompleteKernelOutput(kernel); + + // Call + WaternetCalculatorResult result = new WaternetCalculator(input, testMacroStabilityInwardsKernelFactory).Calculate(); + + // Assert + Assert.IsNotNull(result); + var expectedPhreaticLines = new List + { + kernel.Waternet.PhreaticLine + }; + expectedPhreaticLines.AddRange(kernel.Waternet.HeadLineList); + + WaternetCalculatorOutputAssert.AssertPhreaticLines(expectedPhreaticLines.ToArray(), result.PhreaticLines.ToArray()); + WaternetCalculatorOutputAssert.AssertWaternetLines(kernel.Waternet.WaternetLineList.ToArray(), result.WaternetLines.ToArray()); + } + + private static void SetCompleteKernelOutput(WaternetKernelStub kernel) + { + kernel.Waternet = CreateValidOutput(); + } + + private static WtiStabilityWaternet CreateValidOutput() + { + var headLine = new HeadLine + { + Name = "line 1", + Points = + { + new GeometryPoint(0, 0), + new GeometryPoint(1, 1) + } + }; + + return new WtiStabilityWaternet + { + HeadLineList = + { + headLine + }, + PhreaticLine = new PhreaticLine + { + Name = "line 2", + Points = + { + new GeometryPoint(2, 2), + new GeometryPoint(3, 3) + } + }, + WaternetLineList = + { + new WaternetLine + { + Name = "line 3", + Points = + { + new GeometryPoint(4, 4), + new GeometryPoint(5, 5) + }, + HeadLine = headLine + } + } + }; + } + private static WaternetCalculatorInput CreateCompleteCalculatorInput() { var random = new Random(21); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/Output/WaternetCalculatorResultCreatorTest.cs =================================================================== diff -u -r262e5ee967e56798894d0ea3167d110d0aea9684 -r909bc295bbe951245e30dd57407efc924be76e12 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/Output/WaternetCalculatorResultCreatorTest.cs (.../WaternetCalculatorResultCreatorTest.cs) (revision 262e5ee967e56798894d0ea3167d110d0aea9684) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/Output/WaternetCalculatorResultCreatorTest.cs (.../WaternetCalculatorResultCreatorTest.cs) (revision 909bc295bbe951245e30dd57407efc924be76e12) @@ -25,7 +25,7 @@ using NUnit.Framework; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Output; using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators.Output; -using Point2D = Core.Common.Base.Geometry.Point2D; +using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Calculators.Waternet.Output; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Creators.Output { @@ -93,44 +93,16 @@ WaternetCalculatorResult result = WaternetCalculatorResultCreator.Create(waternet); // Assert - AssertPhreaticLines(new GeometryPointString[] + WaternetCalculatorOutputAssert.AssertPhreaticLines(new GeometryPointString[] { phreaticLine, headLine }, result.PhreaticLines.ToArray()); - AssertWaternetLines(new[] + WaternetCalculatorOutputAssert.AssertWaternetLines(new[] { waternetLine }, result.WaternetLines.ToArray()); } - - private static void AssertWaternetLines(WaternetLine[] expectedLines, WaternetLineResult[] actualLines) - { - Assert.AreEqual(expectedLines.Length, actualLines.Length); - - for (var i = 0; i < expectedLines.Length; i++) - { - Assert.AreEqual(expectedLines[i].Name, actualLines[i].Name); - CollectionAssert.AreEqual(expectedLines[i].Points.Select(p => new Point2D(p.X, p.Z)), actualLines[i].Geometry); - AssertPhreaticLine(expectedLines[i].HeadLine, actualLines[i].PhreaticLine); - } - } - - private static void AssertPhreaticLines(GeometryPointString[] expectedLines, WaternetPhreaticLineResult[] actualLines) - { - Assert.AreEqual(expectedLines.Length, actualLines.Length); - - for (var i = 0; i < expectedLines.Length; i++) - { - AssertPhreaticLine(expectedLines[i], actualLines[i]); - } - } - - private static void AssertPhreaticLine(GeometryPointString expectedLine, WaternetPhreaticLineResult actualLine) - { - Assert.AreEqual(expectedLine.Name, actualLine.Name); - CollectionAssert.AreEqual(expectedLine.Points.Select(p => new Point2D(p.X, p.Z)), actualLine.Geometry); - } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/Waternet/Output/WaternetCalculatorOutputAssert.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/Waternet/Output/WaternetCalculatorOutputAssert.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/Waternet/Output/WaternetCalculatorOutputAssert.cs (revision 909bc295bbe951245e30dd57407efc924be76e12) @@ -0,0 +1,84 @@ +// 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.Linq; +using Deltares.WTIStability.Data.Geo; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Output; +using Point2D = Core.Common.Base.Geometry.Point2D; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Calculators.Waternet.Output +{ + /// + /// Class for asserting Waternet calculator output. + /// + public static class WaternetCalculatorOutputAssert + { + /// + /// Asserts whether is equal to . + /// + /// The expected array. + /// The actual array. + /// Thrown when + /// is not equal to . + public static void AssertWaternetLines(WaternetLine[] expected, WaternetLineResult[] actual) + { + Assert.AreEqual(expected.Length, actual.Length); + + for (var i = 0; i < expected.Length; i++) + { + Assert.AreEqual(expected[i].Name, actual[i].Name); + CollectionAssert.AreEqual(expected[i].Points.Select(p => new Point2D(p.X, p.Z)), actual[i].Geometry); + AssertPhreaticLine(expected[i].HeadLine, actual[i].PhreaticLine); + } + } + + /// + /// Asserts whether is equal to . + /// + /// The expected array. + /// The actual array. + /// Thrown when + /// is not equal to . + public static void AssertPhreaticLines(GeometryPointString[] expected, WaternetPhreaticLineResult[] actual) + { + Assert.AreEqual(expected.Length, actual.Length); + + for (var i = 0; i < expected.Length; i++) + { + AssertPhreaticLine(expected[i], actual[i]); + } + } + + /// + /// Asserts whether is equal to . + /// + /// The expected . + /// The actual . + /// Thrown when + /// is not equal to . + private static void AssertPhreaticLine(GeometryPointString expected, WaternetPhreaticLineResult actual) + { + Assert.AreEqual(expected.Name, actual.Name); + CollectionAssert.AreEqual(expected.Points.Select(p => new Point2D(p.X, p.Z)), actual.Geometry); + } + } +} Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/Waternet/WaternetCalculatorStub.cs =================================================================== diff -u -r99f866932bc3dc21c0a6129e8c3e425e795512c8 -r909bc295bbe951245e30dd57407efc924be76e12 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/Waternet/WaternetCalculatorStub.cs (.../WaternetCalculatorStub.cs) (revision 99f866932bc3dc21c0a6129e8c3e425e795512c8) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Calculators/Waternet/WaternetCalculatorStub.cs (.../WaternetCalculatorStub.cs) (revision 909bc295bbe951245e30dd57407efc924be76e12) @@ -21,6 +21,7 @@ using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Input; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.Waternet.Output; namespace Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Calculators.Waternet { @@ -34,6 +35,9 @@ /// public WaternetCalculatorInput Input { get; set; } - public void Calculate() {} + public WaternetCalculatorResult Calculate() + { + return null; + } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj =================================================================== diff -u -r5b9f582b5c7815a95c306d624a11c2d771840f91 -r909bc295bbe951245e30dd57407efc924be76e12 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj) (revision 5b9f582b5c7815a95c306d624a11c2d771840f91) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil/Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.csproj) (revision 909bc295bbe951245e30dd57407efc924be76e12) @@ -62,6 +62,7 @@ +