Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Factories/MacroStabilityInwardsSliceChartDataPointsFactory.cs =================================================================== diff -u -rc9703bc7410fa04c7e81a19553b62eb704b1ff6c -r02d9cc7ffa59b850d32f3fcdc58d13f8af1d661a --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Factories/MacroStabilityInwardsSliceChartDataPointsFactory.cs (.../MacroStabilityInwardsSliceChartDataPointsFactory.cs) (revision c9703bc7410fa04c7e81a19553b62eb704b1ff6c) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Factories/MacroStabilityInwardsSliceChartDataPointsFactory.cs (.../MacroStabilityInwardsSliceChartDataPointsFactory.cs) (revision 02d9cc7ffa59b850d32f3fcdc58d13f8af1d661a) @@ -267,6 +267,14 @@ foreach (MacroStabilityInwardsSlice slice in slices) { RoundedDouble value = getParameterFunc(slice); + if (double.IsNaN(value)) + { + value = (RoundedDouble) 0.0; + } + else if (value > 2000.0) + { + value = (RoundedDouble) 2000.0; + } double offset = value.Value * scaleFactor; double deltaX = slice.BottomLeftPoint.X - slice.BottomRightPoint.X; double deltaY = slice.BottomLeftPoint.Y - slice.BottomRightPoint.Y; Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Factories/MacroStabilityInwardsSliceChartDataPointsFactoryTest.cs =================================================================== diff -u -r873730f975e8d753040ef397eeb90252fe5416ec -r02d9cc7ffa59b850d32f3fcdc58d13f8af1d661a --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Factories/MacroStabilityInwardsSliceChartDataPointsFactoryTest.cs (.../MacroStabilityInwardsSliceChartDataPointsFactoryTest.cs) (revision 873730f975e8d753040ef397eeb90252fe5416ec) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Factories/MacroStabilityInwardsSliceChartDataPointsFactoryTest.cs (.../MacroStabilityInwardsSliceChartDataPointsFactoryTest.cs) (revision 02d9cc7ffa59b850d32f3fcdc58d13f8af1d661a) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using Core.Common.Base.Geometry; using Core.Common.Base.TestUtil.Geometry; @@ -89,6 +90,70 @@ } [Test] + public void CreateParameterAreas_ValueNaN_ReturnsExpectedAreas() + { + // Setup + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(new MacroStabilityInwardsSlice.ConstructionProperties()); + + // Call + IEnumerable> cohesionAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateCohesionAreas(slidingCurve); + IEnumerable> effectiveStressAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateEffectiveStressAreas(slidingCurve); + IEnumerable> effectiveStressDailyAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateEffectiveStressDailyAreas(slidingCurve); + IEnumerable> totalPorePressureAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateTotalPorePressureAreas(slidingCurve); + IEnumerable> weightAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateWeightAreas(slidingCurve); + IEnumerable> piezometricPorePressureAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreatePiezometricPorePressureAreas(slidingCurve); + IEnumerable> porePressureAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreatePorePressureAreas(slidingCurve); + IEnumerable> verticalPorePressureAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateVerticalPorePressureAreas(slidingCurve); + IEnumerable> horizontalPorePressureAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateHorizontalPorePressureAreas(slidingCurve); + IEnumerable> overConsolidationRatioAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateOverConsolidationRatioAreas(slidingCurve); + IEnumerable> popAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreatePopAreas(slidingCurve); + IEnumerable> normalStressAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateNormalStressAreas(slidingCurve); + IEnumerable> shearStressAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateShearStressAreas(slidingCurve); + IEnumerable> loadStressAreas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateLoadStressAreas(slidingCurve); + + // Assert + var expectedAreas = new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, 0), + new Point2D(0, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(1, 1), + new Point2D(1, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(2, 1), + new Point2D(1, 0) + } + }; + + CollectionAssert.AreEqual(expectedAreas, cohesionAreas); + CollectionAssert.AreEqual(expectedAreas, effectiveStressAreas); + CollectionAssert.AreEqual(expectedAreas, effectiveStressDailyAreas); + CollectionAssert.AreEqual(expectedAreas, totalPorePressureAreas); + CollectionAssert.AreEqual(expectedAreas, weightAreas); + CollectionAssert.AreEqual(expectedAreas, piezometricPorePressureAreas); + CollectionAssert.AreEqual(expectedAreas, porePressureAreas); + CollectionAssert.AreEqual(expectedAreas, verticalPorePressureAreas); + CollectionAssert.AreEqual(expectedAreas, horizontalPorePressureAreas); + CollectionAssert.AreEqual(expectedAreas, overConsolidationRatioAreas); + CollectionAssert.AreEqual(expectedAreas, popAreas); + CollectionAssert.AreEqual(expectedAreas, normalStressAreas); + CollectionAssert.AreEqual(expectedAreas, shearStressAreas); + CollectionAssert.AreEqual(expectedAreas, loadStressAreas); + } + + [Test] public void CreateCohesionAreas_SlidingCurveNull_ReturnsEmptyCollection() { // Call @@ -99,6 +164,47 @@ } [Test] + public void CreateCohesionAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + Cohesion = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateCohesionAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateCohesionAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -150,6 +256,47 @@ } [Test] + public void CreateEffectiveStressAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + EffectiveStress = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateEffectiveStressAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateEffectiveStressAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -201,6 +348,47 @@ } [Test] + public void CreateEffectiveStressDailyAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + EffectiveStressDaily = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateEffectiveStressDailyAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateEffectiveStressDailyAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -252,6 +440,47 @@ } [Test] + public void CreateTotalPorePressureAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + TotalPorePressure = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateTotalPorePressureAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateTotalPorePressureAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -303,6 +532,47 @@ } [Test] + public void CreateWeightAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + Weight = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateWeightAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateWeightAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -354,6 +624,47 @@ } [Test] + public void CreatePiezometricPorePressureAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + PiezometricPorePressure = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreatePiezometricPorePressureAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreatePiezometricPorePressureAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -405,6 +716,47 @@ } [Test] + public void CreatePorePressureAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + PorePressure = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreatePorePressureAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreatePorePressureAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -456,6 +808,47 @@ } [Test] + public void CreateVerticalPorePressureAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + VerticalPorePressure = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateVerticalPorePressureAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateVerticalPorePressureAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -507,6 +900,47 @@ } [Test] + public void CreateHorizontalPorePressureAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + HorizontalPorePressure = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateHorizontalPorePressureAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateHorizontalPorePressureAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -558,6 +992,47 @@ } [Test] + public void CreateOverConsolidationRatioAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + OverConsolidationRatio = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateOverConsolidationRatioAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -100), + new Point2D(0, -100) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(101, 1), + new Point2D(101, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(72.710678, -69.710678), + new Point2D(71.710678, -70.710678) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateOverConsolidationRatioAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -609,6 +1084,47 @@ } [Test] + public void CreatePopAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + Pop = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreatePopAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreatePopAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -660,6 +1176,47 @@ } [Test] + public void CreateNormalStressAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + NormalStress = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateNormalStressAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateNormalStressAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -711,6 +1268,47 @@ } [Test] + public void CreateShearStressAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + ShearStress = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateShearStressAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateShearStressAreas_ValidParameters_ReturnsExpectedAreas() { // Setup @@ -762,6 +1360,47 @@ } [Test] + public void CreateLoadStressAreas_ValueAboveLimit_ReturnsExpectedAreas() + { + // Setup + var constructionProperties = new MacroStabilityInwardsSlice.ConstructionProperties + { + LoadStress = new Random(39).Next(2001, int.MaxValue) + }; + + MacroStabilityInwardsSlidingCurve slidingCurve = CreateSlidingCurve(constructionProperties); + + // Call + IEnumerable> areas = MacroStabilityInwardsSliceChartDataPointsFactory.CreateLoadStressAreas(slidingCurve); + + // Assert + CollectionAssert.AreEqual(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(1, 0), + new Point2D(1, -250), + new Point2D(0, -250) + }, + new[] + { + new Point2D(1, 0), + new Point2D(1, 1), + new Point2D(251, 1), + new Point2D(251, 0) + }, + new[] + { + new Point2D(1, 0), + new Point2D(2, 1), + new Point2D(178.776695, -175.776695), + new Point2D(177.776695, -176.776695) + } + }, areas, new Point2DComparerWithTolerance(1e-6)); + } + + [Test] public void CreateLoadStressAreas_ValidParameters_ReturnsExpectedAreas() { // Setup