Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsSlidingCurveResultCreator.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsSlidingCurveResultCreator.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsSlidingCurveResultCreator.cs (revision dd2c47d012620dd990d481838fb7ee34a4572b48) @@ -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 Core.Common.Base.Geometry; +using Deltares.WTIStability; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Result; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Creators +{ + /// + /// Creates instances. + /// + public static class MacroStabilityInwardsSlidingCurveResultCreator + { + /// + /// 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 MacroStabilityInwardsSlidingCurveResult Create(SlidingDualCircle slidingCurve) + { + if (slidingCurve == null) + { + throw new ArgumentNullException(nameof(slidingCurve)); + } + + MacroStabilityInwardsSlidingCircleResult leftCircle = slidingCurve.LeftCircleIsActive ? CreateActiveCircle(slidingCurve) : CreatePassiveCircle(slidingCurve); + MacroStabilityInwardsSlidingCircleResult rightCircle = slidingCurve.LeftCircleIsActive ? CreatePassiveCircle(slidingCurve) : CreateActiveCircle(slidingCurve); + + return new MacroStabilityInwardsSlidingCurveResult(leftCircle, rightCircle, CreateSlices(slidingCurve.Slices), + slidingCurve.HorizontalForce0, slidingCurve.HorizontalForce); + } + + private static MacroStabilityInwardsSlidingCircleResult CreateActiveCircle(SlidingDualCircle slidingCurve) + { + return new MacroStabilityInwardsSlidingCircleResult(new Point2D(slidingCurve.ActiveCircle.X, slidingCurve.ActiveCircle.Z), + slidingCurve.ActiveRadius, true, slidingCurve.ActiveForce0, slidingCurve.ActiveForce, + slidingCurve.DrivingMomentActive, slidingCurve.ResistingMomentActive); + } + + private static MacroStabilityInwardsSlidingCircleResult CreatePassiveCircle(SlidingDualCircle slidingCurve) + { + return new MacroStabilityInwardsSlidingCircleResult(new Point2D(slidingCurve.PassiveCircle.X, slidingCurve.PassiveCircle.Z), + slidingCurve.PassiveRadius, false, slidingCurve.PassiveForce0, slidingCurve.PassiveForce, + slidingCurve.DrivingMomentPassive, slidingCurve.ResistingMomentPassive); + } + + private static IEnumerable CreateSlices(IEnumerable slidingCurveSlices) + { + return slidingCurveSlices.Select( + slice => + new MacroStabilityInwardsSliceResult( + new Point2D(slice.TopLeftX, slice.TopLeftZ), + new Point2D(slice.TopRightX, slice.TopRightZ), + new Point2D(slice.BottomLeftX, slice.BottomLeftZ), + new Point2D(slice.BottomRightX, slice.BottomRightZ), + new MacroStabilityInwardsSliceResult.ConstructionProperties + { + Cohesion = slice.Cohesion, + FrictionAngle = slice.Phi, + CriticalPressure = slice.PGrens, + OverConsolidationRatio = slice.OCR, + Pop = slice.POP, + DegreeOfConsolidationPorePressureSoil = slice.DegreeofConsolidationPorePressure, + DegreeOfConsolidationPorePressureLoad = slice.PorePressureDueToDegreeOfConsolidationLoad, + Dilatancy = slice.Dilatancy, + ExternalLoad = slice.ExternalLoad, + HydrostaticPorePressure = slice.HydrostaticPorePressure, + LeftForce = slice.LeftForce, + LeftForceAngle = slice.LeftForceAngle, + LeftForceY = slice.LeftForceY, + RightForce = slice.RightForce, + RightForceAngle = slice.RightForceAngle, + RightForceY = slice.RightForceY, + LoadStress = slice.LoadStress, + NormalStress = slice.NormalStress, + PorePressure = slice.PoreOnSurface, + HorizontalPorePressure = slice.HPoreOnSurface, + VerticalPorePressure = slice.VPoreOnSurface, + PiezometricPorePressure = slice.PiezometricPorePressure, + EffectiveStress = slice.EffectiveStress, + EffectiveStressDaily = slice.EffectiveStressDaily, + ExcessPorePressure = slice.ExcessPorePressure, + ShearStress = slice.ShearStress, + SoilStress = slice.SoilStress, + TotalPorePressure = slice.TotalPorePressure, + TotalStress = slice.TotalStress, + Weight = slice.Weight + })).ToArray(); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsUpliftVanCalculationGridResultCreator.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsUpliftVanCalculationGridResultCreator.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/MacroStabilityInwardsUpliftVanCalculationGridResultCreator.cs (revision dd2c47d012620dd990d481838fb7ee34a4572b48) @@ -0,0 +1,62 @@ +// 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; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Result; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Creators +{ + /// + /// 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 Fisheye: Tag dd2c47d012620dd990d481838fb7ee34a4572b48 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Result/MacroStabilityInwardsSlidingCurveResultCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag dd2c47d012620dd990d481838fb7ee34a4572b48 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Result/MacroStabilityInwardsUpliftVanCalculationGridResultCreator.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj =================================================================== diff -u -r6d840ea50bda7649e8b2c8f2272dca8a3cab0200 -rdd2c47d012620dd990d481838fb7ee34a4572b48 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision 6d840ea50bda7649e8b2c8f2272dca8a3cab0200) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Ringtoets.MacroStabilityInwards.KernelWrapper.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.csproj) (revision dd2c47d012620dd990d481838fb7ee34a4572b48) @@ -57,9 +57,9 @@ - + - + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsSlidingCurveResultCreatorTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsSlidingCurveResultCreatorTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsSlidingCurveResultCreatorTest.cs (revision dd2c47d012620dd990d481838fb7ee34a4572b48) @@ -0,0 +1,273 @@ +// 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; +using Deltares.WTIStability.Data.Geo; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Result; +using Point2D = Core.Common.Base.Geometry.Point2D; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Creators +{ + [TestFixture] + public class MacroStabilityInwardsSlidingCurveResultCreatorTest + { + [Test] + public void Create_SlidingCurveNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsSlidingCurveResultCreator.Create(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("slidingCurve", exception.ParamName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Create_WithSlidingCurve_ReturnSlidingCurveResult(bool leftCircleIsActive) + { + // Setup + var random = new Random(21); + double activeCircleX = random.Next(); + double activeCircleZ = random.Next(); + + double activeCircleIteratedForce = random.Next(); + double activeCircleNonIteratedForce = random.Next(); + double activeCircleRadius = random.Next(); + double activeCircleDrivingMoment = random.Next(); + double activeCircleResistingMoment = random.Next(); + + double passiveCircleX = random.Next(); + double passiveCircleZ = random.Next(); + double passiveCircleIteratedForce = random.Next(); + double passiveCircleNonIteratedForce = random.Next(); + double passiveCircleRadius = random.Next(); + double passiveCircleDrivingMoment = random.Next(); + double passiveCircleResistingMoment = random.Next(); + + double iteratedHorizontalForce = random.Next(); + double nonIteratedHorizontalForce = random.Next(); + + var slidingCurve = new SlidingDualCircle + { + LeftCircleIsActive = leftCircleIsActive, + ActiveCircle = new GeometryPoint(activeCircleX, activeCircleZ), + ActiveForce = activeCircleIteratedForce, + ActiveForce0 = activeCircleNonIteratedForce, + ActiveRadius = activeCircleRadius, + DrivingMomentActive = activeCircleDrivingMoment, + ResistingMomentActive = activeCircleResistingMoment, + PassiveCircle = new GeometryPoint(passiveCircleX, passiveCircleZ), + PassiveForce = passiveCircleIteratedForce, + PassiveForce0 = passiveCircleNonIteratedForce, + PassiveRadius = passiveCircleRadius, + DrivingMomentPassive = passiveCircleDrivingMoment, + ResistingMomentPassive = passiveCircleResistingMoment, + HorizontalForce = iteratedHorizontalForce, + HorizontalForce0 = nonIteratedHorizontalForce + }; + + // Call + MacroStabilityInwardsSlidingCurveResult result = MacroStabilityInwardsSlidingCurveResultCreator.Create(slidingCurve); + + // Assert + AssertActiveCircle(leftCircleIsActive ? result.LeftCircle : result.RightCircle, + activeCircleX, activeCircleZ, activeCircleIteratedForce, + activeCircleNonIteratedForce, activeCircleRadius, + activeCircleDrivingMoment, activeCircleResistingMoment); + + AssertPassiveCircle(leftCircleIsActive ? result.RightCircle : result.LeftCircle, + passiveCircleX, passiveCircleZ, passiveCircleIteratedForce, + passiveCircleNonIteratedForce, passiveCircleRadius, + passiveCircleDrivingMoment, passiveCircleResistingMoment); + + Assert.AreEqual(iteratedHorizontalForce, result.IteratedHorizontalForce); + Assert.AreEqual(nonIteratedHorizontalForce, result.NonIteratedHorizontalForce); + } + + [Test] + public void Create_SlidingCurveWithSlices_ReturnSlidingCurveResult() + { + // Setup + var random = new Random(21); + double topLeftX = random.NextDouble(); + double topLeftZ = random.NextDouble(); + double topRightX = random.NextDouble(); + double topRightZ = random.NextDouble(); + double bottomLeftX = random.NextDouble(); + double bottomLeftZ = random.NextDouble(); + double bottomRightX = random.NextDouble(); + double bottomRightZ = random.NextDouble(); + double cohesion = random.NextDouble(); + double frictionAngle = random.NextDouble(); + double criticalPressure = random.NextDouble(); + double overConsolidationRatio = random.NextDouble(); + double pop = random.NextDouble(); + double degreeOfConsolidationPorePressureSoil = random.NextDouble(); + double degreeOfConsolidationPorePressureLoad = random.NextDouble(); + double dilatancy = random.NextDouble(); + double externalLoad = random.NextDouble(); + double hydrostaticPorePressure = random.NextDouble(); + double leftForce = random.NextDouble(); + double leftForceAngle = random.NextDouble(); + double leftForceY = random.NextDouble(); + double rightForce = random.NextDouble(); + double rightForceAngle = random.NextDouble(); + double rightForceY = random.NextDouble(); + double loadStress = random.NextDouble(); + double normalStress = random.NextDouble(); + double porePressure = random.NextDouble(); + double horizontalPorePressure = random.NextDouble(); + double verticalPorePressure = random.NextDouble(); + double piezometricPorePressure = random.NextDouble(); + double effectiveStress = random.NextDouble(); + double effectiveStressDaily = random.NextDouble(); + double excessPorePressure = random.NextDouble(); + double shearStress = random.NextDouble(); + double soilStress = random.NextDouble(); + double totalPorePressure = random.NextDouble(); + double totalStress = random.NextDouble(); + double weight = random.NextDouble(); + + var slidingCurve = new SlidingDualCircle + { + Slices = + { + new Slice + { + TopLeftX = topLeftX, + TopLeftZ = topLeftZ, + TopRightX = topRightX, + TopRightZ = topRightZ, + BottomLeftX = bottomLeftX, + BottomLeftZ = bottomLeftZ, + BottomRightX = bottomRightX, + BottomRightZ = bottomRightZ, + Cohesion = cohesion, + Phi = frictionAngle, + PGrens = criticalPressure, + OCR = overConsolidationRatio, + POP = pop, + DegreeofConsolidationPorePressure = degreeOfConsolidationPorePressureSoil, + PorePressureDueToDegreeOfConsolidationLoad = degreeOfConsolidationPorePressureLoad, + Dilatancy = dilatancy, + ExternalLoad = externalLoad, + HydrostaticPorePressure = hydrostaticPorePressure, + LeftForce = leftForce, + LeftForceAngle = leftForceAngle, + LeftForceY = leftForceY, + RightForce = rightForce, + RightForceAngle = rightForceAngle, + RightForceY = rightForceY, + LoadStress = loadStress, + NormalStress = normalStress, + PoreOnSurface = porePressure, + HPoreOnSurface = horizontalPorePressure, + VPoreOnSurface = verticalPorePressure, + PiezometricPorePressure = piezometricPorePressure, + EffectiveStress = effectiveStress, + EffectiveStressDaily = effectiveStressDaily, + ExcessPorePressure = excessPorePressure, + ShearStress = shearStress, + SoilStress = soilStress, + TotalPorePressure = totalPorePressure, + TotalStress = totalStress, + Weight = weight + } + } + }; + + // Call + MacroStabilityInwardsSlidingCurveResult result = MacroStabilityInwardsSlidingCurveResultCreator.Create(slidingCurve); + + // Assert + Assert.AreEqual(1, result.Slices.Count()); + + MacroStabilityInwardsSliceResult slice = result.Slices.First(); + Assert.AreEqual(new Point2D(topLeftX, topLeftZ), slice.TopLeftPoint); + Assert.AreEqual(new Point2D(topRightX, topRightZ), slice.TopRightPoint); + Assert.AreEqual(new Point2D(bottomLeftX, bottomLeftZ), slice.BottomLeftPoint); + Assert.AreEqual(new Point2D(bottomRightX, bottomRightZ), slice.BottomRightPoint); + + Assert.AreEqual(cohesion, slice.Cohesion); + Assert.AreEqual(frictionAngle, slice.FrictionAngle); + Assert.AreEqual(criticalPressure, slice.CriticalPressure); + Assert.AreEqual(overConsolidationRatio, slice.OverConsolidationRatio); + Assert.AreEqual(pop, slice.Pop); + Assert.AreEqual(degreeOfConsolidationPorePressureSoil, slice.DegreeOfConsolidationPorePressureSoil); + Assert.AreEqual(degreeOfConsolidationPorePressureLoad, slice.DegreeOfConsolidationPorePressureLoad); + Assert.AreEqual(dilatancy, slice.Dilatancy); + Assert.AreEqual(externalLoad, slice.ExternalLoad); + Assert.AreEqual(hydrostaticPorePressure, slice.HydrostaticPorePressure); + Assert.AreEqual(leftForce, slice.LeftForce); + Assert.AreEqual(leftForceAngle, slice.LeftForceAngle); + Assert.AreEqual(leftForceY, slice.LeftForceY); + Assert.AreEqual(rightForce, slice.RightForce); + Assert.AreEqual(rightForceAngle, slice.RightForceAngle); + Assert.AreEqual(rightForceY, slice.RightForceY); + Assert.AreEqual(loadStress, slice.LoadStress); + Assert.AreEqual(normalStress, slice.NormalStress); + Assert.AreEqual(porePressure, slice.PorePressure); + Assert.AreEqual(horizontalPorePressure, slice.HorizontalPorePressure); + Assert.AreEqual(verticalPorePressure, slice.VerticalPorePressure); + Assert.AreEqual(piezometricPorePressure, slice.PiezometricPorePressure); + Assert.AreEqual(effectiveStress, slice.EffectiveStress); + Assert.AreEqual(effectiveStressDaily, slice.EffectiveStressDaily); + Assert.AreEqual(excessPorePressure, slice.ExcessPorePressure); + Assert.AreEqual(shearStress, slice.ShearStress); + Assert.AreEqual(soilStress, slice.SoilStress); + Assert.AreEqual(totalPorePressure, slice.TotalPorePressure); + Assert.AreEqual(totalStress, slice.TotalStress); + Assert.AreEqual(weight, slice.Weight); + } + + private static void AssertActiveCircle(MacroStabilityInwardsSlidingCircleResult circle, double x, double z, double iteratedForce, + double nonIteratedForce, double radius, double drivingMoment, double resistingMoment) + { + Assert.IsTrue(circle.IsActive); + AssertCircle(circle, x, z, iteratedForce, nonIteratedForce, radius, drivingMoment, resistingMoment); + } + + private static void AssertPassiveCircle(MacroStabilityInwardsSlidingCircleResult circle, double x, double z, double iteratedForce, + double nonIteratedForce, double radius, double drivingMoment, double resistingMoment) + { + Assert.IsFalse(circle.IsActive); + AssertCircle(circle, x, z, iteratedForce, nonIteratedForce, radius, drivingMoment, resistingMoment); + } + + private static void AssertCircle(MacroStabilityInwardsSlidingCircleResult circle, double x, double z, double iteratedForce, + double nonIteratedForce, double radius, double drivingMoment, double resistingMoment) + { + Assert.AreEqual(x, circle.Center.X); + Assert.AreEqual(z, circle.Center.Y); + Assert.AreEqual(iteratedForce, circle.IteratedForce); + Assert.AreEqual(nonIteratedForce, circle.NonIteratedForce); + Assert.AreEqual(radius, circle.Radius); + Assert.AreEqual(drivingMoment, circle.DrivingMoment); + Assert.AreEqual(resistingMoment, circle.ResistingMoment); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsUpliftVanCalculationGridResultCreatorTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsUpliftVanCalculationGridResultCreatorTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/MacroStabilityInwardsUpliftVanCalculationGridResultCreatorTest.cs (revision dd2c47d012620dd990d481838fb7ee34a4572b48) @@ -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.Linq; +using Deltares.WTIStability; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Creators; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Result; + +namespace Ringtoets.MacroStabilityInwards.KernelWrapper.Test.Creators +{ + [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 Fisheye: Tag dd2c47d012620dd990d481838fb7ee34a4572b48 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Result/MacroStabilityInwardsSlidingCurveResultCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag dd2c47d012620dd990d481838fb7ee34a4572b48 refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Result/MacroStabilityInwardsUpliftVanCalculationGridResultCreatorTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj =================================================================== diff -u -r6d840ea50bda7649e8b2c8f2272dca8a3cab0200 -rdd2c47d012620dd990d481838fb7ee34a4572b48 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision 6d840ea50bda7649e8b2c8f2272dca8a3cab0200) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj (.../Ringtoets.MacroStabilityInwards.KernelWrapper.Test.csproj) (revision dd2c47d012620dd990d481838fb7ee34a4572b48) @@ -72,9 +72,9 @@ - + - +