Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs =================================================================== diff -u -r3b2cfa62b4a0df5c5577395b7cbef40de1d7f2f9 -r7472a3a034f5d43d665980b35727c63d167abb5e --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs (.../MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs) (revision 3b2cfa62b4a0df5c5577395b7cbef40de1d7f2f9) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/MacroStabilityInwards/MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs (.../MacroStabilityInwardsCalculationOutputEntityReadExtensions.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -22,7 +22,6 @@ 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; @@ -63,22 +62,21 @@ private static MacroStabilityInwardsSlipPlaneUpliftVan ReadSlipPlane(MacroStabilityInwardsCalculationOutputEntity entity) { - var leftGrid = new MacroStabilityInwardsGrid + var leftGrid = new MacroStabilityInwardsGrid(entity.SlipPlaneLeftGridXLeft.ToNullAsNaN(), + entity.SlipPlaneLeftGridXRight.ToNullAsNaN(), + entity.SlipPlaneLeftGridZTop.ToNullAsNaN(), + entity.SlipPlaneLeftGridZBottom.ToNullAsNaN()) { - 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 + var rightGrid = new MacroStabilityInwardsGrid(entity.SlipPlaneRightGridXLeft.ToNullAsNaN(), + entity.SlipPlaneRightGridXRight.ToNullAsNaN(), + entity.SlipPlaneRightGridZTop.ToNullAsNaN(), + entity.SlipPlaneRightGridZBottom.ToNullAsNaN() + ) { - 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 }; Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensionsTest.cs =================================================================== diff -u -r3b2cfa62b4a0df5c5577395b7cbef40de1d7f2f9 -r7472a3a034f5d43d665980b35727c63d167abb5e --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensionsTest.cs (.../MacroStabilityInwardsOutputCreateExtensionsTest.cs) (revision 3b2cfa62b4a0df5c5577395b7cbef40de1d7f2f9) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/MacroStabilityInwards/MacroStabilityInwardsOutputCreateExtensionsTest.cs (.../MacroStabilityInwardsOutputCreateExtensionsTest.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -152,20 +152,19 @@ private static MacroStabilityInwardsGrid CreateGrid(int seed) { var random = new Random(seed); - return new MacroStabilityInwardsGrid + return new MacroStabilityInwardsGrid(random.NextDouble(), + 1 + random.NextDouble(), + 1 + random.NextDouble(), + random.NextDouble()) { - XLeft = random.NextRoundedDouble(), - XRight = random.NextRoundedDouble(), - ZTop = random.NextRoundedDouble(), - ZBottom = random.NextRoundedDouble(), - NumberOfHorizontalPoints = random.Next(), - NumberOfVerticalPoints = random.Next() + NumberOfHorizontalPoints = random.Next(1, 100), + NumberOfVerticalPoints = random.Next(1, 100) }; } private static MacroStabilityInwardsGrid CreateGridWithNaNValues() { - return new MacroStabilityInwardsGrid + return new MacroStabilityInwardsGrid(double.NaN, double.NaN, double.NaN, double.NaN) { XLeft = RoundedDouble.NaN, XRight = RoundedDouble.NaN, Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsGrid.cs =================================================================== diff -u -r47b2bbe8b9d15194a9641a2db098c25e5e775528 -r7472a3a034f5d43d665980b35727c63d167abb5e --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsGrid.cs (.../MacroStabilityInwardsGrid.cs) (revision 47b2bbe8b9d15194a9641a2db098c25e5e775528) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsGrid.cs (.../MacroStabilityInwardsGrid.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -37,12 +37,16 @@ /// /// Creates a new instance of . /// - public MacroStabilityInwardsGrid() + /// The x left of the grid. + /// The x right of the grid. + /// The z top of the grid. + /// The z bottom of the grid. + public MacroStabilityInwardsGrid(double xLeft, double xRight, double zTop, double zBottom) { - xLeft = new RoundedDouble(2, double.NaN); - xRight = new RoundedDouble(2, double.NaN); - zTop = new RoundedDouble(2, double.NaN); - zBottom = new RoundedDouble(2, double.NaN); + this.xLeft = new RoundedDouble(2, xLeft); + this.xRight = new RoundedDouble(2, xRight); + this.zTop = new RoundedDouble(2, zTop); + this.zBottom = new RoundedDouble(2, zBottom); } /// Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsInput.cs =================================================================== diff -u -rd707a4abb863bf309335b4e228968b39dbaf9645 -r7472a3a034f5d43d665980b35727c63d167abb5e --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsInput.cs (.../MacroStabilityInwardsInput.cs) (revision d707a4abb863bf309335b4e228968b39dbaf9645) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsInput.cs (.../MacroStabilityInwardsInput.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -102,8 +102,8 @@ tangentLineZBottom = new RoundedDouble(2, double.NaN); tangentLineNumber = 1; - LeftGrid = new MacroStabilityInwardsGrid(); - RightGrid = new MacroStabilityInwardsGrid(); + LeftGrid = new MacroStabilityInwardsGrid(double.NaN, double.NaN, double.NaN, double.NaN); + RightGrid = new MacroStabilityInwardsGrid(double.NaN, double.NaN, double.NaN, double.NaN); CreateZones = true; } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Converters/MacroStabilityInwardsSlipPlaneUpliftVanConverter.cs =================================================================== diff -u -r0f736d81afe800a482dff027fe93128a5e967114 -r7472a3a034f5d43d665980b35727c63d167abb5e --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Converters/MacroStabilityInwardsSlipPlaneUpliftVanConverter.cs (.../MacroStabilityInwardsSlipPlaneUpliftVanConverter.cs) (revision 0f736d81afe800a482dff027fe93128a5e967114) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Service/Converters/MacroStabilityInwardsSlipPlaneUpliftVanConverter.cs (.../MacroStabilityInwardsSlipPlaneUpliftVanConverter.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using Core.Common.Base.Data; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan; using Ringtoets.MacroStabilityInwards.KernelWrapper.Calculators.UpliftVan.Output; @@ -56,12 +55,11 @@ private static MacroStabilityInwardsGrid ConvertGrid(UpliftVanGrid grid) { - return new MacroStabilityInwardsGrid + return new MacroStabilityInwardsGrid(grid.XLeft, + grid.XRight, + grid.ZTop, + grid.ZBottom) { - XLeft = (RoundedDouble) grid.XLeft, - XRight = (RoundedDouble) grid.XRight, - ZTop = (RoundedDouble) grid.ZTop, - ZBottom = (RoundedDouble) grid.ZBottom, NumberOfHorizontalPoints = grid.NumberOfHorizontalPoints, NumberOfVerticalPoints = grid.NumberOfVerticalPoints }; Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsGridTest.cs =================================================================== diff -u -r47b2bbe8b9d15194a9641a2db098c25e5e775528 -r7472a3a034f5d43d665980b35727c63d167abb5e --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsGridTest.cs (.../MacroStabilityInwardsGridTest.cs) (revision 47b2bbe8b9d15194a9641a2db098c25e5e775528) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsGridTest.cs (.../MacroStabilityInwardsGridTest.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -22,7 +22,6 @@ using System; using Core.Common.Base.Data; using Core.Common.Data.TestUtil; -using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.TestUtil; using Ringtoets.MacroStabilityInwards.Data.TestUtil; @@ -36,7 +35,7 @@ public void Constructor_ExpectedValues() { // Call - var grid = new MacroStabilityInwardsGrid(); + var grid = new MacroStabilityInwardsGrid(double.NaN, double.NaN, double.NaN, double.NaN); // Assert Assert.IsInstanceOf(grid); @@ -63,17 +62,21 @@ // Setup var random = new Random(21); double xLeft = random.NextDouble(); - double xRight = random.NextDouble(); - double zTop = random.NextDouble(); + double xRight = 1 + random.NextDouble(); + double zTop = 1 + random.NextDouble(); double zBottom = random.NextDouble(); + int numberOfHorizontalPoints = random.Next(1, 100); + int numberOfVerticalPoints = random.Next(1, 100); // call - var grid = new MacroStabilityInwardsGrid + var grid = new MacroStabilityInwardsGrid(double.NaN, double.NaN, double.NaN, double.NaN) { XLeft = (RoundedDouble) xLeft, XRight = (RoundedDouble) xRight, ZTop = (RoundedDouble) zTop, - ZBottom = (RoundedDouble) zBottom + ZBottom = (RoundedDouble) zBottom, + NumberOfHorizontalPoints = numberOfHorizontalPoints, + NumberOfVerticalPoints = numberOfVerticalPoints }; // Assert @@ -92,21 +95,23 @@ Assert.AreEqual(2, grid.ZBottom.NumberOfDecimalPlaces); Assert.AreEqual(zBottom, grid.ZBottom, grid.ZBottom.GetAccuracy()); + + Assert.AreEqual(numberOfHorizontalPoints, grid.NumberOfHorizontalPoints); + Assert.AreEqual(numberOfVerticalPoints, grid.NumberOfVerticalPoints); } [Test] public void Clone_Always_ReturnNewInstanceWithCopiedValues() { // Setup var random = new Random(21); - var original = new MacroStabilityInwardsGrid + var original = new MacroStabilityInwardsGrid(random.NextDouble(), + 1 + random.NextDouble(), + 1 + random.NextDouble(), + random.NextDouble()) { - XLeft = random.NextRoundedDouble(), - XRight = random.NextRoundedDouble(), - NumberOfHorizontalPoints = random.Next(), - ZTop = random.NextRoundedDouble(), - ZBottom = random.NextRoundedDouble(), - NumberOfVerticalPoints = random.Next() + NumberOfHorizontalPoints = random.Next(1, 100), + NumberOfVerticalPoints = random.Next(1, 100) }; // Call Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsGridTestFactoryTest.cs =================================================================== diff -u -r59adecfc7f82ab8277440ecae147453f5cbddbbf -r7472a3a034f5d43d665980b35727c63d167abb5e --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsGridTestFactoryTest.cs (.../MacroStabilityInwardsGridTestFactoryTest.cs) (revision 59adecfc7f82ab8277440ecae147453f5cbddbbf) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil.Test/MacroStabilityInwardsGridTestFactoryTest.cs (.../MacroStabilityInwardsGridTestFactoryTest.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -20,6 +20,7 @@ // All rights reserved. using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.MacroStabilityInwards.Data.TestUtil.Test { @@ -33,10 +34,10 @@ MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create(); // Assert - Assert.AreEqual(0.1, grid.XLeft); - Assert.AreEqual(0.2, grid.XRight); - Assert.AreEqual(0.3, grid.ZTop); - Assert.AreEqual(0.4, grid.ZBottom); + Assert.AreEqual(1.0, grid.XLeft, grid.XLeft.GetAccuracy()); + Assert.AreEqual(2.0, grid.XRight, grid.XRight.GetAccuracy()); + Assert.AreEqual(4.0, grid.ZTop, grid.ZTop.GetAccuracy()); + Assert.AreEqual(3.0, grid.ZBottom, grid.ZBottom.GetAccuracy()); Assert.AreEqual(1, grid.NumberOfHorizontalPoints); Assert.AreEqual(2, grid.NumberOfVerticalPoints); } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsGridTestFactory.cs =================================================================== diff -u -r59adecfc7f82ab8277440ecae147453f5cbddbbf -r7472a3a034f5d43d665980b35727c63d167abb5e --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsGridTestFactory.cs (.../MacroStabilityInwardsGridTestFactory.cs) (revision 59adecfc7f82ab8277440ecae147453f5cbddbbf) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.TestUtil/MacroStabilityInwardsGridTestFactory.cs (.../MacroStabilityInwardsGridTestFactory.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -19,8 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using Core.Common.Base.Data; - namespace Ringtoets.MacroStabilityInwards.Data.TestUtil { /// @@ -35,15 +33,11 @@ /// The created . public static MacroStabilityInwardsGrid Create() { - return new MacroStabilityInwardsGrid + return new MacroStabilityInwardsGrid(1.0, 2.0, 4.0, 3.0) { - XLeft = (RoundedDouble) 0.1, - XRight = (RoundedDouble) 0.2, - ZTop = (RoundedDouble) 0.3, - ZBottom = (RoundedDouble) 0.4, NumberOfHorizontalPoints = 1, NumberOfVerticalPoints = 2 }; } } -} +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Factories/MacroStabilityInwardsChartDataPointsFactoryTest.cs =================================================================== diff -u -r66396d7a91ffdfadfcd6a94759ce579c611c78b9 -r7472a3a034f5d43d665980b35727c63d167abb5e --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Factories/MacroStabilityInwardsChartDataPointsFactoryTest.cs (.../MacroStabilityInwardsChartDataPointsFactoryTest.cs) (revision 66396d7a91ffdfadfcd6a94759ce579c611c78b9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Factories/MacroStabilityInwardsChartDataPointsFactoryTest.cs (.../MacroStabilityInwardsChartDataPointsFactoryTest.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -24,7 +24,6 @@ using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; -using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; @@ -826,16 +825,15 @@ [Test] public void CreateGridPoints_MacroStabilityInwardsGridDeterminationTypeAutomatic_ReturnsEmptyPoints() { - // Setup + // Setup var random = new Random(21); - var grid = new MacroStabilityInwardsGrid + var grid = new MacroStabilityInwardsGrid(random.NextDouble(), + 1 + random.NextDouble(), + 1 + random.NextDouble(), + random.NextDouble()) { NumberOfHorizontalPoints = 0, - XLeft = random.NextRoundedDouble(), - XRight = random.NextRoundedDouble(), - NumberOfVerticalPoints = 1, - ZTop = random.NextRoundedDouble(), - ZBottom = random.NextRoundedDouble() + NumberOfVerticalPoints = 1 }; // Call @@ -957,101 +955,65 @@ { var random = new Random(21); - RoundedDouble xLeft = random.NextRoundedDouble(); - RoundedDouble xRight = random.NextRoundedDouble(); - RoundedDouble zTop = random.NextRoundedDouble(); - RoundedDouble zBottom = random.NextRoundedDouble(); - yield return new TestCaseData(new MacroStabilityInwardsGrid + double xLeft = random.NextDouble(); + double xRight = 1 + random.NextDouble(); + double zTop = 1 + random.NextDouble(); + double zBottom = random.NextDouble(); + yield return new TestCaseData(new MacroStabilityInwardsGrid(xLeft, xRight, zTop, zBottom) { NumberOfHorizontalPoints = 0, - XLeft = xLeft, - XRight = xRight, - NumberOfVerticalPoints = 1, - ZTop = zTop, - ZBottom = zBottom - }).SetName("BothNrOfPointsZero"); + NumberOfVerticalPoints = 1 + }).SetName("NumberOfHorizontalPointsZero"); - yield return new TestCaseData(new MacroStabilityInwardsGrid + yield return new TestCaseData(new MacroStabilityInwardsGrid(xLeft, xRight, zTop, zBottom) { NumberOfHorizontalPoints = 1, - XLeft = xLeft, - XRight = xRight, - NumberOfVerticalPoints = 0, - ZTop = zTop, - ZBottom = zTop + NumberOfVerticalPoints = 0 }).SetName("NumberOfVerticalPointsZero"); - yield return new TestCaseData(new MacroStabilityInwardsGrid + yield return new TestCaseData(new MacroStabilityInwardsGrid(xLeft, xRight, zTop, zBottom) { NumberOfHorizontalPoints = 0, - XLeft = xLeft, - XRight = xRight, - NumberOfVerticalPoints = 0, - ZTop = zTop, - ZBottom = zBottom - }).SetName("NumberOfHorizontalPointsZero"); + NumberOfVerticalPoints = 0 + }).SetName("BothNrOfPointsZero"); - yield return new TestCaseData(new MacroStabilityInwardsGrid + yield return new TestCaseData(new MacroStabilityInwardsGrid(xLeft, xRight, zTop, zBottom) { NumberOfHorizontalPoints = 1, - XLeft = xLeft, - XRight = xRight, - NumberOfVerticalPoints = -1, - ZTop = zTop, - ZBottom = zBottom + NumberOfVerticalPoints = -1 }).SetName("NumberOfVerticalPointsNegative"); - yield return new TestCaseData(new MacroStabilityInwardsGrid + yield return new TestCaseData(new MacroStabilityInwardsGrid(xLeft, xRight, zTop, zBottom) { NumberOfHorizontalPoints = -1, - XLeft = xLeft, - XRight = xRight, - NumberOfVerticalPoints = 1, - ZTop = zTop, - ZBottom = zBottom + NumberOfVerticalPoints = 1 }).SetName("NumberOfHorizontalPointsNegative"); - yield return new TestCaseData(new MacroStabilityInwardsGrid + yield return new TestCaseData(new MacroStabilityInwardsGrid(double.NaN, xRight, zTop, zBottom) { NumberOfHorizontalPoints = 1, - XRight = xRight, - NumberOfVerticalPoints = 1, - ZTop = zTop, - ZBottom = zBottom + NumberOfVerticalPoints = 1 }).SetName("XLeftNaN"); - yield return new TestCaseData(new MacroStabilityInwardsGrid + yield return new TestCaseData(new MacroStabilityInwardsGrid(xLeft, double.NaN, zTop, zBottom) { NumberOfHorizontalPoints = 1, - XLeft = xLeft, - NumberOfVerticalPoints = 1, - ZTop = zTop, - ZBottom = zBottom + NumberOfVerticalPoints = 1 }).SetName("XRightNaN"); - yield return new TestCaseData(new MacroStabilityInwardsGrid + yield return new TestCaseData(new MacroStabilityInwardsGrid(xLeft, xRight, double.NaN, zBottom) { NumberOfHorizontalPoints = 1, - XLeft = xLeft, - XRight = xRight, - NumberOfVerticalPoints = 1, - ZBottom = zBottom + NumberOfVerticalPoints = 1 }).SetName("ZTopNaN"); - yield return new TestCaseData(new MacroStabilityInwardsGrid + yield return new TestCaseData(new MacroStabilityInwardsGrid(xLeft, xRight, zTop, double.NaN) { NumberOfHorizontalPoints = 1, - XLeft = xLeft, - XRight = xRight, - NumberOfVerticalPoints = 1, - ZTop = zBottom + NumberOfVerticalPoints = 1 }).SetName("ZBottomNaN"); } private static IEnumerable GetGridSettingsOnlyHorizontalPoints() { - var gridRightSmallerThanLeft = new MacroStabilityInwardsGrid + var gridRightSmallerThanLeft = new MacroStabilityInwardsGrid(1, -2, 3, 1) { NumberOfHorizontalPoints = 4, - XLeft = (RoundedDouble) 1, - XRight = (RoundedDouble) (-2.0), - NumberOfVerticalPoints = 1, - ZTop = (RoundedDouble) 3, - ZBottom = (RoundedDouble) 1 + NumberOfVerticalPoints = 1 }; yield return new TestCaseData(gridRightSmallerThanLeft, new[] { @@ -1061,14 +1023,10 @@ new Point2D(gridRightSmallerThanLeft.XRight, gridRightSmallerThanLeft.ZBottom) }).SetName("XRight < XLeft"); - var gridRightLargerThanLeft = new MacroStabilityInwardsGrid + var gridRightLargerThanLeft = new MacroStabilityInwardsGrid(1, 4, 3, 1) { NumberOfHorizontalPoints = 4, - XLeft = (RoundedDouble) 1, - XRight = (RoundedDouble) 4, - NumberOfVerticalPoints = 1, - ZTop = (RoundedDouble) 3, - ZBottom = (RoundedDouble) 1 + NumberOfVerticalPoints = 1 }; yield return new TestCaseData(gridRightLargerThanLeft, new[] { @@ -1081,14 +1039,10 @@ private static IEnumerable GetGridSettingsOnlyVerticalPoints() { - var gridTopLargerThanBottom = new MacroStabilityInwardsGrid + var gridTopLargerThanBottom = new MacroStabilityInwardsGrid(1, 3, 4, 1) { NumberOfHorizontalPoints = 1, - XLeft = (RoundedDouble) 1, - XRight = (RoundedDouble) 3, - NumberOfVerticalPoints = 4, - ZTop = (RoundedDouble) 4, - ZBottom = (RoundedDouble) 1 + NumberOfVerticalPoints = 4 }; yield return new TestCaseData(gridTopLargerThanBottom, new[] { @@ -1098,14 +1052,10 @@ new Point2D(gridTopLargerThanBottom.XLeft, gridTopLargerThanBottom.ZTop) }).SetName("ZTop > ZBottom"); - var gridBottomLargerThanTop = new MacroStabilityInwardsGrid + var gridBottomLargerThanTop = new MacroStabilityInwardsGrid(1, 3, -2, 1) { NumberOfHorizontalPoints = 1, - XLeft = (RoundedDouble) 1, - XRight = (RoundedDouble) 3, - NumberOfVerticalPoints = 4, - ZTop = (RoundedDouble) (-2), - ZBottom = (RoundedDouble) 1 + NumberOfVerticalPoints = 4 }; yield return new TestCaseData(gridBottomLargerThanTop, new[] { @@ -1118,41 +1068,29 @@ private static IEnumerable GetGridSettingsOnePoint() { - var zBottom = (RoundedDouble) 1; + const double zBottom = 1.0; - var grid = new MacroStabilityInwardsGrid + var grid = new MacroStabilityInwardsGrid(1, 2, 3, zBottom) { NumberOfHorizontalPoints = 1, - XLeft = (RoundedDouble) 1, - XRight = (RoundedDouble) 2, - NumberOfVerticalPoints = 1, - ZTop = (RoundedDouble) 3, - ZBottom = zBottom + NumberOfVerticalPoints = 1 }; yield return new TestCaseData(grid).SetName("XRight > XLeft, ZTop > ZBottom"); - var inverseGrid = new MacroStabilityInwardsGrid + var inverseGrid = new MacroStabilityInwardsGrid(1, -2, -3, zBottom) { NumberOfHorizontalPoints = 1, - XLeft = (RoundedDouble) 1, - XRight = (RoundedDouble) (-2), - NumberOfVerticalPoints = 1, - ZTop = (RoundedDouble) (-3), - ZBottom = zBottom + NumberOfVerticalPoints = 1 }; yield return new TestCaseData(inverseGrid).SetName("XRight < XLeft, ZTop < ZBottom"); } private static IEnumerable GetWellDefinedGridSettings() { - var grid = new MacroStabilityInwardsGrid + var grid = new MacroStabilityInwardsGrid(1, 3, 3, 1) { NumberOfHorizontalPoints = 3, - XLeft = (RoundedDouble) 1, - XRight = (RoundedDouble) 3, - NumberOfVerticalPoints = 3, - ZTop = (RoundedDouble) 3, - ZBottom = (RoundedDouble) 1 + NumberOfVerticalPoints = 3 }; yield return new TestCaseData(grid, new[] { @@ -1167,14 +1105,10 @@ new Point2D(grid.XRight, grid.ZTop) }).SetName("XRight > XLeft, ZTop > ZBottom"); - var inverseGrid = new MacroStabilityInwardsGrid + var inverseGrid = new MacroStabilityInwardsGrid(1, -1, -1, 1) { NumberOfHorizontalPoints = 3, - XLeft = (RoundedDouble) 1, - XRight = (RoundedDouble) (-1), - NumberOfVerticalPoints = 3, - ZTop = (RoundedDouble) (-1), - ZBottom = (RoundedDouble) 1 + NumberOfVerticalPoints = 3 }; yield return new TestCaseData(inverseGrid, new[] { @@ -1192,16 +1126,15 @@ private static IEnumerable GetGridSettingsPointsOverlap() { - var commonCoordinateValue = (RoundedDouble) 5; + const double commonCoordinateValue = 5.0; - var horizontalPointsOverlap = new MacroStabilityInwardsGrid + var horizontalPointsOverlap = new MacroStabilityInwardsGrid(commonCoordinateValue, + commonCoordinateValue, + 2, + 1) { NumberOfHorizontalPoints = 3, - XLeft = commonCoordinateValue, - XRight = commonCoordinateValue, - NumberOfVerticalPoints = 2, - ZTop = (RoundedDouble) 2, - ZBottom = (RoundedDouble) 1 + NumberOfVerticalPoints = 2 }; yield return new TestCaseData(horizontalPointsOverlap, new[] { @@ -1213,14 +1146,13 @@ new Point2D(commonCoordinateValue, horizontalPointsOverlap.ZTop) }).SetName("HorizontalPointsOverlap"); - var grid = new MacroStabilityInwardsGrid + var grid = new MacroStabilityInwardsGrid(1, + 2, + commonCoordinateValue, + commonCoordinateValue) { NumberOfHorizontalPoints = 2, - XLeft = (RoundedDouble) 1, - XRight = (RoundedDouble) 2, - NumberOfVerticalPoints = 3, - ZTop = commonCoordinateValue, - ZBottom = commonCoordinateValue + NumberOfVerticalPoints = 3 }; yield return new TestCaseData(grid, new[] { Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsGridPropertiesTest.cs =================================================================== diff -u -rbd0a78dc9dd218a799c43b114725f6efa4da1687 -r7472a3a034f5d43d665980b35727c63d167abb5e --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsGridPropertiesTest.cs (.../MacroStabilityInwardsGridPropertiesTest.cs) (revision bd0a78dc9dd218a799c43b114725f6efa4da1687) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsGridPropertiesTest.cs (.../MacroStabilityInwardsGridPropertiesTest.cs) (revision 7472a3a034f5d43d665980b35727c63d167abb5e) @@ -32,6 +32,7 @@ using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.TestUtil; using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.Data.TestUtil; using Ringtoets.MacroStabilityInwards.Forms.PropertyClasses; namespace Ringtoets.MacroStabilityInwards.Forms.Test.PropertyClasses @@ -54,14 +55,14 @@ var changeHandler = mocks.Stub(); mocks.ReplayAll(); - var data = new MacroStabilityInwardsGrid(); + MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create(); // Call - var properties = new MacroStabilityInwardsGridProperties(data, changeHandler, false); + var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, false); // Assert Assert.IsInstanceOf>(properties); - Assert.AreSame(data, properties.Data); + Assert.AreSame(grid, properties.Data); mocks.VerifyAll(); } @@ -85,8 +86,11 @@ [Test] public void Constructor_HandlerNull_ThrowsArgumentNullException() { + // Setup + MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create(); + // Call - TestDelegate call = () => new MacroStabilityInwardsGridProperties(new MacroStabilityInwardsGrid(), null, false); + TestDelegate call = () => new MacroStabilityInwardsGridProperties(grid, null, false); // Assert var exception = Assert.Throws(call); @@ -103,7 +107,7 @@ var changeHandler = mocks.Stub(); mocks.ReplayAll(); - var grid = new MacroStabilityInwardsGrid(); + MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create(); // Call var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, isReadOnly); @@ -174,7 +178,7 @@ var changeHandler = mocks.Stub(); mocks.ReplayAll(); - var grid = new MacroStabilityInwardsGrid(); + MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create(); // Call var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, false); @@ -202,8 +206,8 @@ var random = new Random(21); RoundedDouble xLeft = random.NextRoundedDouble(); - RoundedDouble xRight = random.NextRoundedDouble(); - RoundedDouble zTop = random.NextRoundedDouble(); + var xRight = (RoundedDouble) (1 + random.NextDouble()); + var zTop = (RoundedDouble) (1 + random.NextDouble()); RoundedDouble zBottom = random.NextRoundedDouble(); int numberOfHorizontalPoints = random.Next(); int numberOfVerticalPoints = random.Next(); @@ -293,7 +297,8 @@ var changeHandler = mocks.Stub(); mocks.ReplayAll(); - var properties = new MacroStabilityInwardsGridProperties(new MacroStabilityInwardsGrid(), changeHandler, false); + MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create(); + var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, false); // Call string toString = properties.ToString(); @@ -312,7 +317,8 @@ var changeHandler = mocks.Stub(); mocks.ReplayAll(); - var properties = new MacroStabilityInwardsGridProperties(new MacroStabilityInwardsGrid(), changeHandler, isReadOnly); + MacroStabilityInwardsGrid grid = MacroStabilityInwardsGridTestFactory.Create(); + var properties = new MacroStabilityInwardsGridProperties(grid, changeHandler, isReadOnly); // Call bool result = properties.DynamicReadOnlyValidationMethod(string.Empty);