Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj
===================================================================
diff -u -r7b4e976738871759292c8219091bae62b966acae -r5276b5e82afd56701abd55dd098651fb9ac504e2
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 7b4e976738871759292c8219091bae62b966acae)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Application.Ringtoets.Storage.csproj (.../Application.Ringtoets.Storage.csproj) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -79,6 +79,7 @@
+
@@ -419,6 +420,7 @@
+
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensions.cs (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -0,0 +1,114 @@
+// 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 Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Serializers;
+using Ringtoets.MacroStabilityInwards.Data;
+
+namespace Application.Ringtoets.Storage.Create.MacroStabilityInwards
+{
+ ///
+ /// Extension methods for related to creating a
+ /// .
+ ///
+ internal static class MacroStabilityInwardsOutputCreateExtensions
+ {
+ ///
+ /// Creates a based on the information
+ /// of the .
+ ///
+ /// The calculation output for macro stability inwards failure mechanism to
+ /// create a database entity for.
+ /// A new .
+ /// Thrown when
+ /// is null.
+ internal static MacroStabilityInwardsCalculationOutputEntity Create(this MacroStabilityInwardsOutput output)
+ {
+ if (output == null)
+ {
+ throw new ArgumentNullException(nameof(output));
+ }
+
+ var entity = new MacroStabilityInwardsCalculationOutputEntity
+ {
+ FactorOfStability = output.FactorOfStability.ToNaNAsNull(),
+ ForbiddenZonesXEntryMin = output.ForbiddenZonesXEntryMin.ToNaNAsNull(),
+ ForbiddenZonesXEntryMax = output.ForbiddenZonesXEntryMax.ToNaNAsNull(),
+ ZValue = output.ZValue.ToNaNAsNull()
+ };
+ SetSlidingCurveProperties(entity, output.SlidingCurve);
+ SetSlipPlaneProperties(entity, output.SlipPlane);
+
+ return entity;
+ }
+
+ private static void SetSlidingCurveProperties(MacroStabilityInwardsCalculationOutputEntity entity,
+ MacroStabilityInwardsSlidingCurve slidingCurve)
+ {
+ entity.SlidingCurveSliceXML = new MacroStabilityInwardsSliceXmlSerializer().ToXml(slidingCurve.Slices);
+ entity.SlidingCurveNonIteratedHorizontalForce = slidingCurve.NonIteratedHorizontalForce.ToNaNAsNull();
+ entity.SlidingCurveIteratedHorizontalForce = slidingCurve.IteratedHorizontalForce.ToNaNAsNull();
+
+ MacroStabilityInwardsSlidingCircle leftCircle = slidingCurve.LeftCircle;
+ entity.SlidingCurveLeftSlidingCircleCenterX = leftCircle.Center.X.ToNaNAsNull();
+ entity.SlidingCurveLeftSlidingCircleCenterY = leftCircle.Center.Y.ToNaNAsNull();
+ entity.SlidingCurveLeftSlidingCircleRadius = leftCircle.Radius.ToNaNAsNull();
+ entity.SlidingCurveLeftSlidingCircleIsActive = Convert.ToByte(leftCircle.IsActive);
+ entity.SlidingCurveLeftSlidingCircleNonIteratedForce = leftCircle.NonIteratedForce.ToNaNAsNull();
+ entity.SlidingCurveLeftSlidingCircleIteratedForce = leftCircle.IteratedForce.ToNaNAsNull();
+ entity.SlidingCurveLeftSlidingCircleDrivingMoment = leftCircle.DrivingMoment.ToNaNAsNull();
+ entity.SlidingCurveLeftSlidingCircleResistingMoment = leftCircle.ResistingMoment.ToNaNAsNull();
+
+ MacroStabilityInwardsSlidingCircle rightCircle = slidingCurve.RightCircle;
+ entity.SlidingCurveRightSlidingCircleCenterX = rightCircle.Center.X.ToNaNAsNull();
+ entity.SlidingCurveRightSlidingCircleCenterY = rightCircle.Center.Y.ToNaNAsNull();
+ entity.SlidingCurveRightSlidingCircleRadius = rightCircle.Radius.ToNaNAsNull();
+ entity.SlidingCurveRightSlidingCircleIsActive = Convert.ToByte(rightCircle.IsActive);
+ entity.SlidingCurveRightSlidingCircleNonIteratedForce = rightCircle.NonIteratedForce.ToNaNAsNull();
+ entity.SlidingCurveRightSlidingCircleIteratedForce = rightCircle.IteratedForce.ToNaNAsNull();
+ entity.SlidingCurveRightSlidingCircleDrivingMoment = rightCircle.DrivingMoment.ToNaNAsNull();
+ entity.SlidingCurveRightSlidingCircleResistingMoment = rightCircle.ResistingMoment.ToNaNAsNull();
+ }
+
+ private static void SetSlipPlaneProperties(MacroStabilityInwardsCalculationOutputEntity entity,
+ MacroStabilityInwardsSlipPlaneUpliftVan slipPlane)
+ {
+ entity.SlipPlaneTangentLinesXml = new TangentLinesXmlSerializer().ToXml(slipPlane.TangentLines);
+
+ MacroStabilityInwardsGrid leftGrid = slipPlane.LeftGrid;
+ entity.SlipPlaneLeftGridXLeft = leftGrid.XLeft.ToNaNAsNull();
+ entity.SlipPlaneLeftGridXRight = leftGrid.XRight.ToNaNAsNull();
+ entity.SlipPlaneLeftGridNrOfHorizontalPoints= leftGrid.NumberOfHorizontalPoints;
+ entity.SlipPlaneLeftGridZTop = leftGrid.ZTop.ToNaNAsNull();
+ entity.SlipPlaneLeftGridZBottom = leftGrid.ZBottom.ToNaNAsNull();
+ entity.SlipPlaneLeftGridNrOfVerticalPoints = leftGrid.NumberOfVerticalPoints;
+
+ MacroStabilityInwardsGrid rightGrid = slipPlane.RightGrid;
+ entity.SlipPlaneRightGridXLeft = rightGrid.XLeft.ToNaNAsNull();
+ entity.SlipPlaneRightGridXRight = rightGrid.XRight.ToNaNAsNull();
+ entity.SlipPlaneRightGridNrOfHorizontalPoints = rightGrid.NumberOfHorizontalPoints;
+ entity.SlipPlaneRightGridZTop = rightGrid.ZTop.ToNaNAsNull();
+ entity.SlipPlaneRightGridZBottom = rightGrid.ZBottom.ToNaNAsNull();
+ entity.SlipPlaneRightGridNrOfVerticalPoints = rightGrid.NumberOfVerticalPoints;
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingOutputCreateExtensions.cs
===================================================================
diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -r5276b5e82afd56701abd55dd098651fb9ac504e2
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingOutputCreateExtensions.cs (.../PipingOutputCreateExtensions.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/Piping/PipingOutputCreateExtensions.cs (.../PipingOutputCreateExtensions.cs) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Application.Ringtoets.Storage.DbContext;
using Ringtoets.Piping.Data;
@@ -36,8 +37,15 @@
/// The calculation output for piping failure mechanism to
/// create a database entity for.
/// A new .
+ /// Thrown when
+ /// is null.
internal static PipingCalculationOutputEntity Create(this PipingOutput output)
{
+ if (output == null)
+ {
+ throw new ArgumentNullException(nameof(output));
+ }
+
var entity = new PipingCalculationOutputEntity
{
HeaveFactorOfSafety = output.HeaveFactorOfSafety.ToNaNAsNull(),
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs
===================================================================
diff -u
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs (revision 0)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -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 Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Serializers;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Ringtoets.MacroStabilityInwards.Data;
+
+namespace Application.Ringtoets.Storage.Read.MacroStabilityInwards
+{
+ ///
+ /// This class defines extension methods for read operations for an
+ /// based on the .
+ ///
+ internal static class MacroStabilityInwardsCalculationOutputEntityReadExtensions
+ {
+ ///
+ /// Read the and use the information to
+ /// construct a .
+ ///
+ /// The to create
+ /// for.
+ /// A new .
+ /// Thrown when is null.
+ internal static MacroStabilityInwardsOutput Read(this MacroStabilityInwardsCalculationOutputEntity entity)
+ {
+ if (entity == null)
+ {
+ throw new ArgumentNullException(nameof(entity));
+ }
+
+ MacroStabilityInwardsSlipPlaneUpliftVan slipPlane = CreateSlipPlane(entity);
+ MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(entity);
+
+ return new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties
+ {
+ FactorOfStability = entity.FactorOfStability.ToNullAsNaN(),
+ ForbiddenZonesXEntryMax = entity.ForbiddenZonesXEntryMax.ToNullAsNaN(),
+ ForbiddenZonesXEntryMin = entity.ForbiddenZonesXEntryMin.ToNullAsNaN(),
+ ZValue = entity.ZValue.ToNullAsNaN()
+ });
+ }
+
+ private static MacroStabilityInwardsSlipPlaneUpliftVan CreateSlipPlane(MacroStabilityInwardsCalculationOutputEntity entity)
+ {
+ var leftGrid = new MacroStabilityInwardsGrid
+ {
+ XLeft = (RoundedDouble) entity.SlipPlaneLeftGridXLeft.ToNullAsNaN(),
+ XRight = (RoundedDouble) entity.SlipPlaneLeftGridXRight.ToNullAsNaN(),
+ NumberOfHorizontalPoints = entity.SlipPlaneLeftGridNrOfHorizontalPoints,
+ ZTop = (RoundedDouble) entity.SlipPlaneLeftGridZTop.ToNullAsNaN(),
+ ZBottom = (RoundedDouble) entity.SlipPlaneLeftGridZBottom.ToNullAsNaN(),
+ NumberOfVerticalPoints = entity.SlipPlaneLeftGridNrOfVerticalPoints
+ };
+ var rightGrid = new MacroStabilityInwardsGrid
+ {
+ XLeft = (RoundedDouble) entity.SlipPlaneRightGridXLeft.ToNullAsNaN(),
+ XRight = (RoundedDouble) entity.SlipPlaneRightGridXRight.ToNullAsNaN(),
+ NumberOfHorizontalPoints = entity.SlipPlaneRightGridNrOfHorizontalPoints,
+ ZTop = (RoundedDouble) entity.SlipPlaneRightGridZTop.ToNullAsNaN(),
+ ZBottom = (RoundedDouble) entity.SlipPlaneRightGridZBottom.ToNullAsNaN(),
+ NumberOfVerticalPoints = entity.SlipPlaneRightGridNrOfVerticalPoints
+ };
+
+ double[] tangentLines = new TangentLinesXmlSerializer().FromXml(entity.SlipPlaneTangentLinesXml);
+ return new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, tangentLines);
+ }
+
+ private static MacroStabilityInwardsSlidingCurve CreateSlidingCurve(MacroStabilityInwardsCalculationOutputEntity entity)
+ {
+ var leftCircle = new MacroStabilityInwardsSlidingCircle(new Point2D(entity.SlidingCurveLeftSlidingCircleCenterX.ToNullAsNaN(),
+ entity.SlidingCurveLeftSlidingCircleCenterY.ToNullAsNaN()),
+ entity.SlidingCurveLeftSlidingCircleRadius.ToNullAsNaN(),
+ Convert.ToBoolean(entity.SlidingCurveLeftSlidingCircleIsActive),
+ entity.SlidingCurveLeftSlidingCircleNonIteratedForce.ToNullAsNaN(),
+ entity.SlidingCurveLeftSlidingCircleIteratedForce.ToNullAsNaN(),
+ entity.SlidingCurveLeftSlidingCircleDrivingMoment.ToNullAsNaN(),
+ entity.SlidingCurveLeftSlidingCircleResistingMoment.ToNullAsNaN());
+
+ var rightCircle = new MacroStabilityInwardsSlidingCircle(new Point2D(entity.SlidingCurveRightSlidingCircleCenterX.ToNullAsNaN(),
+ entity.SlidingCurveRightSlidingCircleCenterY.ToNullAsNaN()),
+ entity.SlidingCurveRightSlidingCircleRadius.ToNullAsNaN(),
+ Convert.ToBoolean(entity.SlidingCurveRightSlidingCircleIsActive),
+ entity.SlidingCurveRightSlidingCircleNonIteratedForce.ToNullAsNaN(),
+ entity.SlidingCurveRightSlidingCircleIteratedForce.ToNullAsNaN(),
+ entity.SlidingCurveRightSlidingCircleDrivingMoment.ToNullAsNaN(),
+ entity.SlidingCurveRightSlidingCircleResistingMoment.ToNullAsNaN());
+
+ MacroStabilityInwardsSlice[] slices = new MacroStabilityInwardsSliceXmlSerializer().FromXml(entity.SlidingCurveSliceXML);
+ return new MacroStabilityInwardsSlidingCurve(leftCircle,
+ rightCircle,
+ slices,
+ entity.SlidingCurveNonIteratedHorizontalForce.ToNullAsNaN(),
+ entity.SlidingCurveIteratedHorizontalForce.ToNullAsNaN());
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/PipingCalculationOutputEntityReadExtensions.cs
===================================================================
diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -r5276b5e82afd56701abd55dd098651fb9ac504e2
--- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/PipingCalculationOutputEntityReadExtensions.cs (.../PipingCalculationOutputEntityReadExtensions.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5)
+++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/Piping/PipingCalculationOutputEntityReadExtensions.cs (.../PipingCalculationOutputEntityReadExtensions.cs) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Application.Ringtoets.Storage.DbContext;
using Ringtoets.Piping.Data;
@@ -31,14 +32,20 @@
internal static class PipingCalculationOutputEntityReadExtensions
{
///
- /// Read the and use the information to
+ /// Read the and use the information to
/// construct a .
///
/// The to create
/// for.
/// A new .
+ /// Thrown when
+ /// is null.
internal static PipingOutput Read(this PipingCalculationOutputEntity entity)
{
+ if (entity == null)
+ {
+ throw new ArgumentNullException(nameof(entity));
+ }
return new PipingOutput(new PipingOutput.ConstructionProperties
{
UpliftZValue = entity.UpliftZValue.ToNullAsNaN(),
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj
===================================================================
diff -u -r7b4e976738871759292c8219091bae62b966acae -r5276b5e82afd56701abd55dd098651fb9ac504e2
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 7b4e976738871759292c8219091bae62b966acae)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -98,6 +98,7 @@
+
@@ -149,6 +150,7 @@
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensionsTest.cs (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -0,0 +1,207 @@
+// 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 Application.Ringtoets.Storage.Create.MacroStabilityInwards;
+using Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Serializers;
+using Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards;
+using Core.Common.Base.Data;
+using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.MacroStabilityInwards.Data;
+
+namespace Application.Ringtoets.Storage.Test.Create.MacroStabilityInwards
+{
+ [TestFixture]
+ public class MacroStabilityInwardsOutputCreateExtensionsTest
+ {
+ [Test]
+ public void Create_OutputNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((MacroStabilityInwardsOutput) null).Create();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("output", exception.ParamName);
+ }
+
+ [Test]
+ public void Create_WithValidValues_ReturnsPropertyWithExpectedPropertiesSet()
+ {
+ // Setup
+ var random = new Random(21);
+
+ MacroStabilityInwardsSlidingCircle leftCircle = CreateSlidingCircle(13);
+ MacroStabilityInwardsSlidingCircle rightCircle = CreateSlidingCircle(34);
+ IEnumerable slices = CreateMacroStabilityInwardsSlices();
+ var slidingCurve = new MacroStabilityInwardsSlidingCurve(leftCircle,
+ rightCircle,
+ slices,
+ random.NextDouble(),
+ random.NextDouble());
+
+ MacroStabilityInwardsGrid leftGrid = CreateGrid(13);
+ MacroStabilityInwardsGrid rightGrid = CreateGrid(34);
+ var tangentLines = new[]
+ {
+ random.NextDouble()
+ };
+ var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(leftGrid, rightGrid, tangentLines);
+
+ var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties
+ {
+ FactorOfStability = random.NextDouble(),
+ ForbiddenZonesXEntryMax = random.NextDouble(),
+ ForbiddenZonesXEntryMin = random.NextDouble(),
+ ZValue = random.NextDouble(),
+ });
+
+ // Call
+ MacroStabilityInwardsCalculationOutputEntity entity = output.Create();
+
+ // Assert
+ MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
+ }
+
+ [Test]
+ public void Create_WithNaNValues_ReturnsPropertyWithExpectedPropertiesSet()
+ {
+ // Setup
+ MacroStabilityInwardsSlidingCircle leftCircle = CreateSlidingCircleWithNaNValues();
+ MacroStabilityInwardsSlidingCircle rightCircle = CreateSlidingCircleWithNaNValues();
+ IEnumerable slices = CreateMacroStabilityInwardsSlices();
+ var slidingCurve = new MacroStabilityInwardsSlidingCurve(leftCircle,
+ rightCircle,
+ slices,
+ double.NaN,
+ double.NaN);
+
+ var slipPlane = new MacroStabilityInwardsSlipPlaneUpliftVan(new MacroStabilityInwardsGrid(),
+ new MacroStabilityInwardsGrid(),
+ new[]
+ {
+ double.NaN
+ });
+
+ var output = new MacroStabilityInwardsOutput(slidingCurve, slipPlane, new MacroStabilityInwardsOutput.ConstructionProperties());
+
+ // Call
+ MacroStabilityInwardsCalculationOutputEntity entity = output.Create();
+
+ // Assert
+ MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
+ }
+
+ #region Slip Plane Helpers
+
+ private static MacroStabilityInwardsGrid CreateGrid(int seed)
+ {
+ var random = new Random(seed);
+ return new MacroStabilityInwardsGrid
+ {
+ XLeft = random.NextRoundedDouble(),
+ XRight = random.NextRoundedDouble(),
+ ZTop = random.NextRoundedDouble(),
+ ZBottom = random.NextRoundedDouble(),
+ NumberOfHorizontalPoints = random.Next(),
+ NumberOfVerticalPoints = random.Next()
+ };
+ }
+
+ #endregion
+
+ #region Sliding Curve Helpers
+
+ private static MacroStabilityInwardsSlidingCircle CreateSlidingCircle(int seed)
+ {
+ var random = new Random(seed);
+ return new MacroStabilityInwardsSlidingCircle(new Point2D(random.NextDouble(), random.NextDouble()),
+ random.NextDouble(),
+ random.NextBoolean(),
+ random.NextDouble(),
+ random.NextDouble(),
+ random.NextDouble(),
+ random.NextDouble());
+ }
+
+ private static MacroStabilityInwardsSlidingCircle CreateSlidingCircleWithNaNValues()
+ {
+ var random = new Random(21);
+ return new MacroStabilityInwardsSlidingCircle(new Point2D(double.NaN, double.NaN),
+ double.NaN,
+ random.NextBoolean(),
+ double.NaN,
+ double.NaN,
+ double.NaN,
+ double.NaN);
+ }
+
+ private static IEnumerable CreateMacroStabilityInwardsSlices()
+ {
+ var random = new Random(21);
+ return new[]
+ {
+ new MacroStabilityInwardsSlice(new Point2D(random.NextDouble(), random.NextDouble()),
+ new Point2D(random.NextDouble(), random.NextDouble()),
+ new Point2D(random.NextDouble(), random.NextDouble()),
+ new Point2D(random.NextDouble(), random.NextDouble()),
+ new MacroStabilityInwardsSlice.ConstructionProperties
+ {
+ Cohesion = random.NextDouble(),
+ FrictionAngle = random.NextDouble(),
+ CriticalPressure = random.NextDouble(),
+ OverConsolidationRatio = random.NextDouble(),
+ DegreeOfConsolidationPorePressureSoil = random.NextDouble(),
+ DegreeOfConsolidationPorePressureLoad = random.NextDouble(),
+ Pop = random.NextDouble(),
+ Dilatancy = random.NextDouble(),
+ ExternalLoad = random.NextDouble(),
+ HydrostaticPorePressure = random.NextDouble(),
+ LeftForce = random.NextDouble(),
+ LeftForceAngle = random.NextDouble(),
+ LeftForceY = random.NextDouble(),
+ RightForce = random.NextDouble(),
+ RightForceAngle = random.NextDouble(),
+ RightForceY = random.NextDouble(),
+ LoadStress = random.NextDouble(),
+ NormalStress = random.NextDouble(),
+ PorePressure = random.NextDouble(),
+ HorizontalPorePressure = random.NextDouble(),
+ VerticalPorePressure = random.NextDouble(),
+ PiezometricPorePressure = random.NextDouble(),
+ EffectiveStress = random.NextDouble(),
+ EffectiveStressDaily = random.NextDouble(),
+ ExcessPorePressure = random.NextDouble(),
+ ShearStress = random.NextDouble(),
+ SoilStress = random.NextDouble(),
+ TotalPorePressure = random.NextDouble(),
+ TotalStress = random.NextDouble()
+ })
+ };
+ }
+
+ #endregion
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingOutputCreateExtensionsTest.cs
===================================================================
diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -r5276b5e82afd56701abd55dd098651fb9ac504e2
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingOutputCreateExtensionsTest.cs (.../PipingOutputCreateExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/Piping/PipingOutputCreateExtensionsTest.cs (.../PipingOutputCreateExtensionsTest.cs) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Application.Ringtoets.Storage.Create.Piping;
using Application.Ringtoets.Storage.DbContext;
using NUnit.Framework;
@@ -30,6 +31,17 @@
public class PipingOutputCreateExtensionsTest
{
[Test]
+ public void Create_OutputNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((PipingOutput) null).Create();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("output", exception.ParamName);
+ }
+
+ [Test]
public void Create_AllOutputValuesSet_ReturnEntity()
{
// Setup
@@ -63,9 +75,6 @@
Assert.AreEqual(pipingOutput.SellmeijerCreepCoefficient.Value, entity.SellmeijerCreepCoefficient);
Assert.AreEqual(pipingOutput.SellmeijerCriticalFall.Value, entity.SellmeijerCriticalFall);
Assert.AreEqual(pipingOutput.SellmeijerReducedFall.Value, entity.SellmeijerReducedFall);
-
- Assert.AreEqual(0, entity.PipingCalculationOutputEntityId);
- Assert.AreEqual(0, entity.PipingCalculationEntityId);
}
[Test]
@@ -89,9 +98,6 @@
Assert.IsNull(entity.SellmeijerCreepCoefficient);
Assert.IsNull(entity.SellmeijerCriticalFall);
Assert.IsNull(entity.SellmeijerReducedFall);
-
- Assert.AreEqual(0, entity.PipingCalculationOutputEntityId);
- Assert.AreEqual(0, entity.PipingCalculationEntityId);
}
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest.cs (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -0,0 +1,204 @@
+// 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 Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Serializers;
+using Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards;
+using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.MacroStabilityInwards.Data;
+using Application.Ringtoets.Storage.Read.MacroStabilityInwards;
+
+namespace Application.Ringtoets.Storage.Test.Read.MacroStabilityInwards
+{
+ [TestFixture]
+ public class MacroStabilityInwardsCalculationOutputEntityReadExtensionsTest
+ {
+ [Test]
+ public void Read_EntityNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((MacroStabilityInwardsCalculationOutputEntity) null).Read();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
+ public void Read_EntityWithValues_ReturnExpectedOutput()
+ {
+ // Setup
+ var random = new Random(21);
+ IEnumerable slices = CreateMacroStabilityInwardsSlices();
+ IEnumerable tangentLines = new[]
+ {
+ random.NextDouble()
+ };
+
+ var entity = new MacroStabilityInwardsCalculationOutputEntity
+ {
+ FactorOfStability = random.NextDouble(),
+ ZValue = random.NextDouble(),
+ ForbiddenZonesXEntryMin = random.NextDouble(),
+ ForbiddenZonesXEntryMax = random.NextDouble(),
+ SlidingCurveSliceXML = new MacroStabilityInwardsSliceXmlSerializer().ToXml(slices),
+ SlidingCurveNonIteratedHorizontalForce = random.NextDouble(),
+ SlidingCurveIteratedHorizontalForce = random.NextDouble(),
+ SlidingCurveLeftSlidingCircleCenterX = random.NextDouble(),
+ SlidingCurveLeftSlidingCircleCenterY = random.NextDouble(),
+ SlidingCurveLeftSlidingCircleRadius = random.NextDouble(),
+ SlidingCurveLeftSlidingCircleIsActive = Convert.ToByte(random.NextBoolean()),
+ SlidingCurveLeftSlidingCircleNonIteratedForce = random.NextDouble(),
+ SlidingCurveLeftSlidingCircleIteratedForce = random.NextDouble(),
+ SlidingCurveLeftSlidingCircleDrivingMoment = random.NextDouble(),
+ SlidingCurveLeftSlidingCircleResistingMoment = random.NextDouble(),
+ SlidingCurveRightSlidingCircleCenterX = random.NextDouble(),
+ SlidingCurveRightSlidingCircleCenterY = random.NextDouble(),
+ SlidingCurveRightSlidingCircleRadius = random.NextDouble(),
+ SlidingCurveRightSlidingCircleIsActive = Convert.ToByte(random.NextBoolean()),
+ SlidingCurveRightSlidingCircleNonIteratedForce = random.NextDouble(),
+ SlidingCurveRightSlidingCircleIteratedForce = random.NextDouble(),
+ SlidingCurveRightSlidingCircleDrivingMoment = random.NextDouble(),
+ SlidingCurveRightSlidingCircleResistingMoment = random.NextDouble(),
+ SlipPlaneTangentLinesXml = new TangentLinesXmlSerializer().ToXml(tangentLines),
+ SlipPlaneLeftGridXLeft = random.NextDouble(),
+ SlipPlaneLeftGridXRight = random.NextDouble(),
+ SlipPlaneLeftGridNrOfHorizontalPoints = random.Next(),
+ SlipPlaneLeftGridZTop = random.NextDouble(),
+ SlipPlaneLeftGridZBottom = random.NextDouble(),
+ SlipPlaneLeftGridNrOfVerticalPoints = random.Next(),
+ SlipPlaneRightGridXLeft = random.NextDouble(),
+ SlipPlaneRightGridXRight = random.NextDouble(),
+ SlipPlaneRightGridNrOfHorizontalPoints = random.Next(),
+ SlipPlaneRightGridZTop = random.NextDouble(),
+ SlipPlaneRightGridZBottom = random.NextDouble(),
+ SlipPlaneRightGridNrOfVerticalPoints = random.Next()
+ };
+
+ // Call
+ MacroStabilityInwardsOutput output = entity.Read();
+
+ // Assert
+ MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
+ }
+
+ [Test]
+ public void Read_EntityWithNullValues_ReturnExpectedOutputWithNaNValues()
+ {
+ // Setup
+ var entity = new MacroStabilityInwardsCalculationOutputEntity
+ {
+ SlidingCurveSliceXML = new MacroStabilityInwardsSliceXmlSerializer().ToXml(new MacroStabilityInwardsSlice[0]),
+ SlipPlaneTangentLinesXml = new TangentLinesXmlSerializer().ToXml(new double[0])
+ };
+
+ // Call
+ MacroStabilityInwardsOutput output = entity.Read();
+
+ // Assert
+ MacroStabilityInwardsCalculationOutputEntityTestHelper.AssertOutputPropertyValues(output, entity);
+ }
+
+ [Test]
+ public void Read_SlipPlaneTangentLineXMLEmpty_ThrowsArgumentException()
+ {
+ // Setup
+ var entity = new MacroStabilityInwardsCalculationOutputEntity
+ {
+ SlidingCurveSliceXML = new MacroStabilityInwardsSliceXmlSerializer().ToXml(new MacroStabilityInwardsSlice[0]),
+ SlipPlaneTangentLinesXml = string.Empty
+ };
+
+ // Call
+ TestDelegate call = ()=> entity.Read();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("xml", exception.ParamName);
+ }
+
+ [Test]
+ public void Read_SlidingCurveSliceXMLEmpty_ThrowsArgumentException()
+ {
+ // Setup
+ var entity = new MacroStabilityInwardsCalculationOutputEntity
+ {
+ SlidingCurveSliceXML = string.Empty,
+ SlipPlaneTangentLinesXml = new TangentLinesXmlSerializer().ToXml(new double[0])
+ };
+
+ // Call
+ TestDelegate call = ()=> entity.Read();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("xml", exception.ParamName);
+ }
+
+ private static IEnumerable CreateMacroStabilityInwardsSlices()
+ {
+ var random = new Random(21);
+ return new[]
+ {
+ new MacroStabilityInwardsSlice(new Point2D(random.NextDouble(), random.NextDouble()),
+ new Point2D(random.NextDouble(), random.NextDouble()),
+ new Point2D(random.NextDouble(), random.NextDouble()),
+ new Point2D(random.NextDouble(), random.NextDouble()),
+ new MacroStabilityInwardsSlice.ConstructionProperties
+ {
+ Cohesion = random.NextDouble(),
+ FrictionAngle = random.NextDouble(),
+ CriticalPressure = random.NextDouble(),
+ OverConsolidationRatio = random.NextDouble(),
+ DegreeOfConsolidationPorePressureSoil = random.NextDouble(),
+ DegreeOfConsolidationPorePressureLoad = random.NextDouble(),
+ Pop = random.NextDouble(),
+ Dilatancy = random.NextDouble(),
+ ExternalLoad = random.NextDouble(),
+ HydrostaticPorePressure = random.NextDouble(),
+ LeftForce = random.NextDouble(),
+ LeftForceAngle = random.NextDouble(),
+ LeftForceY = random.NextDouble(),
+ RightForce = random.NextDouble(),
+ RightForceAngle = random.NextDouble(),
+ RightForceY = random.NextDouble(),
+ LoadStress = random.NextDouble(),
+ NormalStress = random.NextDouble(),
+ PorePressure = random.NextDouble(),
+ HorizontalPorePressure = random.NextDouble(),
+ VerticalPorePressure = random.NextDouble(),
+ PiezometricPorePressure = random.NextDouble(),
+ EffectiveStress = random.NextDouble(),
+ EffectiveStressDaily = random.NextDouble(),
+ ExcessPorePressure = random.NextDouble(),
+ ShearStress = random.NextDouble(),
+ SoilStress = random.NextDouble(),
+ TotalPorePressure = random.NextDouble(),
+ TotalStress = random.NextDouble()
+ })
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingCalculationOutputEntityReadExtensionsTest.cs
===================================================================
diff -u -r3fb0df0ed6e64657154700ee7706e035d5bf99f5 -r5276b5e82afd56701abd55dd098651fb9ac504e2
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingCalculationOutputEntityReadExtensionsTest.cs (.../PipingCalculationOutputEntityReadExtensionsTest.cs) (revision 3fb0df0ed6e64657154700ee7706e035d5bf99f5)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/Piping/PipingCalculationOutputEntityReadExtensionsTest.cs (.../PipingCalculationOutputEntityReadExtensionsTest.cs) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Application.Ringtoets.Storage.DbContext;
using Application.Ringtoets.Storage.Read.Piping;
using NUnit.Framework;
@@ -30,6 +31,17 @@
public class PipingCalculationOutputEntityReadExtensionsTest
{
[Test]
+ public void Read_EntityNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => ((PipingCalculationOutputEntity) null).Read();
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("entity", exception.ParamName);
+ }
+
+ [Test]
public void Read_ValidEntity_ReturnPipingOutput()
{
// Setup
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Serializers/MacroStabilityInwardsSliceXmlSerializerTest.cs
===================================================================
diff -u -r2a585c57b57dac62d39293e51dda15c7392305de -r5276b5e82afd56701abd55dd098651fb9ac504e2
--- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Serializers/MacroStabilityInwardsSliceXmlSerializerTest.cs (.../MacroStabilityInwardsSliceXmlSerializerTest.cs) (revision 2a585c57b57dac62d39293e51dda15c7392305de)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Serializers/MacroStabilityInwardsSliceXmlSerializerTest.cs (.../MacroStabilityInwardsSliceXmlSerializerTest.cs) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -20,9 +20,10 @@
// All rights reserved.
using System;
-using System.Collections;
+using System.Collections.Generic;
using Application.Ringtoets.Storage.Serializers;
using Core.Common.Base.Geometry;
+using Core.Common.TestUtil;
using NUnit.Framework;
using Ringtoets.MacroStabilityInwards.Data;
@@ -101,55 +102,53 @@
MacroStabilityInwardsSlice[] roundtripResult = serializer.FromXml(xml);
// Then
- CollectionAssert.AreEqual(original, roundtripResult, new MacroStabilityInwardsSliceComparer());
+ TestHelper.AssertCollectionsAreEqual(original, roundtripResult, new MacroStabilityInwardsSliceComparer());
}
- private class MacroStabilityInwardsSliceComparer : IComparer
+ private class MacroStabilityInwardsSliceComparer : IEqualityComparer
{
- public int Compare(object x, object y)
+ public bool Equals(MacroStabilityInwardsSlice x, MacroStabilityInwardsSlice y)
{
- var x1 = (MacroStabilityInwardsSlice) x;
- var y1 = (MacroStabilityInwardsSlice) y;
- if (x1.TopLeftPoint.Equals(y1.TopLeftPoint)
- && x1.TopRightPoint.Equals(y1.TopRightPoint)
- && x1.BottomLeftPoint.Equals(y1.BottomLeftPoint)
- && x1.BottomRightPoint.Equals(y1.BottomRightPoint)
- && x1.Cohesion.Equals(y1.Cohesion)
- && x1.FrictionAngle.Equals(y1.FrictionAngle)
- && x1.CriticalPressure.Equals(y1.CriticalPressure)
- && x1.OverConsolidationRatio.Equals(y1.OverConsolidationRatio)
- && x1.Pop.Equals(y1.Pop)
- && x1.DegreeOfConsolidationPorePressureSoil.Equals(y1.DegreeOfConsolidationPorePressureSoil)
- && x1.DegreeOfConsolidationPorePressureLoad.Equals(y1.DegreeOfConsolidationPorePressureLoad)
- && x1.Dilatancy.Equals(y1.Dilatancy)
- && x1.ExternalLoad.Equals(y1.ExternalLoad)
- && x1.HydrostaticPorePressure.Equals(y1.HydrostaticPorePressure)
- && x1.LeftForce.Equals(y1.LeftForce)
- && x1.LeftForceAngle.Equals(y1.LeftForceAngle)
- && x1.LeftForceY.Equals(y1.LeftForceY)
- && x1.RightForce.Equals(y1.RightForce)
- && x1.RightForceAngle.Equals(y1.RightForceAngle)
- && x1.RightForceY.Equals(y1.RightForceY)
- && x1.LoadStress.Equals(y1.LoadStress)
- && x1.NormalStress.Equals(y1.NormalStress)
- && x1.PorePressure.Equals(y1.PorePressure)
- && x1.HorizontalPorePressure.Equals(y1.HorizontalPorePressure)
- && x1.VerticalPorePressure.Equals(y1.VerticalPorePressure)
- && x1.PiezometricPorePressure.Equals(y1.PiezometricPorePressure)
- && x1.EffectiveStress.Equals(y1.EffectiveStress)
- && x1.EffectiveStressDaily.Equals(y1.EffectiveStressDaily)
- && x1.ExcessPorePressure.Equals(y1.ExcessPorePressure)
- && x1.ShearStress.Equals(y1.ShearStress)
- && x1.SoilStress.Equals(y1.SoilStress)
- && x1.TotalPorePressure.Equals(y1.TotalPorePressure)
- && x1.TotalStress.Equals(y1.TotalStress)
- && x1.Weight.Equals(y1.Weight)
- )
- {
- return 0;
- }
- return 1;
+ return x.TopLeftPoint.Equals(y.TopLeftPoint)
+ && x.TopRightPoint.Equals(y.TopRightPoint)
+ && x.BottomLeftPoint.Equals(y.BottomLeftPoint)
+ && x.BottomRightPoint.Equals(y.BottomRightPoint)
+ && x.Cohesion.Equals(y.Cohesion)
+ && x.FrictionAngle.Equals(y.FrictionAngle)
+ && x.CriticalPressure.Equals(y.CriticalPressure)
+ && x.OverConsolidationRatio.Equals(y.OverConsolidationRatio)
+ && x.Pop.Equals(y.Pop)
+ && x.DegreeOfConsolidationPorePressureSoil.Equals(y.DegreeOfConsolidationPorePressureSoil)
+ && x.DegreeOfConsolidationPorePressureLoad.Equals(y.DegreeOfConsolidationPorePressureLoad)
+ && x.Dilatancy.Equals(y.Dilatancy)
+ && x.ExternalLoad.Equals(y.ExternalLoad)
+ && x.HydrostaticPorePressure.Equals(y.HydrostaticPorePressure)
+ && x.LeftForce.Equals(y.LeftForce)
+ && x.LeftForceAngle.Equals(y.LeftForceAngle)
+ && x.LeftForceY.Equals(y.LeftForceY)
+ && x.RightForce.Equals(y.RightForce)
+ && x.RightForceAngle.Equals(y.RightForceAngle)
+ && x.RightForceY.Equals(y.RightForceY)
+ && x.LoadStress.Equals(y.LoadStress)
+ && x.NormalStress.Equals(y.NormalStress)
+ && x.PorePressure.Equals(y.PorePressure)
+ && x.HorizontalPorePressure.Equals(y.HorizontalPorePressure)
+ && x.VerticalPorePressure.Equals(y.VerticalPorePressure)
+ && x.PiezometricPorePressure.Equals(y.PiezometricPorePressure)
+ && x.EffectiveStress.Equals(y.EffectiveStress)
+ && x.EffectiveStressDaily.Equals(y.EffectiveStressDaily)
+ && x.ExcessPorePressure.Equals(y.ExcessPorePressure)
+ && x.ShearStress.Equals(y.ShearStress)
+ && x.SoilStress.Equals(y.SoilStress)
+ && x.TotalPorePressure.Equals(y.TotalPorePressure)
+ && x.TotalStress.Equals(y.TotalStress)
+ && x.Weight.Equals(y.Weight);
}
+
+ public int GetHashCode(MacroStabilityInwardsSlice obj)
+ {
+ throw new NotImplementedException();
+ }
}
}
}
\ No newline at end of file
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/Application.Ringtoets.Storage.TestUtil.csproj
===================================================================
diff -u -r5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1 -r5276b5e82afd56701abd55dd098651fb9ac504e2
--- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/Application.Ringtoets.Storage.TestUtil.csproj (.../Application.Ringtoets.Storage.TestUtil.csproj) (revision 5e5695f9f466a0ab54a59b61879f5d7a66e6ffb1)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/Application.Ringtoets.Storage.TestUtil.csproj (.../Application.Ringtoets.Storage.TestUtil.csproj) (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -55,6 +55,7 @@
Properties\GlobalAssembly.cs
+
Index: Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityTestHelper.cs
===================================================================
diff -u
--- Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityTestHelper.cs (revision 0)
+++ Application/Ringtoets/test/Application.Ringtoets.Storage.TestUtil/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityTestHelper.cs (revision 5276b5e82afd56701abd55dd098651fb9ac504e2)
@@ -0,0 +1,145 @@
+// 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 Application.Ringtoets.Storage.DbContext;
+using Application.Ringtoets.Storage.Serializers;
+using Core.Common.Base.Data;
+using NUnit.Framework;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.MacroStabilityInwards.Data;
+
+namespace Application.Ringtoets.Storage.TestUtil.MacroStabilityInwards
+{
+ ///
+ /// Class to assert the properties of macro stability inwards calculation output entities.
+ ///
+ public static class MacroStabilityInwardsCalculationOutputEntityTestHelper
+ {
+ ///
+ /// Determines for each property of whether the matching
+ /// property of has an equal value.
+ ///
+ /// The to compare.
+ /// The
+ /// to compare.
+ /// Thrown if any of the argument is null.
+ /// Thrown when any of the values of the
+ /// and its nested elements do not match.
+ ///
+ public static void AssertOutputPropertyValues(MacroStabilityInwardsOutput output, MacroStabilityInwardsCalculationOutputEntity entity)
+ {
+ if (output == null)
+ {
+ throw new ArgumentNullException(nameof(output));
+ }
+ if (entity == null)
+ {
+ throw new ArgumentNullException(nameof(entity));
+ }
+
+ AssertAreEqual(output.FactorOfStability, entity.FactorOfStability);
+ AssertAreEqual(output.ForbiddenZonesXEntryMin, entity.ForbiddenZonesXEntryMin);
+ AssertAreEqual(output.ForbiddenZonesXEntryMax, entity.ForbiddenZonesXEntryMax);
+ AssertAreEqual(output.ZValue, entity.ZValue);
+
+ AssertSlidingCurveProperties(output.SlidingCurve, entity);
+ AssertSlipPlaneProperties(output.SlipPlane, entity);
+ }
+
+ private static void AssertSlipPlaneProperties(MacroStabilityInwardsSlipPlaneUpliftVan slipPlane,
+ MacroStabilityInwardsCalculationOutputEntity entity)
+ {
+ string expectedTangentLinesXml = new TangentLinesXmlSerializer().ToXml(slipPlane.TangentLines);
+ Assert.AreEqual(expectedTangentLinesXml, entity.SlipPlaneTangentLinesXml);
+
+ MacroStabilityInwardsGrid leftGrid = slipPlane.LeftGrid;
+ AssertAreEqual(leftGrid.XLeft, entity.SlipPlaneLeftGridXLeft);
+ AssertAreEqual(leftGrid.XRight, entity.SlipPlaneLeftGridXRight);
+ Assert.AreEqual(leftGrid.NumberOfHorizontalPoints, entity.SlipPlaneLeftGridNrOfHorizontalPoints);
+ AssertAreEqual(leftGrid.ZTop, entity.SlipPlaneLeftGridZTop);
+ AssertAreEqual(leftGrid.ZBottom, entity.SlipPlaneLeftGridZBottom);
+ Assert.AreEqual(leftGrid.NumberOfVerticalPoints, entity.SlipPlaneLeftGridNrOfVerticalPoints);
+
+ MacroStabilityInwardsGrid rightGrid = slipPlane.RightGrid;
+ AssertAreEqual(rightGrid.XRight, entity.SlipPlaneRightGridXRight);
+ AssertAreEqual(rightGrid.XRight, entity.SlipPlaneRightGridXRight);
+ Assert.AreEqual(rightGrid.NumberOfHorizontalPoints, entity.SlipPlaneRightGridNrOfHorizontalPoints);
+ AssertAreEqual(rightGrid.ZTop, entity.SlipPlaneRightGridZTop);
+ AssertAreEqual(rightGrid.ZBottom, entity.SlipPlaneRightGridZBottom);
+ Assert.AreEqual(rightGrid.NumberOfVerticalPoints, entity.SlipPlaneRightGridNrOfVerticalPoints);
+ }
+
+ private static void AssertSlidingCurveProperties(MacroStabilityInwardsSlidingCurve slidingCurve,
+ MacroStabilityInwardsCalculationOutputEntity entity)
+ {
+ string expectedSlicesXml = new MacroStabilityInwardsSliceXmlSerializer().ToXml(slidingCurve.Slices);
+ Assert.AreEqual(expectedSlicesXml, entity.SlidingCurveSliceXML);
+
+ AssertAreEqual(slidingCurve.IteratedHorizontalForce, entity.SlidingCurveIteratedHorizontalForce);
+ AssertAreEqual(slidingCurve.NonIteratedHorizontalForce, entity.SlidingCurveNonIteratedHorizontalForce);
+
+ MacroStabilityInwardsSlidingCircle leftCircle = slidingCurve.LeftCircle;
+ AssertAreEqual(leftCircle.Center.X, entity.SlidingCurveLeftSlidingCircleCenterX);
+ AssertAreEqual(leftCircle.Center.Y, entity.SlidingCurveLeftSlidingCircleCenterY);
+ AssertAreEqual(leftCircle.Radius, entity.SlidingCurveLeftSlidingCircleRadius);
+ Assert.AreEqual(Convert.ToByte(leftCircle.IsActive), entity.SlidingCurveLeftSlidingCircleIsActive);
+ AssertAreEqual(leftCircle.IteratedForce, entity.SlidingCurveLeftSlidingCircleIteratedForce);
+ AssertAreEqual(leftCircle.NonIteratedForce, entity.SlidingCurveLeftSlidingCircleNonIteratedForce);
+ AssertAreEqual(leftCircle.DrivingMoment, entity.SlidingCurveLeftSlidingCircleDrivingMoment);
+ AssertAreEqual(leftCircle.ResistingMoment, entity.SlidingCurveLeftSlidingCircleResistingMoment);
+
+ MacroStabilityInwardsSlidingCircle rightCircle = slidingCurve.RightCircle;
+ AssertAreEqual(rightCircle.Center.X, entity.SlidingCurveRightSlidingCircleCenterX);
+ AssertAreEqual(rightCircle.Center.Y, entity.SlidingCurveRightSlidingCircleCenterY);
+ AssertAreEqual(rightCircle.Radius, entity.SlidingCurveRightSlidingCircleRadius);
+ Assert.AreEqual(Convert.ToByte(rightCircle.IsActive), entity.SlidingCurveRightSlidingCircleIsActive);
+ AssertAreEqual(rightCircle.IteratedForce, entity.SlidingCurveRightSlidingCircleIteratedForce);
+ AssertAreEqual(rightCircle.NonIteratedForce, entity.SlidingCurveRightSlidingCircleNonIteratedForce);
+ AssertAreEqual(rightCircle.DrivingMoment, entity.SlidingCurveRightSlidingCircleDrivingMoment);
+ AssertAreEqual(rightCircle.ResistingMoment, entity.SlidingCurveRightSlidingCircleResistingMoment);
+ }
+
+ private static void AssertAreEqual(double expectedDouble, double? actualDouble)
+ {
+ if (double.IsNaN(expectedDouble))
+ {
+ Assert.IsNull(actualDouble);
+ }
+ else
+ {
+ Assert.AreEqual(expectedDouble, actualDouble);
+ }
+ }
+
+ private static void AssertAreEqual(RoundedDouble expectedDouble, double? actualDouble)
+ {
+ if (double.IsNaN(expectedDouble))
+ {
+ Assert.IsNull(actualDouble);
+ }
+ else
+ {
+ Assert.AreEqual(expectedDouble, actualDouble, expectedDouble.GetAccuracy());
+ }
+ }
+ }
+}
\ No newline at end of file