Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Result/MacroStabilityInwardsUpliftVanCalculationGridResultCreator.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Result/MacroStabilityInwardsUpliftVanCalculationGridResultCreator.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Result/MacroStabilityInwardsUpliftVanCalculationGridResultCreator.cs (revision 6d840ea50bda7649e8b2c8f2272dca8a3cab0200) @@ -0,0 +1,61 @@ +// 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.Linq; +using Deltares.WTIStability; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Result +{ + /// + /// Creates instances. + /// + public static class MacroStabilityInwardsUpliftVanCalculationGridResultCreator + { + /// + /// Creates a based on the information + /// given in the . + /// + /// The output to create the result for. + /// A new with information + /// taken from the + /// Thrown when + /// is null. + public static MacroStabilityInwardsUpliftVanCalculationGridResult Create(SlipPlaneUpliftVan slipPlaneUpliftVan) + { + if (slipPlaneUpliftVan == null) + { + throw new ArgumentNullException(nameof(slipPlaneUpliftVan)); + } + + MacroStabilityInwardsGridResult leftGrid = CreateGrid(slipPlaneUpliftVan.SlipPlaneLeftGrid); + MacroStabilityInwardsGridResult rightGrid = CreateGrid(slipPlaneUpliftVan.SlipPlaneRightGrid); + + return new MacroStabilityInwardsUpliftVanCalculationGridResult(leftGrid, rightGrid, slipPlaneUpliftVan.SlipPlaneTangentLine.BoundaryHeights + .Select(tl => tl.Height)); + } + + private static MacroStabilityInwardsGridResult CreateGrid(SlipCircleGrid grid) + { + return new MacroStabilityInwardsGridResult(grid.GridXLeft, grid.GridXRight, grid.GridZTop, grid.GridZBottom, grid.GridXNumber, grid.GridZNumber); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj =================================================================== diff -u -r16f3a2d1ff6ed7e05949113116c4cfd081f5ddcd -r6d840ea50bda7649e8b2c8f2272dca8a3cab0200 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision 16f3a2d1ff6ed7e05949113116c4cfd081f5ddcd) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision 6d840ea50bda7649e8b2c8f2272dca8a3cab0200) @@ -59,6 +59,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Result/MacroStabilityInwardsUpliftVanCalculationGridResultCreatorTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Result/MacroStabilityInwardsUpliftVanCalculationGridResultCreatorTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Result/MacroStabilityInwardsUpliftVanCalculationGridResultCreatorTest.cs (revision 6d840ea50bda7649e8b2c8f2272dca8a3cab0200) @@ -0,0 +1,117 @@ +// 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; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Result; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Result +{ + [TestFixture] + public class MacroStabilityInwardsUpliftVanCalculationGridResultCreatorTest + { + [Test] + public void Create_SlipPlaneUpliftVanNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsUpliftVanCalculationGridResultCreator.Create(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("slipPlaneUpliftVan", exception.ParamName); + } + + [Test] + public void Create_WithSlipPlaneUpliftVan_ReturnUpliftVanCalculationGridResult() + { + // Setup + var random = new Random(21); + double leftGridXLeft = random.Next(); + double leftGridXRight = random.Next(); + double leftGridZTop = random.Next(); + double leftGridZBottom = random.Next(); + int leftGridHorizontalPoints = random.Next(); + int leftGridVerticalPoints = random.Next(); + + double rightGridXLeft = random.Next(); + double rightGridXRight = random.Next(); + double rightGridZTop = random.Next(); + double rightGridZBottom = random.Next(); + int rightGridHorizontalPoints = random.Next(); + int rightGridVerticalPoints = random.Next(); + + double tangentLine1 = random.Next(); + double tangentLine2 = random.Next(); + + var slipPlaneUpliftVan = new SlipPlaneUpliftVan + { + SlipPlaneLeftGrid = new SlipCircleGrid + { + GridXLeft = leftGridXLeft, + GridXRight = leftGridXRight, + GridZTop = leftGridZTop, + GridZBottom = leftGridZBottom, + GridXNumber = leftGridHorizontalPoints, + GridZNumber = leftGridVerticalPoints + }, + SlipPlaneRightGrid = new SlipCircleGrid + { + GridXLeft = rightGridXLeft, + GridXRight = rightGridXRight, + GridZTop = rightGridZTop, + GridZBottom = rightGridZBottom, + GridXNumber = rightGridHorizontalPoints, + GridZNumber = rightGridVerticalPoints + }, + SlipPlaneTangentLine = new SlipCircleTangentLine + { + BoundaryHeights = + { + new TangentLine(tangentLine1), + new TangentLine(tangentLine2) + } + } + }; + + // Call + MacroStabilityInwardsUpliftVanCalculationGridResult result = MacroStabilityInwardsUpliftVanCalculationGridResultCreator.Create(slipPlaneUpliftVan); + + // Assert + AssertGrid(slipPlaneUpliftVan.SlipPlaneLeftGrid, result.LeftGrid); + AssertGrid(slipPlaneUpliftVan.SlipPlaneRightGrid, result.RightGrid); + + CollectionAssert.AreEqual(slipPlaneUpliftVan.SlipPlaneTangentLine.BoundaryHeights.Select(sl => sl.Height), result.TangentLines); + } + + private static void AssertGrid(SlipCircleGrid originalGrid, MacroStabilityInwardsGridResult actualGrid) + { + Assert.AreEqual(originalGrid.GridXLeft, actualGrid.XLeft); + Assert.AreEqual(originalGrid.GridXRight, actualGrid.XRight); + Assert.AreEqual(originalGrid.GridZTop, actualGrid.ZTop); + Assert.AreEqual(originalGrid.GridZBottom, actualGrid.ZBottom); + Assert.AreEqual(originalGrid.GridXNumber, actualGrid.NumberOfHorizontalPoints); + Assert.AreEqual(originalGrid.GridZNumber, actualGrid.NumberOfVerticalPoints); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj =================================================================== diff -u -r16f3a2d1ff6ed7e05949113116c4cfd081f5ddcd -r6d840ea50bda7649e8b2c8f2272dca8a3cab0200 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 16f3a2d1ff6ed7e05949113116c4cfd081f5ddcd) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 6d840ea50bda7649e8b2c8f2272dca8a3cab0200) @@ -74,6 +74,7 @@ +