Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs =================================================================== diff -u -r4627 -r4838 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 4627) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 4838) @@ -34,18 +34,20 @@ public class PlLinesToWaternetConverterTests { + private const double precision3Decimals = 0.00051; + private static readonly Random random = new(21); + private static readonly double leftCoordinate = random.NextDouble(); + private static readonly double rightCoordinate = leftCoordinate + 1; + private static readonly double middleXCoordinate = 0.5 * (leftCoordinate + rightCoordinate); + private const double penetrationLength = 0.5; + [Test] [TestCase(0)] [TestCase(0.01)] [TestCase(10)] - public void ConvertPlLineToWaternet_PlLinesFullyDefinedAtOrBelowSoil1DProfile_ReturnsExpectedWaternet(double offsetFromBottomOfProfile) + public void ConvertPlLineToWaternet_PlLinesFullyDefinedAtOrBelowBottomSoil1DProfile_ReturnsEmptyWaternet(double offsetFromBottomOfProfile) { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); - SoilProfile1D soilProfile = CreateSoilProfile1DForTest(); double bottomLevel = soilProfile.BottomLevel; double plLineZCoordinate = bottomLevel - offsetFromBottomOfProfile; @@ -79,59 +81,70 @@ [Test] public void TestConvertPlLinesToWaternet() { - const double cDif = 0.0001; PlLines plLines = CreatePlLinesForTest(); SoilProfile1D soilProfile1D = CreateSoilProfile1DForTest(); - Assert.That(soilProfile1D.InBetweenAquiferLayer.TopLevel, Is.EqualTo(-2.111).Within(cDif)); - Assert.That(soilProfile1D.BottomAquiferLayer.TopLevel, Is.EqualTo(-6.111).Within(cDif)); + Assert.Multiple(() => + { + Assert.That(soilProfile1D.InBetweenAquiferLayer.TopLevel, Is.EqualTo(-2.111).Within(precision3Decimals)); + Assert.That(soilProfile1D.BottomAquiferLayer.TopLevel, Is.EqualTo(-6.111).Within(precision3Decimals)); + }); - const double penetrationLength = 2.1; + const double penetrateLength = 2.1; const double left = 0; const double right = 100; - Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrationLength, left, right); + Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrateLength, left, right); - // Pl 1 is only the phreatic line, a headline or waternetline does not have to be created - // Pl 2 gets waternetline to level of BottomAquiferLayer.TopLevel + penetrationLength - // Pl 3 gets waternetline to level of InBetweenAquiferLayer.TopLevel - // Pl 4 gets waternetline to level of BottomAquiferLayer.TopLevel + // Pl 1 is only the phreatic line, a headline or waternet line does not have to be created + // Pl 2 gets waternet line to level of BottomAquiferLayer.TopLevel + penetrationLength + // Pl 3 gets waternet line to level of InBetweenAquiferLayer.TopLevel + // Pl 4 gets waternet line to level of BottomAquiferLayer.TopLevel - // ex[ected phreatic line from pl 1 - Assert.That(waternet.PhreaticLine.Points.Count, Is.EqualTo(3)); - Assert.That(waternet.PhreaticLine.Points[0].X, Is.EqualTo(0).Within(cDif)); - Assert.That(waternet.PhreaticLine.Points[0].Z, Is.EqualTo(0).Within(cDif)); - Assert.That(waternet.PhreaticLine.Points[1].X, Is.EqualTo(50).Within(cDif)); - Assert.That(waternet.PhreaticLine.Points[1].Z, Is.EqualTo(1).Within(cDif)); - Assert.That(waternet.PhreaticLine.Points[2].X, Is.EqualTo(100).Within(cDif)); - Assert.That(waternet.PhreaticLine.Points[2].Z, Is.EqualTo(1).Within(cDif)); - // expected head lines from pl 2, 3 and 4 - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); - Assert.That(waternet.HeadLineList[0].Points.Count, Is.EqualTo(2)); - Assert.That(waternet.HeadLineList[1].Points.Count, Is.EqualTo(3)); - Assert.That(waternet.HeadLineList[2].Points.Count, Is.EqualTo(2)); - // check the points of first head line that represents pl 2 - Assert.That(waternet.HeadLineList[0].Points[0].X, Is.EqualTo(0).Within(cDif)); - Assert.That(waternet.HeadLineList[0].Points[0].Z, Is.EqualTo(0).Within(cDif)); - Assert.That(waternet.HeadLineList[0].Points[1].X, Is.EqualTo(100).Within(cDif)); - Assert.That(waternet.HeadLineList[0].Points[1].Z, Is.EqualTo(-1).Within(cDif)); + // expected phreatic line from pl 1 + Assert.That(waternet.PhreaticLine.Points, Has.Count.EqualTo(3)); + Assert.Multiple(() => + { + Assert.That(waternet.PhreaticLine.Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternet.PhreaticLine.Points[0].Z, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternet.PhreaticLine.Points[1].X, Is.EqualTo(50).Within(precision3Decimals)); + Assert.That(waternet.PhreaticLine.Points[1].Z, Is.EqualTo(1).Within(precision3Decimals)); + Assert.That(waternet.PhreaticLine.Points[2].X, Is.EqualTo(100).Within(precision3Decimals)); + Assert.That(waternet.PhreaticLine.Points[2].Z, Is.EqualTo(1).Within(precision3Decimals)); + // expected head lines from pl 2, 3 and 4 + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); + }); + Assert.Multiple(() => + { + Assert.That(waternet.HeadLineList[0].Points.Count, Is.EqualTo(2)); + Assert.That(waternet.HeadLineList[1].Points.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList[2].Points.Count, Is.EqualTo(2)); + // check the points of first head line that represents pl 2 + Assert.That(waternet.HeadLineList[0].Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternet.HeadLineList[0].Points[0].Z, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternet.HeadLineList[0].Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); + Assert.That(waternet.HeadLineList[0].Points[1].Z, Is.EqualTo(-1).Within(precision3Decimals)); - // expected waternet lines from pl 2, 3 and 4 - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(3)); + // expected waternet lines from pl 2, 3 and 4 + Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(3)); + }); - // expected waternet line 0 is connected to pl2 with level -6.111 + 2.1 = -4.011 - Assert.That(waternet.WaternetLineList[0].HeadLine, Is.EqualTo(waternet.HeadLineList[0])); - Assert.That(waternet.WaternetLineList[0].Points[0].X, Is.EqualTo(0).Within(cDif)); - Assert.That(waternet.WaternetLineList[0].Points[0].Z, Is.EqualTo(-4.011).Within(cDif)); - Assert.That(waternet.WaternetLineList[0].Points[1].X, Is.EqualTo(100).Within(cDif)); - Assert.That(waternet.WaternetLineList[0].Points[1].Z, Is.EqualTo(-4.011).Within(cDif)); + Assert.Multiple(() => + { + // expected waternet line 0 is connected to pl2 with level -6.111 + 2.1 = -4.011 + Assert.That(waternet.WaternetLineList[0].HeadLine, Is.EqualTo(waternet.HeadLineList[0])); + Assert.That(waternet.WaternetLineList[0].Points[0].X, Is.EqualTo(0).Within(precision3Decimals)); + Assert.That(waternet.WaternetLineList[0].Points[0].Z, Is.EqualTo(-4.011).Within(precision3Decimals)); + Assert.That(waternet.WaternetLineList[0].Points[1].X, Is.EqualTo(100).Within(precision3Decimals)); + Assert.That(waternet.WaternetLineList[0].Points[1].Z, Is.EqualTo(-4.011).Within(precision3Decimals)); - // expected waternet line 1 is connected to pl3 with level -6.111 - Assert.That(waternet.WaternetLineList[1].HeadLine, Is.EqualTo(waternet.HeadLineList[1])); - Assert.That(waternet.WaternetLineList[1].Points[0].Z, Is.EqualTo(-6.111).Within(cDif)); + // expected waternet line 1 is connected to pl3 with level -6.111 + Assert.That(waternet.WaternetLineList[1].HeadLine, Is.EqualTo(waternet.HeadLineList[1])); + Assert.That(waternet.WaternetLineList[1].Points[0].Z, Is.EqualTo(-6.111).Within(precision3Decimals)); - // expected waternet line 2 is connected to pl4 with level -2.111 - Assert.That(waternet.WaternetLineList[2].HeadLine, Is.EqualTo(waternet.HeadLineList[2])); - Assert.That(waternet.WaternetLineList[2].Points[0].Z, Is.EqualTo(-2.111).Within(cDif)); + // expected waternet line 2 is connected to pl4 with level -2.111 + Assert.That(waternet.WaternetLineList[2].HeadLine, Is.EqualTo(waternet.HeadLineList[2])); + Assert.That(waternet.WaternetLineList[2].Points[0].Z, Is.EqualTo(-2.111).Within(precision3Decimals)); + }); } [Test] @@ -141,111 +154,119 @@ SoilProfile1D soilProfile1D = CreateSoilProfile1DForTest(); Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, 0, 0, 0); // head lines - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); - Assert.That(waternet.HeadLineList[0].Points.Count, Is.EqualTo(2)); - Assert.That(waternet.HeadLineList[1].Points.Count, Is.EqualTo(3)); - Assert.That(waternet.HeadLineList[2].Points.Count, Is.EqualTo(2)); - // phreatic line - Assert.That(waternet.PhreaticLine.Points.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); + Assert.Multiple(() => + { + Assert.That(waternet.HeadLineList[0].Points.Count, Is.EqualTo(2)); + Assert.That(waternet.HeadLineList[1].Points.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList[2].Points.Count, Is.EqualTo(2)); + // phreatic line + Assert.That(waternet.PhreaticLine.Points.Count, Is.EqualTo(3)); + }); // check that no headline are added when Pl2, Pl3 or Pl4 does not exist or has no points plLines.Lines[PlLineType.Pl3] = null; plLines.Lines[PlLineType.Pl4].Points.Clear(); waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, 0, 0, 0); // head lines - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(1)); - Assert.That(waternet.HeadLineList[0].Points.Count, Is.EqualTo(2)); - // phreatic line - Assert.That(waternet.PhreaticLine.Points.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(1)); + Assert.Multiple(() => + { + Assert.That(waternet.HeadLineList[0].Points, Has.Count.EqualTo(2)); + // phreatic line + Assert.That(waternet.PhreaticLine.Points, Has.Count.EqualTo(3)); + }); } [Test] public void TestConvertPlLinesToWaternetWhenNoWaternetLinesExpected() { - const double cDif = 0.0001; PlLines plLines = CreatePlLinesForTest(); SoilProfile1D soilProfile1D = CreateSoilProfile1DForTest(); - const double penetrationLength = 2.1; - Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrationLength, 0, 0); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(3)); + const double penetrateLength = 2.1; + Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrateLength, 0, 0); + Assert.Multiple(() => + { + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(3)); + }); // check that no waternetlines are added for pl3 when InBetweenAquiferLayer is null soilProfile1D = CreateSoilProfile1DWith1AquiferForTest(); - waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrationLength, 0, 0); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(2)); - // expected waternet line 0 is connected to pl2 with level -6.111 + 2.1 = -4.011 - Assert.That(waternet.WaternetLineList[0].HeadLine, Is.EqualTo(waternet.HeadLineList[0])); - Assert.That(waternet.WaternetLineList[0].Points[0].Z, Is.EqualTo(-4.011).Within(cDif)); - // expected waternet line 1 is connected to pl3 with level -6.111 - Assert.That(waternet.WaternetLineList[1].HeadLine, Is.EqualTo(waternet.HeadLineList[1])); - Assert.That(waternet.WaternetLineList[1].Points[0].Z, Is.EqualTo(-6.111).Within(cDif)); + waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrateLength, 0, 0); + Assert.Multiple(() => + { + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(2)); + }); + Assert.Multiple(() => + { + // expected waternet line 0 is connected to pl2 with level -6.111 + 2.1 = -4.011 + Assert.That(waternet.WaternetLineList[0].HeadLine, Is.EqualTo(waternet.HeadLineList[0])); + Assert.That(waternet.WaternetLineList[0].Points[0].Z, Is.EqualTo(-4.011).Within(precision3Decimals)); + // expected waternet line 1 is connected to pl3 with level -6.111 + Assert.That(waternet.WaternetLineList[1].HeadLine, Is.EqualTo(waternet.HeadLineList[1])); + Assert.That(waternet.WaternetLineList[1].Points[0].Z, Is.EqualTo(-6.111).Within(precision3Decimals)); + }); // check that no waternetlines are added for pl2, pl3 and pl4 when BottomAquiferLayer is null soilProfile1D = CreateSoilProfile1DWithoutAquifersForTest(); - waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrationLength, 0, 0); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(0)); + waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile1D, penetrateLength, 0, 0); + Assert.Multiple(() => + { + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); + Assert.That(waternet.WaternetLineList, Is.Empty); + }); } [Test] public void TestConvertLevelToWaternetLine() { - const double cDif = 0.0001; - const double level = 1.234; const double left = -50.111; const double right = 50.123; WaternetLine waternetLine = PlLinesToWaternetConverter.CreateWaternetLine(level, left, right); - Assert.That(waternetLine.Points.Count, Is.EqualTo(2)); - Assert.That(waternetLine.Points[0].X, Is.EqualTo(-50.111).Within(cDif)); - Assert.That(waternetLine.Points[0].Z, Is.EqualTo(1.234).Within(cDif)); - Assert.That(waternetLine.Points[1].X, Is.EqualTo(50.123).Within(cDif)); - Assert.That(waternetLine.Points[1].Z, Is.EqualTo(1.234).Within(cDif)); + Assert.That(waternetLine.Points, Has.Count.EqualTo(2)); + Assert.Multiple(() => + { + Assert.That(waternetLine.Points[0].X, Is.EqualTo(-50.111).Within(precision3Decimals)); + Assert.That(waternetLine.Points[0].Z, Is.EqualTo(1.234).Within(precision3Decimals)); + Assert.That(waternetLine.Points[1].X, Is.EqualTo(50.123).Within(precision3Decimals)); + Assert.That(waternetLine.Points[1].Z, Is.EqualTo(1.234).Within(precision3Decimals)); + }); } + /// + /// Different soil profiles 2D are tested, see the pictures in method GetSoilProfilesWithContinuousBottomAquiferLayer, + /// with a top clay layer and bottom aquifer layers always forming a continuous bottom layer. + /// Expected is that: + /// - PL3 is connected to the top of the bottom aquifer layer + /// - PL2 is connected to the line parallel to the top of the bottom aquifer layer but shifted by 0.5 m (penetration length) upwards + /// - PL4 is not used because no in-between aquifer is present + /// + /// + /// [Test] [TestCaseSource(nameof(GetSoilProfilesWithContinuousBottomAquiferLayer))] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousAquiferLayers_ReturnsExpectedWaternet( SoilProfile2D soilProfile, IEnumerable expectedBottomAquiferCoordinates) { // Setup - var random = new Random(21); - double leftCoordinate = soilProfile.Geometry.Left; - double rightCoordinate = soilProfile.Geometry.Right; - double penetrationLength = random.NextDouble(); + PlLines plLines = CreateAllPlLines(); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); - - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(2)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(2)); WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.That(pl2WaternetLine.HeadLine, Is.SameAs(waternet.HeadLineList[0])); @@ -259,59 +280,33 @@ } /// - /// ------------------------------------------------------------- - /// top layer - /// ------------------------------------------------------------- - /// inbetween aquifer layer left | inbetween aquifer layer right - /// ------------------------------------------------------------- - /// inbetween layer - /// ------------------------------------------------------------- - /// bottom aquifer layer + /// --------------------------------------------------------------- Level 0 m + /// top layer + /// --------------------------------------------------------------- Level -10 m + /// in-between aquifer layer left | in-between aquifer layer right + /// --------------------------------------------------------------- Level -20 m + /// in-between layer + /// --------------------------------------------------------------- Level -25 m + /// bottom aquifer layer + /// --------------------------------------------------------------- Level -30 m /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerConsistOfTwoParts_ReturnsExpectedWaternet() { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); - - var topLeftUpperLayer = new Point2D(leftCoordinate, 0); - var topRightUpperLayer = new Point2D(rightCoordinate, 0); - var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); - var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); - SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); - - var topRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -10); - var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); - var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, topRightInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); - soilLayerAquiferInBetweenLeft.IsAquifer = true; - - var topRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -10); - var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -20); - SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(topRightInBetweenAquiferLayerLeft, topRightInBetweenAquiferLayerRight, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerLeft); - soilLayerAquiferInBetweenRight.IsAquifer = true; - - var topRightInBetweenLayer = new Point2D(rightCoordinate, -20); - var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); - var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); - SoilLayer2D soilLayerInBetween = CreateSoilLayer2D(bottomLeftInBetweenAquiferLayerLeft, topRightInBetweenLayer, bottomRightInBetweenLayer, bottomLeftInBetweenLayer); - - var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); - var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); - var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); - SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); - soilLayerAquiferBottom.IsAquifer = true; - + SoilLayer2D soilLayer = CreateRectangularSoilLayer2D(0, -10, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferInBetweenLeft = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, middleXCoordinate, true); + SoilLayer2D soilLayerAquiferInBetweenRight = CreateRectangularSoilLayer2D(-10, -20, middleXCoordinate, rightCoordinate, true); + SoilLayer2D soilLayerInBetween = CreateRectangularSoilLayer2D(-20, -25, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferBottom = CreateRectangularSoilLayer2D(-25, -30, leftCoordinate, rightCoordinate, true); + var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, - Bottom = -20 + Bottom = -30 } }; soilProfile.Surfaces.Add(soilLayer); @@ -320,42 +315,27 @@ soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + PlLines plLines = CreateAllPlLines(); - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(3)); Point2D[] expectedBottomAquiferCoordinates = - { - bottomLeftInBetweenLayer, - new Point2D(rightCoordinate / 2, -25), - topRightBottomAquiferLayer - }; + [ + new Point2D(leftCoordinate, -25), + new Point2D(middleXCoordinate, -25), + new Point2D(rightCoordinate, -25) + ]; WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.That(pl2WaternetLine.HeadLine, Is.SameAs(waternet.HeadLineList[0])); @@ -369,103 +349,69 @@ WaternetLine pl4WaternetLine = waternet.WaternetLineList[2]; Assert.That(pl4WaternetLine.HeadLine, Is.SameAs(waternet.HeadLineList[2])); - AssertGeometry(new[] - { - bottomLeftUpperLayer, - topRightInBetweenAquiferLayerLeft, - topRightInBetweenAquiferLayerRight - }, pl4WaternetLine.Points); + AssertGeometry([ + new Point2D(leftCoordinate, -10), + new Point2D(middleXCoordinate, -10), + new Point2D(rightCoordinate, -10) + ], pl4WaternetLine.Points); } /// - /// --------------------------------------------------- - /// top layer - /// --------------------------------------------------- - /// inbetween aquifer layer - /// --------------------------------------------------- - /// inbetween layer - /// --------------------------------------------------- - /// bottom aquifer layer + /// --------------------------------------------------- Level 0 m + /// top layer + /// --------------------------------------------------- Level -10 m + /// in-between aquifer layer + /// --------------------------------------------------- Level -20 m + /// in-between layer + /// --------------------------------------------------- Level -25 m + /// bottom aquifer layer + /// --------------------------------------------------- Level -30 m /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerConsistOfOnePart_ReturnsExpectedWaternet() { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); + SoilLayer2D soilLayer = CreateRectangularSoilLayer2D(0, -10, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferInBetween = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, rightCoordinate, true); + SoilLayer2D soilLayerInBetween = CreateRectangularSoilLayer2D(-20, -25, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferBottom = CreateRectangularSoilLayer2D(-25, -30, leftCoordinate, rightCoordinate, true); - var topLeftUpperLayer = new Point2D(leftCoordinate, 0); - var topRightUpperLayer = new Point2D(rightCoordinate, 0); - var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); - var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); - SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); - - var bottomRightInBetweenAquiferLayer = new Point2D(rightCoordinate, -20); - var bottomLeftInBetweenAquiferLayer = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferInBetween = CreateSoilLayer2D(bottomLeftUpperLayer, bottomRightUpperLayer, bottomRightInBetweenAquiferLayer, bottomLeftInBetweenAquiferLayer); - soilLayerAquiferInBetween.IsAquifer = true; - - var topRightInBetweenLayer = new Point2D(rightCoordinate, -20); - var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); - var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); - SoilLayer2D soilLayerInBetween = CreateSoilLayer2D(bottomLeftInBetweenAquiferLayer, topRightInBetweenLayer, bottomRightInBetweenLayer, bottomLeftInBetweenLayer); - - var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); - var bottomleftBottomAquiferLayer = new Point2D(leftCoordinate, -30); - SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, bottomRightInBetweenLayer, bottomRightBottomAquiferLayer, bottomleftBottomAquiferLayer); - soilLayerAquiferBottom.IsAquifer = true; - var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, - Bottom = -20 + Bottom = -30 } }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferInBetween); soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + PlLines plLines = CreateAllPlLines(); - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(3)); + var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); + var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); Point2D[] expectedBottomAquiferCoordinates = - { + [ bottomLeftInBetweenLayer, bottomRightInBetweenLayer - }; + ]; WaternetLine pl2WaternetLine = waternet.WaternetLineList[0]; Assert.That(pl2WaternetLine.HeadLine, Is.SameAs(waternet.HeadLineList[0])); @@ -479,59 +425,44 @@ WaternetLine pl4WaternetLine = waternet.WaternetLineList[2]; Assert.That(pl4WaternetLine.HeadLine, Is.SameAs(waternet.HeadLineList[2])); - AssertGeometry(new[] - { + var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); + var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); + AssertGeometry([ bottomLeftUpperLayer, bottomRightUpperLayer - }, pl4WaternetLine.Points); + ], pl4WaternetLine.Points); } /// - /// ------------------------------------------------------------- - /// top layer - /// ------------------------------------------------------------- - /// inbetween aquifer layer left | Gap layer - /// |------------------------------- - /// | - /// | Inbetween aquifer layer right - /// -----------------------------| - /// inbetween layer | - /// |------------------------------- + /// ------------------------------------------------------------- Level 0 m + /// top layer + /// ------------------------------------------------------------- Level -10 m + /// | Gap layer + /// in-between aquifer |------------------------------- Level -15 m + /// layer left | + /// | in-between aquifer + /// -----------------------------| layer right Level -20 m + /// in-between layer | + /// |------------------------------- Level -21 m /// - /// ------------------------------------------------------------- - /// bottom aquifer layer + /// ------------------------------------------------------------- Level -25 m + /// bottom aquifer layer + /// ------------------------------------------------------------- Level -30 m /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerRightLayerTopLevelInRangeLeftLayer_ReturnsExpectedWaternet() { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); - - var topLeftUpperLayer = new Point2D(leftCoordinate, 0); - var topRightUpperLayer = new Point2D(rightCoordinate, 0); - var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); - var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); - SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); - - var topRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -10); - var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); + SoilLayer2D soilLayer = CreateRectangularSoilLayer2D(0, -10, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferInBetweenLeft = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, middleXCoordinate, true); + // Add a layer to fill the gap between the right aquifer layer and the upper layer + SoilLayer2D soilLayerGap = CreateRectangularSoilLayer2D(-10, -15, middleXCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferInBetweenRight = CreateRectangularSoilLayer2D(-15, -21, middleXCoordinate, rightCoordinate, true); + // Add continuous in-between layer var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, topRightInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); - soilLayerAquiferInBetweenLeft.IsAquifer = true; - - // Add a layer to fill the gap between the right aquiferlayer and the upper layer - var bottomRightGapLayer = new Point2D(rightCoordinate, -15); - var bottomLeftGapLayer = new Point2D(rightCoordinate / 2, -15); - SoilLayer2D soilLayerGap = CreateSoilLayer2D(topRightInBetweenAquiferLayerLeft, bottomRightUpperLayer, bottomRightGapLayer, bottomLeftGapLayer); - + var bottomRightInBetweenAquiferLayerLeft = new Point2D(middleXCoordinate, -20); + var bottomLeftInBetweenAquiferLayerRight = new Point2D(middleXCoordinate, -21); var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -21); - var bottomLeftInBetweenAquiferLayerRight = new Point2D(rightCoordinate / 2, -21); - SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(bottomLeftGapLayer, bottomRightGapLayer, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); - soilLayerAquiferInBetweenRight.IsAquifer = true; - var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); var soilLayerInBetween = new SoilLayer2D @@ -551,20 +482,15 @@ } } }; + SoilLayer2D soilLayerAquiferBottom = CreateRectangularSoilLayer2D(-25, -30, leftCoordinate, rightCoordinate, true); - var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); - var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); - var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); - SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); - soilLayerAquiferBottom.IsAquifer = true; - var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, - Bottom = -20 + Bottom = -30 } }; soilProfile.Surfaces.Add(soilLayer); @@ -574,40 +500,25 @@ soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + PlLines plLines = CreateAllPlLines(); - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(3)); Point2D[] expectedBottomAquiferCoordinates = { bottomLeftInBetweenLayer, - new Point2D(rightCoordinate / 2, -25), + new(middleXCoordinate, -25), bottomRightInBetweenLayer }; @@ -623,44 +534,36 @@ WaternetLine pl4WaternetLine = waternet.WaternetLineList[2]; Assert.That(pl4WaternetLine.HeadLine, Is.SameAs(waternet.HeadLineList[2])); - AssertGeometry(new[] - { + AssertGeometry([ new GeometryPoint(leftCoordinate, -10), - new GeometryPoint(rightCoordinate / 2, -10), + new GeometryPoint(middleXCoordinate, -10), new GeometryPoint(rightCoordinate, -15) - }, pl4WaternetLine.Points); + ], pl4WaternetLine.Points); } /// - /// ------------------------------------------------------------- - /// top layer - /// |------------------------------- - /// | - /// | Inbetween aquifer layer right - /// -----------------------------| - /// inbetween aquifer layer left | - /// |------------------------------- - /// | - /// | - /// -----------------------------| - /// inbetween layer - /// ------------------------------------------------------------- - /// bottom aquifer layer + /// -------------------------------------------------------------- Level 0 m + /// top layer + /// |------------------------------- Level -5 m + /// | + /// | in-between aquifer + /// ------------------------------| layer right Level -10 m + /// in-between aquifer layer left | + /// ------------------------------------------------------------- Level -20 m + /// in-between layer + /// -------------------------------------------------------------- Level -25 m + /// bottom aquifer layer + /// -------------------------------------------------------------- Level -30 m /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerRightLayerBottomLevelInRangeLeftLayer_ReturnsExpectedWaternet() { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); - var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -5); - var bottomIntermediateUpperUpperLayer = new Point2D(rightCoordinate / 2, -5); - var bottomIntermediateLowerUpperLayer = new Point2D(rightCoordinate / 2, -10); + var bottomIntermediateUpperUpperLayer = new Point2D(middleXCoordinate, -5); + var bottomIntermediateLowerUpperLayer = new Point2D(middleXCoordinate, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); var soilLayer = new SoilLayer2D { @@ -680,25 +583,10 @@ } } }; - - var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); - var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, bottomIntermediateLowerUpperLayer, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); - soilLayerAquiferInBetweenLeft.IsAquifer = true; - - var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -20); - var bottomLeftInBetweenAquiferLayerRight = new Point2D(rightCoordinate / 2, -20); - SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(bottomIntermediateUpperUpperLayer, bottomRightUpperLayer, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); - soilLayerAquiferInBetweenRight.IsAquifer = true; - - var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); - var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); - SoilLayer2D soilLayerInBetween = CreateSoilLayer2D(bottomLeftInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerRight, bottomRightInBetweenLayer, bottomLeftInBetweenLayer); - - var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); - var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); - var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); - SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); + SoilLayer2D soilLayerAquiferInBetweenLeft = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, middleXCoordinate, true); + SoilLayer2D soilLayerAquiferInBetweenRight = CreateRectangularSoilLayer2D(-5, -20, middleXCoordinate, rightCoordinate, true); + SoilLayer2D soilLayerInBetween = CreateRectangularSoilLayer2D(-20, -25, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferBottom = CreateRectangularSoilLayer2D(-25, -30, leftCoordinate, rightCoordinate, true); soilLayerAquiferBottom.IsAquifer = true; var soilProfile = new SoilProfile2D @@ -707,7 +595,7 @@ { Left = leftCoordinate, Right = rightCoordinate, - Bottom = -20 + Bottom = -30 } }; soilProfile.Surfaces.Add(soilLayer); @@ -716,40 +604,27 @@ soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + PlLines plLines = CreateAllPlLines(); - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(3)); + var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); + var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); Point2D[] expectedBottomAquiferCoordinates = { bottomLeftInBetweenLayer, - new Point2D(rightCoordinate / 2, -25), + new Point2D(middleXCoordinate, -25), bottomRightInBetweenLayer }; @@ -774,35 +649,31 @@ } /// - /// ------------------------------------------------------------- - /// top layer + /// ------------------------------------------------------------- Level 0 m + /// top layer /// - /// -----------------------------| - /// inbetween aquifer layer left | - /// |------------------------------- - /// | Inbetween aquifer layer right - /// | ------------------------------ + /// -----------------------------| Level -10 m + /// in-between aquifer | + /// layer left |------------------------------- Level -15 m + /// | in-between aquifer layer right + /// | ------------------------------ Level -17 m /// | /// | - /// -----------------------------| - /// inbetween layer - /// ------------------------------------------------------------- - /// bottom aquifer layer + /// -----------------------------| Level -20 m + /// in-between layer + /// ------------------------------------------------------------- Level -25 m + /// bottom aquifer layer + /// ------------------------------------------------------------- Level -30 m /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerRightLayerEnvelopedByLeftLayer_ReturnsExpectedWaternet() { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); - var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -15); - var bottomIntermediateLowerUpperLayer = new Point2D(rightCoordinate / 2, -15); - var bottomIntermediateUpperUpperLayer = new Point2D(rightCoordinate / 2, -10); + var bottomIntermediateLowerUpperLayer = new Point2D(middleXCoordinate, -15); + var bottomIntermediateUpperUpperLayer = new Point2D(middleXCoordinate, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); var soilLayer = new SoilLayer2D { @@ -822,17 +693,13 @@ } } }; - - var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); + SoilLayer2D soilLayerAquiferInBetweenLeft = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, middleXCoordinate, true); + SoilLayer2D soilLayerAquiferInBetweenRight = CreateRectangularSoilLayer2D(-15, -17, middleXCoordinate, rightCoordinate, true); + var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, bottomIntermediateUpperUpperLayer, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); - soilLayerAquiferInBetweenLeft.IsAquifer = true; - + var bottomRightInBetweenAquiferLayerLeft = new Point2D(middleXCoordinate, -20); + var bottomLeftInBetweenAquiferLayerRight = new Point2D(middleXCoordinate, -17); var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -17); - var bottomLeftInBetweenAquiferLayerRight = new Point2D(rightCoordinate / 2, -17); - SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(bottomIntermediateLowerUpperLayer, bottomRightUpperLayer, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); - soilLayerAquiferInBetweenRight.IsAquifer = true; - var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); var soilLayerInBetween = new SoilLayer2D @@ -853,20 +720,15 @@ } } }; + SoilLayer2D soilLayerAquiferBottom = CreateRectangularSoilLayer2D(-25, -30, leftCoordinate, rightCoordinate, true); - var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); - var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); - var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); - SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); - soilLayerAquiferBottom.IsAquifer = true; - var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, - Bottom = -20 + Bottom = -30 } }; soilProfile.Surfaces.Add(soilLayer); @@ -875,30 +737,15 @@ soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + PlLines plLines = CreateAllPlLines(); - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); @@ -908,7 +755,7 @@ Point2D[] expectedBottomAquiferCoordinates = { bottomLeftInBetweenLayer, - new Point2D(rightCoordinate / 2, -25), + new Point2D(middleXCoordinate, -25), bottomRightInBetweenLayer }; @@ -933,35 +780,30 @@ } /// - /// ------------------------------------------------------------- - /// top layer - /// |------------------------------- - /// | Inbetween aquifer layer right - /// | - /// -----------------------------| - /// inbetween aquifer layer left | - /// | - /// -----------------------------| - /// inbetween layer | - /// |------------------------------- + /// ------------------------------------------------------------- Level 0 m + /// top layer + /// |------------------------------ Level -5 m + /// | in-between aquifer + /// ------------------------------| layer right Level -10 m + /// in-between aquifer layer left | + /// | + /// ------------------------------| Level -20 m + /// in-between layer | + /// |------------------------------ Level -21 m /// - /// ------------------------------------------------------------- - /// bottom aquifer layer + /// ------------------------------------------------------------- Level -25 m + /// bottom aquifer layer + /// ------------------------------------------------------------- Level -30 m /// [Test] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithContinuousInBetweenAquiferLayerRightLayerEnvelopesLeftLayer_ReturnsExpectedWaternet() { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); - var topLeftUpperLayer = new Point2D(leftCoordinate, 0); var topRightUpperLayer = new Point2D(rightCoordinate, 0); var bottomRightUpperLayer = new Point2D(rightCoordinate, -5); - var bottomIntermediateLowerUpperLayer = new Point2D(rightCoordinate / 2, -5); - var bottomIntermediateUpperUpperLayer = new Point2D(rightCoordinate / 2, -10); + var bottomIntermediateLowerUpperLayer = new Point2D(middleXCoordinate, -5); + var bottomIntermediateUpperUpperLayer = new Point2D(middleXCoordinate, -10); var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); var soilLayer = new SoilLayer2D { @@ -981,17 +823,14 @@ } } }; - - var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); + + SoilLayer2D soilLayerAquiferInBetweenLeft = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, middleXCoordinate, true); + SoilLayer2D soilLayerAquiferInBetweenRight = CreateRectangularSoilLayer2D(-5, -21, middleXCoordinate, rightCoordinate, true); + var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, bottomIntermediateUpperUpperLayer, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); - soilLayerAquiferInBetweenLeft.IsAquifer = true; - + var bottomRightInBetweenAquiferLayerLeft = new Point2D(middleXCoordinate, -20); + var bottomLeftInBetweenAquiferLayerRight = new Point2D(middleXCoordinate, -21); var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -21); - var bottomLeftInBetweenAquiferLayerRight = new Point2D(rightCoordinate / 2, -21); - SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(bottomIntermediateLowerUpperLayer, bottomRightUpperLayer, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); - soilLayerAquiferInBetweenRight.IsAquifer = true; - var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); var soilLayerInBetween = new SoilLayer2D @@ -1012,20 +851,15 @@ } } }; + SoilLayer2D soilLayerAquiferBottom = CreateRectangularSoilLayer2D(-25, -30, leftCoordinate, rightCoordinate, true); - var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); - var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); - var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); - SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); - soilLayerAquiferBottom.IsAquifer = true; - var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, - Bottom = -20 + Bottom = -30 } }; soilProfile.Surfaces.Add(soilLayer); @@ -1034,40 +868,25 @@ soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + PlLines plLines = CreateAllPlLines(); - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(3)); Point2D[] expectedBottomAquiferCoordinates = { bottomLeftInBetweenLayer, - new Point2D(rightCoordinate / 2, -25), + new Point2D(middleXCoordinate, -25), bottomRightInBetweenLayer }; @@ -1091,54 +910,37 @@ }, pl4WaternetLine.Points); } + /// + /// --------------------------------------------------- Level 0 m + /// top layer + /// -------------------------|------------------------- Level -10 m + /// in-between layer left | in-between layer right + /// -------------------------|------------------------- Level -20 m + /// in-between layer + /// --------------------------------------------------- Level -25 m + /// bottom aquifer layer + /// --------------------------------------------------- Level -30 m + /// [Test] [TestCase(true, false)] [TestCase(false, true)] public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithDiscontinuousInBetweenAquiferLayer_ReturnsExpectedWaternet( bool isLeftInBetweenLayerAquifer, bool isRightInBetweenLayerAquifer) { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); + SoilLayer2D soilLayer = CreateRectangularSoilLayer2D(0, -10, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferInBetweenLeft = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, middleXCoordinate, isLeftInBetweenLayerAquifer); + SoilLayer2D soilLayerAquiferInBetweenRight = CreateRectangularSoilLayer2D(-10, -20, middleXCoordinate, rightCoordinate, isRightInBetweenLayerAquifer); + SoilLayer2D soilLayerInBetween = CreateRectangularSoilLayer2D(-20, -25, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferBottom = CreateRectangularSoilLayer2D(-25, -30, leftCoordinate, rightCoordinate, true); - var topLeftUpperLayer = new Point2D(leftCoordinate, 0); - var topRightUpperLayer = new Point2D(rightCoordinate, 0); - var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); - var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); - SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); - - var topRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -10); - var bottomRightInBetweenAquiferLayerLeft = new Point2D(rightCoordinate / 2, -20); - var bottomLeftInBetweenAquiferLayerLeft = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferInBetweenLeft = CreateSoilLayer2D(bottomLeftUpperLayer, topRightInBetweenAquiferLayerLeft, bottomRightInBetweenAquiferLayerLeft, bottomLeftInBetweenAquiferLayerLeft); - soilLayerAquiferInBetweenLeft.IsAquifer = isLeftInBetweenLayerAquifer; - - var topRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -10); - var bottomRightInBetweenAquiferLayerRight = new Point2D(rightCoordinate, -20); - var bottomLeftInBetweenAquiferLayerRight = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferInBetweenRight = CreateSoilLayer2D(topRightInBetweenAquiferLayerLeft, topRightInBetweenAquiferLayerRight, bottomRightInBetweenAquiferLayerRight, bottomLeftInBetweenAquiferLayerRight); - soilLayerAquiferInBetweenRight.IsAquifer = isRightInBetweenLayerAquifer; - - var topRightInBetweenLayer = new Point2D(rightCoordinate, -20); - var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); - var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); - SoilLayer2D soilLayerInBetween = CreateSoilLayer2D(bottomLeftInBetweenAquiferLayerLeft, topRightInBetweenLayer, bottomRightInBetweenLayer, bottomLeftInBetweenLayer); - - var topRightBottomAquiferLayer = new Point2D(rightCoordinate, -25); - var bottomRightBottomAquiferLayer = new Point2D(rightCoordinate, -30); - var bottomLeftBottomAquiferLayer = new Point2D(leftCoordinate, -30); - SoilLayer2D soilLayerAquiferBottom = CreateSoilLayer2D(bottomLeftInBetweenLayer, topRightBottomAquiferLayer, bottomRightBottomAquiferLayer, bottomLeftBottomAquiferLayer); - soilLayerAquiferBottom.IsAquifer = true; - var soilProfile = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, - Bottom = -20 + Bottom = -30 } }; soilProfile.Surfaces.Add(soilLayer); @@ -1147,40 +949,27 @@ soilProfile.Surfaces.Add(soilLayerInBetween); soilProfile.Surfaces.Add(soilLayerAquiferBottom); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + PlLines plLines = CreateAllPlLines(); - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.HeadLineList.Count, Is.EqualTo(3)); + Assert.That(waternet.HeadLineList, Has.Count.EqualTo(3)); AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); - Assert.That(waternet.WaternetLineList.Count, Is.EqualTo(2)); + Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(2)); + var bottomRightInBetweenLayer = new Point2D(rightCoordinate, -25); + var bottomLeftInBetweenLayer = new Point2D(leftCoordinate, -25); Point2D[] expectedBottomAquiferCoordinates = { bottomLeftInBetweenLayer, - new Point2D(rightCoordinate / 2, -25), + new Point2D(middleXCoordinate, -25), bottomRightInBetweenLayer }; @@ -1195,34 +984,24 @@ AssertGeometry(expectedBottomAquiferCoordinates, pl3WaternetLine.Points); } + /// + /// --------------------------------------------------- Level 0 m + /// + /// |------------------------- Level -5 m + /// top layer | right aquifer + /// |------------------------- Level -9 m + /// + /// -------------------------|------------------------- Level -10 m + /// left aquifer | + /// -------------------------| Level -20 m + /// [Test] - public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithDiscontinuousBottomAquiferLayer_ReturnsExpectedWaternet() + public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithDiscontinuousBottomAquiferLayer_ReturnsEmptyWaternet() { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); - - var pointOne = new Point2D(leftCoordinate, 0); - var pointTwo = new Point2D(rightCoordinate, 0); - var pointThree = new Point2D(leftCoordinate, -10); - var pointFour = new Point2D(rightCoordinate, -10); - SoilLayer2D soilLayer = CreateSoilLayer2D(pointOne, pointTwo, pointThree, pointFour); - - var pointFive = new Point2D(rightCoordinate / 2, -10); - var pointSix = new Point2D(rightCoordinate / 2, -20); - var pointSeven = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferPartOne = CreateSoilLayer2D(pointThree, pointFive, pointSix, pointSeven); - soilLayerAquiferPartOne.IsAquifer = true; - - var pointEight = new Point2D(rightCoordinate, -5); - var pointNine = new Point2D(rightCoordinate, -9); - var pointTen = new Point2D(rightCoordinate / 2, -5); - var pointEleven = new Point2D(rightCoordinate / 2, -9); - SoilLayer2D soilLayerAquiferPartTwo = CreateSoilLayer2D(pointTen, pointEight, pointNine, pointEleven); - soilLayerAquiferPartTwo.IsAquifer = true; - + SoilLayer2D soilLayer = CreateRectangularSoilLayer2D(0, -10, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferPartOne = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, middleXCoordinate, true); + SoilLayer2D soilLayerAquiferPartTwo = CreateRectangularSoilLayer2D(-5, -9, middleXCoordinate, rightCoordinate, true); var soilProfile = new SoilProfile2D { Geometry = new GeometryData @@ -1236,67 +1015,38 @@ soilProfile.Surfaces.Add(soilLayerAquiferPartOne); soilProfile.Surfaces.Add(soilLayerAquiferPartTwo); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + PlLines plLines = CreateAllPlLines(); - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); Assert.That(waternet.WaternetLineList, Is.Empty); } + /// + /// --------------------------------------------------- Level 0 m + /// top layer + /// -------------------------|------------------------- Level -10 m + /// bottom layer left | bottom layer right + /// -------------------------|------------------------- Level -20 m + /// [Test] [TestCase(true, false)] [TestCase(false, true)] - public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithBottomAquiferLayerNotSpanningWholeInterval_ReturnsExpectedWaternet( + public void ConvertPlLineToWaternet_ValidPLLinesAndSoilProfile2DWithBottomAquiferLayerNotSpanningWholeInterval_ReturnsEmptyWaternet( bool isLeftBottomLayerAquifer, bool isRightBottomLayerAquifer) { // Setup - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - double penetrationLength = random.NextDouble(); + SoilLayer2D soilLayer = CreateRectangularSoilLayer2D(0, -10, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilLayerAquiferPartOne = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, middleXCoordinate, isLeftBottomLayerAquifer); + SoilLayer2D soilLayerAquiferPartTwo = CreateRectangularSoilLayer2D(-10, -20, middleXCoordinate, rightCoordinate, isRightBottomLayerAquifer); - var pointOne = new Point2D(leftCoordinate, 0); - var pointTwo = new Point2D(rightCoordinate, 0); - var pointThree = new Point2D(leftCoordinate, -10); - var pointFour = new Point2D(rightCoordinate, -10); - SoilLayer2D soilLayer = CreateSoilLayer2D(pointOne, pointTwo, pointThree, pointFour); - - var pointFive = new Point2D(rightCoordinate / 2, -10); - var pointSix = new Point2D(rightCoordinate / 2, -20); - var pointSeven = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferPartOne = CreateSoilLayer2D(pointThree, pointFive, pointSix, pointSeven); - soilLayerAquiferPartOne.IsAquifer = isLeftBottomLayerAquifer; - - var pointEight = new Point2D(rightCoordinate, -10); - var pointNine = new Point2D(rightCoordinate, -20); - var pointTen = new Point2D(rightCoordinate / 2, -10); - var pointEleven = new Point2D(rightCoordinate / 2, -20); - SoilLayer2D soilLayerAquiferPartTwo = CreateSoilLayer2D(pointTen, pointEight, pointNine, pointEleven); - soilLayerAquiferPartTwo.IsAquifer = isRightBottomLayerAquifer; - var soilProfile = new SoilProfile2D { Geometry = new GeometryData @@ -1310,29 +1060,13 @@ soilProfile.Surfaces.Add(soilLayerAquiferPartOne); soilProfile.Surfaces.Add(soilLayerAquiferPartTwo); - var plLines = new PlLines(); - PlLine plLine = plLines.Lines[PlLineType.Pl1]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + PlLines plLines = CreateAllPlLines(); - plLine = plLines.Lines[PlLineType.Pl2]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); - - plLine = plLines.Lines[PlLineType.Pl3]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); - - plLine = plLines.Lines[PlLineType.Pl4]; - plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); - plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); - // Call Waternet waternet = PlLinesToWaternetConverter.ConvertPlLineToWaternet(plLines, soilProfile, penetrationLength); // Assert AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - AssertGeometry(plLines.Lines[PlLineType.Pl2].Points, waternet.HeadLineList[0].Points); AssertGeometry(plLines.Lines[PlLineType.Pl3].Points, waternet.HeadLineList[1].Points); AssertGeometry(plLines.Lines[PlLineType.Pl4].Points, waternet.HeadLineList[2].Points); @@ -1372,7 +1106,7 @@ Assert.That(() => PlLinesToWaternetConverter.ConvertPlLineToWaternet(null, soilProfile, 0), Throws.InstanceOf().With.Message.EqualTo("Geen object voor pn-lijnen gedefinieerd")); } - private PlLines CreatePlLinesForTest() + private static PlLines CreatePlLinesForTest() { var plLines = new PlLines(); // pl 1 is phreatic line @@ -1398,122 +1132,146 @@ return plLines; } - private SoilProfile1D CreateSoilProfile1DForTest() + private static SoilProfile1D CreateSoilProfile1DForTest() { - var soilProfile1D = new SoilProfile1D(); - soilProfile1D.BottomLevel = -30.0; + var soilProfile1D = new SoilProfile1D + { + BottomLevel = -30.0 + }; - var layer = new SoilLayer1D(); - layer.Name = "L1a"; - layer.TopLevel = 1.212; - layer.IsAquifer = true; // aquifer at top + var layer = new SoilLayer1D + { + Name = "L1a", + TopLevel = 1.212, + IsAquifer = true // aquifer at top + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L1b"; - layer.TopLevel = 1.212; - layer.IsAquifer = false; + layer = new SoilLayer1D + { + Name = "L1b", + TopLevel = 1.212, + IsAquifer = false + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L2a"; - layer.TopLevel = -2.111; // top of in-between aquifer - layer.IsAquifer = true; + layer = new SoilLayer1D + { + Name = "L2a", + TopLevel = -2.111, // top of in-between aquifer + IsAquifer = true + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L2b"; - layer.TopLevel = -2.151; - layer.IsAquifer = true; + layer = new SoilLayer1D + { + Name = "L2b", + TopLevel = -2.151, + IsAquifer = true + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L3"; - layer.TopLevel = -3.373; - layer.IsAquifer = false; + layer = new SoilLayer1D + { + Name = "L3", + TopLevel = -3.373, + IsAquifer = false + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L4"; - layer.TopLevel = -4.151; - layer.IsAquifer = true; + layer = new SoilLayer1D + { + Name = "L4", + TopLevel = -4.151, + IsAquifer = true + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L5"; - layer.TopLevel = -5.373; - layer.IsAquifer = false; + layer = new SoilLayer1D + { + Name = "L5", + TopLevel = -5.373, + IsAquifer = false + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L6a"; - layer.TopLevel = -6.111; // top of bottom aquifer - layer.IsAquifer = true; + layer = new SoilLayer1D + { + Name = "L6a", + TopLevel = -6.111, // top of bottom aquifer + IsAquifer = true + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L6b"; - layer.TopLevel = -6.151; - layer.IsAquifer = true; + layer = new SoilLayer1D + { + Name = "L6b", + TopLevel = -6.151, + IsAquifer = true + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L7"; - layer.TopLevel = -7.373; - layer.IsAquifer = false; + layer = new SoilLayer1D + { + Name = "L7", + TopLevel = -7.373, + IsAquifer = false + }; soilProfile1D.Layers.Add(layer); return soilProfile1D; } - private SoilProfile1D CreateSoilProfile1DWith1AquiferForTest() + private static SoilProfile1D CreateSoilProfile1DWith1AquiferForTest() { - var soilProfile1D = new SoilProfile1D(); - soilProfile1D.BottomLevel = -30.0; + var soilProfile1D = new SoilProfile1D + { + BottomLevel = -30.0 + }; - var layer = new SoilLayer1D(); - layer = new SoilLayer1D(); - layer.Name = "L1b"; - layer.TopLevel = 1.212; - layer.IsAquifer = false; + var layer = new SoilLayer1D + { + Name = "L1b", + TopLevel = 1.212, + IsAquifer = false + }; soilProfile1D.Layers.Add(layer); - layer = new SoilLayer1D(); - layer.Name = "L6a"; - layer.TopLevel = -6.111; // top of bottom aquifer - layer.IsAquifer = true; + layer = new SoilLayer1D + { + Name = "L6a", + TopLevel = -6.111, // top of bottom aquifer + IsAquifer = true + }; soilProfile1D.Layers.Add(layer); return soilProfile1D; } - private SoilProfile1D CreateSoilProfile1DWithoutAquifersForTest() + private static SoilProfile1D CreateSoilProfile1DWithoutAquifersForTest() { - var soilProfile1D = new SoilProfile1D(); - soilProfile1D.BottomLevel = -30.0; + var soilProfile1D = new SoilProfile1D + { + BottomLevel = -30.0 + }; - var layer = new SoilLayer1D(); - layer = new SoilLayer1D(); - layer.Name = "L1b"; - layer.TopLevel = 1.212; - layer.IsAquifer = false; + var layer = new SoilLayer1D + { + Name = "L1b", + TopLevel = 1.212, + IsAquifer = false + }; soilProfile1D.Layers.Add(layer); return soilProfile1D; } + /// + /// Many test cases are considered using a different soil profile 2D: + /// Within the method below, pictures of these soil profiles 2D are drawn to get a better idea of the test. + /// private static IEnumerable GetSoilProfilesWithContinuousBottomAquiferLayer() { - var random = new Random(21); - double leftCoordinate = random.NextDouble(); - double rightCoordinate = leftCoordinate + 1; - - var topLeftUpperLayer = new Point2D(leftCoordinate, 0); - var topRightUpperLayer = new Point2D(rightCoordinate, 0); - var bottomLeftUpperLayer = new Point2D(leftCoordinate, -10); - var bottomRightUpperLayer = new Point2D(rightCoordinate, -10); - SoilLayer2D soilLayer = CreateSoilLayer2D(topLeftUpperLayer, topRightUpperLayer, bottomRightUpperLayer, bottomLeftUpperLayer); - - var topRightLeftBottomLayer = new Point2D(rightCoordinate / 2, -10); - var bottomRightLeftBottomLayer = new Point2D(rightCoordinate / 2, -20); - var bottomLeftLeftBottomLayer = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquiferPartOne = CreateSoilLayer2D(bottomLeftUpperLayer, topRightLeftBottomLayer, bottomRightLeftBottomLayer, bottomLeftLeftBottomLayer); - soilLayerAquiferPartOne.IsAquifer = true; - - var bottomRightRightBottomLayer = new Point2D(rightCoordinate, -20); - SoilLayer2D soilLayerAquiferPartTwo = CreateSoilLayer2D(topRightLeftBottomLayer, bottomRightUpperLayer, bottomRightRightBottomLayer, bottomRightLeftBottomLayer); - soilLayerAquiferPartTwo.IsAquifer = true; - + // TEST CASE 1: "Right aquifer fully adjoins left aquifer" + // + // ------------------------------------------------------------- Level 0 m + // Upper layer (not aquifer) + // -----------------------------|------------------------------- Level -10 m + // Bottom aquifer layer left | Bottom aquifer layer right + // -----------------------------|------------------------------- Level -20 m + SoilLayer2D soilUpperLayer = CreateRectangularSoilLayer2D(0, -10, leftCoordinate, rightCoordinate, false); + SoilLayer2D soilBottomLayerAquiferPartLeft = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, middleXCoordinate, true); + SoilLayer2D soilBottomLayerAquiferPartRight = CreateRectangularSoilLayer2D(-10, -20, middleXCoordinate, rightCoordinate, true); var soilProfileFullAdjoin = new SoilProfile2D { Geometry = new GeometryData @@ -1523,23 +1281,25 @@ Bottom = -20 } }; - soilProfileFullAdjoin.Surfaces.Add(soilLayer); - soilProfileFullAdjoin.Surfaces.Add(soilLayerAquiferPartOne); - soilProfileFullAdjoin.Surfaces.Add(soilLayerAquiferPartTwo); - + soilProfileFullAdjoin.Surfaces.Add(soilUpperLayer); + soilProfileFullAdjoin.Surfaces.Add(soilBottomLayerAquiferPartLeft); + soilProfileFullAdjoin.Surfaces.Add(soilBottomLayerAquiferPartRight); + yield return new TestCaseData(soilProfileFullAdjoin, new[] { new GeometryPoint(leftCoordinate, -10), - new GeometryPoint(rightCoordinate / 2, -10), + new GeometryPoint(middleXCoordinate, -10), new GeometryPoint(rightCoordinate, -10) }).SetName("Right aquifer fully adjoins left aquifer"); - var topRightBottomLayer = new Point2D(rightCoordinate, -10); - var bottomRightBottomLayer = new Point2D(rightCoordinate, -20); - var bottomLeftBottomLayer = new Point2D(leftCoordinate, -20); - SoilLayer2D soilLayerAquifer = CreateSoilLayer2D(bottomLeftUpperLayer, topRightBottomLayer, bottomRightBottomLayer, bottomLeftBottomLayer); - soilLayerAquifer.IsAquifer = true; - + // TEST CASE 2: "One aquifer bottom layer" + // + // ------------------------------------------------------------- Level 0 m + // Upper layer (not aquifer) + // ------------------------------------------------------------- Level -10 m + // Bottom aquifer layer + // ------------------------------------------------------------- Level -20 m + SoilLayer2D soilBottomLayerAquifer = CreateRectangularSoilLayer2D(-10, -20, leftCoordinate, rightCoordinate, true); var soilProfileOneBottomAquiferLayer = new SoilProfile2D { Geometry = new GeometryData @@ -1549,22 +1309,23 @@ Bottom = -20 } }; - soilProfileOneBottomAquiferLayer.Surfaces.Add(soilLayer); - soilProfileOneBottomAquiferLayer.Surfaces.Add(soilLayerAquifer); + soilProfileOneBottomAquiferLayer.Surfaces.Add(soilUpperLayer); + soilProfileOneBottomAquiferLayer.Surfaces.Add(soilBottomLayerAquifer); yield return new TestCaseData(soilProfileOneBottomAquiferLayer, new[] { new GeometryPoint(leftCoordinate, -10), new GeometryPoint(rightCoordinate, -10) }).SetName("One aquifer bottom layer"); - - var topLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -5); - var topRightRightBottomLayer = new Point2D(rightCoordinate, -5); - bottomRightRightBottomLayer = new Point2D(rightCoordinate, -15); - var bottomLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -15); - soilLayerAquiferPartTwo = CreateSoilLayer2D(topLeftRightBottomLayer, topRightRightBottomLayer, bottomRightRightBottomLayer, bottomLeftRightBottomLayer); - soilLayerAquiferPartTwo.IsAquifer = true; - + + // TEST CASE 3: "Right aquifer only bottom in range" + // + // ------------------------------------------------------------- Level 0 m + // Upper layer (not aquifer) |------------------------------ Level -5 m + // ------------------------------| Right bottom aquifer layer Level -10 m + // Left bottom aquifer layer |------------------------------ Level -15 m + // ------------------------------| Level -20 m + soilBottomLayerAquiferPartRight = CreateRectangularSoilLayer2D(-5, -15, middleXCoordinate, rightCoordinate, true); var soilProfileRightSoilLayerBottomInRange = new SoilProfile2D { Geometry = new GeometryData @@ -1574,75 +1335,89 @@ Bottom = -20 } }; - soilProfileRightSoilLayerBottomInRange.Surfaces.Add(soilLayer); - soilProfileRightSoilLayerBottomInRange.Surfaces.Add(soilLayerAquiferPartOne); - soilProfileRightSoilLayerBottomInRange.Surfaces.Add(soilLayerAquiferPartTwo); + soilProfileRightSoilLayerBottomInRange.Surfaces.Add(soilUpperLayer); + soilProfileRightSoilLayerBottomInRange.Surfaces.Add(soilBottomLayerAquiferPartLeft); + soilProfileRightSoilLayerBottomInRange.Surfaces.Add(soilBottomLayerAquiferPartRight); + soilProfileRightSoilLayerBottomInRange.Geometry.Surfaces.Add(new GeometrySurface()); + yield return new TestCaseData(soilProfileRightSoilLayerBottomInRange, new[] { new GeometryPoint(leftCoordinate, -10), - new GeometryPoint(rightCoordinate / 2, -5), + new GeometryPoint(middleXCoordinate, -5), new GeometryPoint(rightCoordinate, -5) }).SetName("Right aquifer only bottom in range"); + + // TEST CASE 4: "Right aquifer only top in range" + // + // ------------------------------------------------------------- Level 0 m + // Upper layer (not aquifer) | + // ------------------------------|------------------------------ Level -10 m + // Left bottom aquifer layer |------------------------------ Level -15 m + // ------------------------------| Right bottom aquifer layer | Level -20 m + // |------------------------------ Level -25 m + soilBottomLayerAquiferPartRight = CreateRectangularSoilLayer2D(-15, -25, middleXCoordinate, rightCoordinate, true); - topLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -15); - topRightRightBottomLayer = new Point2D(rightCoordinate, -15); - bottomRightRightBottomLayer = new Point2D(rightCoordinate, -25); - bottomLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -25); - soilLayerAquiferPartTwo = CreateSoilLayer2D(topLeftRightBottomLayer, topRightRightBottomLayer, bottomRightRightBottomLayer, bottomLeftRightBottomLayer); - soilLayerAquiferPartTwo.IsAquifer = true; - var soilProfileRightSoilLayerTopInRange = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, - Bottom = -20 + Bottom = -25 } }; - soilProfileRightSoilLayerTopInRange.Surfaces.Add(soilLayer); - soilProfileRightSoilLayerTopInRange.Surfaces.Add(soilLayerAquiferPartOne); - soilProfileRightSoilLayerTopInRange.Surfaces.Add(soilLayerAquiferPartTwo); + soilProfileRightSoilLayerTopInRange.Surfaces.Add(soilUpperLayer); + soilProfileRightSoilLayerTopInRange.Surfaces.Add(soilBottomLayerAquiferPartLeft); + soilProfileRightSoilLayerTopInRange.Surfaces.Add(soilBottomLayerAquiferPartRight); + soilProfileRightSoilLayerTopInRange.Geometry.Surfaces.Add(new GeometrySurface()); + yield return new TestCaseData(soilProfileRightSoilLayerTopInRange, new[] { new GeometryPoint(leftCoordinate, -10), - new GeometryPoint(rightCoordinate / 2, -10), + new GeometryPoint(middleXCoordinate, -10), new GeometryPoint(rightCoordinate, -15) }).SetName("Right aquifer only top in range"); - - topLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -5); - topRightRightBottomLayer = new Point2D(rightCoordinate, -5); - bottomRightRightBottomLayer = new Point2D(rightCoordinate, -25); - bottomLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -25); - soilLayerAquiferPartTwo = CreateSoilLayer2D(topLeftRightBottomLayer, topRightRightBottomLayer, bottomRightRightBottomLayer, bottomLeftRightBottomLayer); - soilLayerAquiferPartTwo.IsAquifer = true; - + + // TEST CASE 5: "Right aquifer fully envelopes left aquifer" + // + // ------------------------------------------------------------- Level 0 m + // Upper layer (not aquifer) |------------------------------ Level -5 m + // ------------------------------| Level -10 m + // Left bottom aquifer layer | Right bottom aquifer layer Level -15 m + // ------------------------------| Level -20 m + // |------------------------------ Level -25 m + soilBottomLayerAquiferPartRight = CreateRectangularSoilLayer2D(-5, -25, middleXCoordinate, rightCoordinate, true); var soilProfileRightAquiferLayerFullyEnvelopsLeft = new SoilProfile2D { Geometry = new GeometryData { Left = leftCoordinate, Right = rightCoordinate, - Bottom = -20 + Bottom = -25 } }; - soilProfileRightAquiferLayerFullyEnvelopsLeft.Surfaces.Add(soilLayer); - soilProfileRightAquiferLayerFullyEnvelopsLeft.Surfaces.Add(soilLayerAquiferPartOne); - soilProfileRightAquiferLayerFullyEnvelopsLeft.Surfaces.Add(soilLayerAquiferPartTwo); + soilProfileRightAquiferLayerFullyEnvelopsLeft.Surfaces.Add(soilUpperLayer); + soilProfileRightAquiferLayerFullyEnvelopsLeft.Surfaces.Add(soilBottomLayerAquiferPartLeft); + soilProfileRightAquiferLayerFullyEnvelopsLeft.Surfaces.Add(soilBottomLayerAquiferPartRight); + soilProfileRightAquiferLayerFullyEnvelopsLeft.Geometry.Surfaces.Add(new GeometrySurface()); + yield return new TestCaseData(soilProfileRightAquiferLayerFullyEnvelopsLeft, new[] { new GeometryPoint(leftCoordinate, -10), - new GeometryPoint(rightCoordinate / 2, -5), + new GeometryPoint(middleXCoordinate, -5), new GeometryPoint(rightCoordinate, -5) }).SetName("Right aquifer fully envelopes left aquifer"); - - topLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -15); - topRightRightBottomLayer = new Point2D(rightCoordinate, -15); - bottomRightRightBottomLayer = new Point2D(rightCoordinate, -17); - bottomLeftRightBottomLayer = new Point2D(rightCoordinate / 2, -17); - soilLayerAquiferPartTwo = CreateSoilLayer2D(topLeftRightBottomLayer, topRightRightBottomLayer, bottomRightRightBottomLayer, bottomLeftRightBottomLayer); - soilLayerAquiferPartTwo.IsAquifer = true; - + + // TEST CASE 6: "Right aquifer fully enveloped by left aquifer" + // + // ------------------------------------------------------------- Level 0 m + // Upper layer (not aquifer) | + // ------------------------------|------------------------------ Level -10 m + // Left bottom aquifer layer |------------------------------ Level -15 m + // | Right bottom aquifer layer | + // |------------------------------ Level -17 m + // ------------------------------| Level -20 m + soilBottomLayerAquiferPartRight = CreateRectangularSoilLayer2D(-15, -17, middleXCoordinate, rightCoordinate, true); var soilProfileRightAquiferLayerFullyEnvelopedByLeft = new SoilProfile2D { Geometry = new GeometryData @@ -1652,27 +1427,21 @@ Bottom = -20 } }; - soilProfileRightAquiferLayerFullyEnvelopedByLeft.Surfaces.Add(soilLayer); - soilProfileRightAquiferLayerFullyEnvelopedByLeft.Surfaces.Add(soilLayerAquiferPartOne); - soilProfileRightAquiferLayerFullyEnvelopedByLeft.Surfaces.Add(soilLayerAquiferPartTwo); + soilProfileRightAquiferLayerFullyEnvelopedByLeft.Surfaces.Add(soilUpperLayer); + soilProfileRightAquiferLayerFullyEnvelopedByLeft.Surfaces.Add(soilBottomLayerAquiferPartLeft); + soilProfileRightAquiferLayerFullyEnvelopedByLeft.Surfaces.Add(soilBottomLayerAquiferPartRight); + soilProfileRightAquiferLayerFullyEnvelopedByLeft.Geometry.Surfaces.Add(new GeometrySurface()); + yield return new TestCaseData(soilProfileRightAquiferLayerFullyEnvelopedByLeft, new[] { new GeometryPoint(leftCoordinate, -10), - new GeometryPoint(rightCoordinate / 2, -10), + new GeometryPoint(middleXCoordinate, -10), new GeometryPoint(rightCoordinate, -15) }).SetName("Right aquifer fully enveloped by left aquifer"); } - /// - /// Creates a rectangular . - /// - /// - /// - /// - /// - /// A rectangular . - private static SoilLayer2D CreateSoilLayer2D(Point2D topLeftCoordinate, - Point2D topRightCoordinate, Point2D bottomRightCoordinate, Point2D bottomLeftCoordinate) + private static SoilLayer2D CreateSoilLayer2D(Point2D topLeftCoordinate, Point2D topRightCoordinate, + Point2D bottomRightCoordinate, Point2D bottomLeftCoordinate, bool isAquifer) { return new SoilLayer2D { @@ -1688,10 +1457,30 @@ new GeometryCurve(bottomLeftCoordinate, topLeftCoordinate) } } - } + }, + IsAquifer = isAquifer }; } + /// + /// Creates a rectangular . + /// + /// + /// + /// + /// + /// + /// A rectangular . + private static SoilLayer2D CreateRectangularSoilLayer2D(double topCoord, double bottomCoord, double leftCoord, double rightCoord, bool isAquifer) + { + var topLeftPoint = new Point2D(leftCoord, topCoord); + var topRightPoint= new Point2D(rightCoord, topCoord); + var bottomRightPoint = new Point2D(rightCoord, bottomCoord); + var bottomLeftPoint = new Point2D(leftCoord, bottomCoord); + + return CreateSoilLayer2D(topLeftPoint, topRightPoint, bottomRightPoint, bottomLeftPoint, isAquifer); + } + private static void AssertGeometry(IEnumerable expectedPoints, IEnumerable actualPoints) { GeometryPoint[] convertedPoints = expectedPoints.Select(p => new GeometryPoint(p.X, p.Z)).ToArray(); @@ -1707,8 +1496,36 @@ { GeometryPoint expectedPoint = expectedPoints.ElementAt(i); GeometryPoint actualPoint = actualPoints.ElementAt(i); - Assert.That(actualPoint.X, Is.EqualTo(expectedPoint.X)); - Assert.That(actualPoint.Z, Is.EqualTo(expectedPoint.Z)); + Assert.Multiple(() => + { + Assert.That(actualPoint.X, Is.EqualTo(expectedPoint.X)); + Assert.That(actualPoint.Z, Is.EqualTo(expectedPoint.Z)); + }); } } + + private static PlLines CreateAllPlLines() + { + var plLines = new PlLines(); + PlLine plLine = plLines.Lines[PlLineType.Pl1]; + plLine.Name = "Phreatic line"; + plLine.Points.Add(new PlLinePoint(leftCoordinate, -5)); + plLine.Points.Add(new PlLinePoint(rightCoordinate, -5)); + + plLine = plLines.Lines[PlLineType.Pl2]; + plLine.Name = "PL 2"; + plLine.Points.Add(new PlLinePoint(leftCoordinate, -6)); + plLine.Points.Add(new PlLinePoint(rightCoordinate, -6)); + + plLine = plLines.Lines[PlLineType.Pl3]; + plLine.Name = "PL 3"; + plLine.Points.Add(new PlLinePoint(leftCoordinate, -7)); + plLine.Points.Add(new PlLinePoint(rightCoordinate, -7)); + + plLine = plLines.Lines[PlLineType.Pl4]; + plLine.Name = "PL 4"; + plLine.Points.Add(new PlLinePoint(leftCoordinate, -8)); + plLine.Points.Add(new PlLinePoint(rightCoordinate, -8)); + return plLines; + } } \ No newline at end of file