Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Converters/MacroStabilityInwardsCurveConverter.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Converters/MacroStabilityInwardsCurveConverter.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Converters/MacroStabilityInwardsCurveConverter.cs (revision 495c443e6e70674e616ff0bffcf2da22b73a616f) @@ -0,0 +1,111 @@ +// 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 Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Result; + +namespace Ringtoets.MacroStabilityInwards.Service.Converters +{ + /// + /// Converter to convert + /// into . + /// + internal static class MacroStabilityInwardsCurveConverter + { + /// + /// Converts + /// into . + /// + /// The result to convert. + /// The converted . + /// Thrown when + /// is null. + public static MacroStabilityInwardsSlidingCurve Convert(MacroStabilityInwardsSlidingCurveResult result) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + MacroStabilityInwardsSlidingCircle leftCircle = ConvertCircle(result.LeftCircle); + MacroStabilityInwardsSlidingCircle rightCircle = ConvertCircle(result.RightCircle); + IEnumerable slices = ConvertSlices(result.Slices); + + return new MacroStabilityInwardsSlidingCurve(leftCircle, rightCircle, slices, result.NonIteratedHorizontalForce, result.IteratedHorizontalForce); + } + + private static MacroStabilityInwardsSlidingCircle ConvertCircle(MacroStabilityInwardsSlidingCircleResult circle) + { + return new MacroStabilityInwardsSlidingCircle(circle.Center, + circle.Radius, + circle.IsActive, + circle.NonIteratedForce, + circle.IteratedForce, + circle.DrivingMoment, + circle.ResistingMoment); + } + + private static IEnumerable ConvertSlices(IEnumerable slices) + { + return slices.Select(s => new MacroStabilityInwardsSlice( + s.TopLeftPoint, + s.TopRightPoint, + s.BottomLeftPoint, + s.BottomRightPoint, + new MacroStabilityInwardsSlice.ConstructionProperties + { + Cohesion = s.Cohesion, + FrictionAngle = s.FrictionAngle, + CriticalPressure = s.CriticalPressure, + OverConsolidationRatio = s.OverConsolidationRatio, + Pop = s.Pop, + DegreeOfConsolidationPorePressureSoil = s.DegreeOfConsolidationPorePressureSoil, + DegreeOfConsolidationPorePressureLoad = s.DegreeOfConsolidationPorePressureLoad, + Dilatancy = s.Dilatancy, + ExternalLoad = s.ExternalLoad, + HydrostaticPorePressure = s.HydrostaticPorePressure, + LeftForce = s.LeftForce, + LeftForceAngle = s.LeftForceAngle, + LeftForceY = s.LeftForceY, + RightForce = s.RightForce, + RightForceAngle = s.RightForceAngle, + RightForceY = s.RightForceY, + LoadStress = s.LoadStress, + NormalStress = s.NormalStress, + PorePressure = s.PorePressure, + HorizontalPorePressure = s.HorizontalPorePressure, + VerticalPorePressure = s.VerticalPorePressure, + PiezometricPorePressure = s.PiezometricPorePressure, + EffectiveStress = s.EffectiveStress, + EffectiveStressDaily = s.EffectiveStressDaily, + ExcessPorePressure = s.ExcessPorePressure, + ShearStress = s.ShearStress, + SoilStress = s.SoilStress, + TotalPorePressure = s.TotalPorePressure, + TotalStress = s.TotalStress, + Weight = s.Weight + })).ToArray(); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Converters/MacroStabilityInwardsSlipPlaneUpliftVanConverter.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Converters/MacroStabilityInwardsSlipPlaneUpliftVanConverter.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Converters/MacroStabilityInwardsSlipPlaneUpliftVanConverter.cs (revision 495c443e6e70674e616ff0bffcf2da22b73a616f) @@ -0,0 +1,65 @@ +// 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 Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Result; + +namespace Ringtoets.MacroStabilityInwards.Service.Converters +{ + /// + /// Converter to convert + /// into . + /// + internal static class MacroStabilityInwardsSlipPlaneUpliftVanConverter + { + /// + /// Converts + /// into . + /// + /// The result to convert. + /// The converted . + /// Thrown when + /// is null. + public static MacroStabilityInwardsSlipPlaneUpliftVan Convert(MacroStabilityInwardsUpliftVanCalculationGridResult result) + { + if (result == null) + { + throw new ArgumentNullException(nameof(result)); + } + + MacroStabilityInwardsGridOutput leftGrid = ConvertGrid(result.LeftGrid); + MacroStabilityInwardsGridOutput rightGrid = ConvertGrid(result.RightGrid); + + return new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, result.TangentLines); + } + + private static MacroStabilityInwardsGridOutput ConvertGrid(MacroStabilityInwardsGridResult grid) + { + return new MacroStabilityInwardsGridOutput(grid.XLeft, + grid.XRight, + grid.ZTop, + grid.ZBottom, + grid.NumberOfHorizontalPoints, + grid.NumberOfVerticalPoints); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Properties/AssemblyInfo.cs =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -r495c443e6e70674e616ff0bffcf2da22b73a616f --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Properties/AssemblyInfo.cs (.../AssemblyInfo.cs) (revision 495c443e6e70674e616ff0bffcf2da22b73a616f) @@ -20,8 +20,10 @@ // All rights reserved. using System.Reflection; +using System.Runtime.CompilerServices; using System.Runtime.InteropServices; [assembly: AssemblyTitle("Ringtoets.MacroStabilityInwards.Service")] [assembly: AssemblyProduct("Ringtoets.MacroStabilityInwards.Service")] -[assembly: Guid("cdf3f141-32b1-4a02-9ea6-8415b1b5c0c1")] \ No newline at end of file +[assembly: Guid("cdf3f141-32b1-4a02-9ea6-8415b1b5c0c1")] +[assembly: InternalsVisibleTo("Ringtoets.MacroStabilityInwards.Service.Test")] \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Ringtoets.MacroStabilityInwards.Service.csproj =================================================================== diff -u -r91dfcac4a3eff0748168e9fc8e9400e209844363 -r495c443e6e70674e616ff0bffcf2da22b73a616f --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Ringtoets.MacroStabilityInwards.Service.csproj (.../Ringtoets.MacroStabilityInwards.Service.csproj) (revision 91dfcac4a3eff0748168e9fc8e9400e209844363) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Ringtoets.MacroStabilityInwards.Service.csproj (.../Ringtoets.MacroStabilityInwards.Service.csproj) (revision 495c443e6e70674e616ff0bffcf2da22b73a616f) @@ -39,6 +39,8 @@ Properties\GlobalAssembly.cs + + @@ -105,6 +107,7 @@ Copying.licenseheader + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/Converters/MacroStabilityInwardsCurveConverterTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/Converters/MacroStabilityInwardsCurveConverterTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/Converters/MacroStabilityInwardsCurveConverterTest.cs (revision 495c443e6e70674e616ff0bffcf2da22b73a616f) @@ -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 NUnit.Framework; +using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Result; +using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Result; +using Ringtoets.MacroStabilityInwards.Service.Converters; + +namespace Ringtoets.MacroStabilityInwards.Service.Test.Converters +{ + [TestFixture] + public class MacroStabilityInwardsCurveConverterTest + { + [Test] + public void Convert_ResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsCurveConverter.Convert(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("result", exception.ParamName); + } + + [Test] + public void Convert_WithResult_ReturnConvertedSlidingCurve() + { + // Setup + MacroStabilityInwardsSlidingCurveResult result = MacroStabilityInwardsSlidingCurveResultTestFactory.Create(); + + // Call + MacroStabilityInwardsSlidingCurve output = MacroStabilityInwardsCurveConverter.Convert(result); + + // Assert + Assert.AreEqual(result.IteratedHorizontalForce, output.IteratedHorizontalForce); + Assert.AreEqual(result.NonIteratedHorizontalForce, output.NonIteratedHorizontalForce); + AssertCircle(result.LeftCircle, output.LeftCircle); + AssertCircle(result.RightCircle, output.RightCircle); + AssertSlices(result.Slices, output.Slices); + } + + private static void AssertCircle(MacroStabilityInwardsSlidingCircleResult circleResult, MacroStabilityInwardsSlidingCircle circleOutput) + { + Assert.AreEqual(circleResult.Center, circleOutput.Center); + Assert.AreEqual(circleResult.IsActive, circleOutput.IsActive); + Assert.AreEqual(circleResult.Radius, circleOutput.Radius); + Assert.AreEqual(circleResult.DrivingMoment, circleOutput.DrivingMoment); + Assert.AreEqual(circleResult.ResistingMoment, circleOutput.ResistingMoment); + Assert.AreEqual(circleResult.IteratedForce, circleOutput.IteratedForce); + Assert.AreEqual(circleResult.NonIteratedForce, circleOutput.NonIteratedForce); + } + + private static void AssertSlices(IEnumerable resultSlices, IEnumerable outputSlices) + { + MacroStabilityInwardsSliceResult[] expectedSlices = resultSlices.ToArray(); + MacroStabilityInwardsSlice[] actualSlices = outputSlices.ToArray(); + + Assert.AreEqual(expectedSlices.Length, actualSlices.Length); + + for (var i = 0; i < expectedSlices.Length; i++) + { + Assert.AreEqual(expectedSlices[i].Cohesion, actualSlices[i].Cohesion); + Assert.AreEqual(expectedSlices[i].FrictionAngle, actualSlices[i].FrictionAngle); + Assert.AreEqual(expectedSlices[i].CriticalPressure, actualSlices[i].CriticalPressure); + Assert.AreEqual(expectedSlices[i].OverConsolidationRatio, actualSlices[i].OverConsolidationRatio); + Assert.AreEqual(expectedSlices[i].Pop, actualSlices[i].Pop); + Assert.AreEqual(expectedSlices[i].DegreeOfConsolidationPorePressureSoil, actualSlices[i].DegreeOfConsolidationPorePressureSoil); + Assert.AreEqual(expectedSlices[i].DegreeOfConsolidationPorePressureLoad, actualSlices[i].DegreeOfConsolidationPorePressureLoad); + Assert.AreEqual(expectedSlices[i].Dilatancy, actualSlices[i].Dilatancy); + Assert.AreEqual(expectedSlices[i].ExternalLoad, actualSlices[i].ExternalLoad); + Assert.AreEqual(expectedSlices[i].HydrostaticPorePressure, actualSlices[i].HydrostaticPorePressure); + Assert.AreEqual(expectedSlices[i].LeftForce, actualSlices[i].LeftForce); + Assert.AreEqual(expectedSlices[i].LeftForceAngle, actualSlices[i].LeftForceAngle); + Assert.AreEqual(expectedSlices[i].LeftForceY, actualSlices[i].LeftForceY); + Assert.AreEqual(expectedSlices[i].RightForce, actualSlices[i].RightForce); + Assert.AreEqual(expectedSlices[i].RightForceAngle, actualSlices[i].RightForceAngle); + Assert.AreEqual(expectedSlices[i].RightForceY, actualSlices[i].RightForceY); + Assert.AreEqual(expectedSlices[i].LoadStress, actualSlices[i].LoadStress); + Assert.AreEqual(expectedSlices[i].NormalStress, actualSlices[i].NormalStress); + Assert.AreEqual(expectedSlices[i].PorePressure, actualSlices[i].PorePressure); + Assert.AreEqual(expectedSlices[i].HorizontalPorePressure, actualSlices[i].HorizontalPorePressure); + Assert.AreEqual(expectedSlices[i].VerticalPorePressure, actualSlices[i].VerticalPorePressure); + Assert.AreEqual(expectedSlices[i].PiezometricPorePressure, actualSlices[i].PiezometricPorePressure); + Assert.AreEqual(expectedSlices[i].EffectiveStress, actualSlices[i].EffectiveStress); + Assert.AreEqual(expectedSlices[i].EffectiveStressDaily, actualSlices[i].EffectiveStressDaily); + Assert.AreEqual(expectedSlices[i].ExcessPorePressure, actualSlices[i].ExcessPorePressure); + Assert.AreEqual(expectedSlices[i].ShearStress, actualSlices[i].ShearStress); + Assert.AreEqual(expectedSlices[i].SoilStress, actualSlices[i].SoilStress); + Assert.AreEqual(expectedSlices[i].TotalPorePressure, actualSlices[i].TotalPorePressure); + Assert.AreEqual(expectedSlices[i].TotalStress, actualSlices[i].TotalStress); + Assert.AreEqual(expectedSlices[i].Weight, actualSlices[i].Weight); + } + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/Converters/MacroStabilityInwardsSlipPlaneUpliftVanConverterTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/Converters/MacroStabilityInwardsSlipPlaneUpliftVanConverterTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/Converters/MacroStabilityInwardsSlipPlaneUpliftVanConverterTest.cs (revision 495c443e6e70674e616ff0bffcf2da22b73a616f) @@ -0,0 +1,79 @@ +// 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.Data; +using Ringtoets.MacroStabilityInwards.KernelWrapper.Result; +using Ringtoets.MacroStabilityInwards.KernelWrapper.TestUtil.Result; +using Ringtoets.MacroStabilityInwards.Service.Converters; + +namespace Ringtoets.MacroStabilityInwards.Service.Test.Converters +{ + [TestFixture] + public class MacroStabilityInwardsSlipPlaneUpliftVanConverterTest + { + [Test] + public void Convert_ResultNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => MacroStabilityInwardsSlipPlaneUpliftVanConverter.Convert(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("result", exception.ParamName); + } + + [Test] + public void Convert_WithResult_ReturnConvertedSlipPlaneUpliftVan() + { + // Setup + MacroStabilityInwardsGridResult leftGrid = MacroStabilityInwardsGridResultTestFactory.Create(); + MacroStabilityInwardsGridResult rightGrid = MacroStabilityInwardsGridResultTestFactory.Create(); + var tangentLines = new[] + { + 3, + 2, + 1.5 + }; + + var result = new MacroStabilityInwardsUpliftVanCalculationGridResult(leftGrid, rightGrid, tangentLines); + + // Call + MacroStabilityInwardsSlipPlaneUpliftVan output = MacroStabilityInwardsSlipPlaneUpliftVanConverter.Convert(result); + + // Assert + CollectionAssert.AreEqual(tangentLines, output.TangentLines); + AssertGrid(leftGrid, output.LeftGrid); + AssertGrid(rightGrid, output.RightGrid); + } + + private static void AssertGrid(MacroStabilityInwardsGridResult expectedGrid, MacroStabilityInwardsGridOutput actualGrid) + { + Assert.AreEqual(expectedGrid.XLeft, actualGrid.XLeft); + Assert.AreEqual(expectedGrid.XRight, actualGrid.XRight); + Assert.AreEqual(expectedGrid.ZTop, actualGrid.ZTop); + Assert.AreEqual(expectedGrid.ZBottom, actualGrid.ZBottom); + Assert.AreEqual(expectedGrid.NumberOfHorizontalPoints, actualGrid.NumberOfHorizontalPoints); + Assert.AreEqual(expectedGrid.NumberOfVerticalPoints, actualGrid.NumberOfVerticalPoints); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/Ringtoets.MacroStabilityInwards.Service.Test.csproj =================================================================== diff -u -r966dc7335defa901104fd4168d57c08315db2de0 -r495c443e6e70674e616ff0bffcf2da22b73a616f --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/Ringtoets.MacroStabilityInwards.Service.Test.csproj (.../Ringtoets.MacroStabilityInwards.Service.Test.csproj) (revision 966dc7335defa901104fd4168d57c08315db2de0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Service.Test/Ringtoets.MacroStabilityInwards.Service.Test.csproj (.../Ringtoets.MacroStabilityInwards.Service.Test.csproj) (revision 495c443e6e70674e616ff0bffcf2da22b73a616f) @@ -56,6 +56,8 @@ Properties\GlobalAssembly.cs + +