Index: DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs
===================================================================
diff -u -r7057 -r7071
--- DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 7057)
+++ DamEngine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile2DSurfaceLineHelperTests.cs (.../SoilProfile2DSurfaceLineHelperTests.cs) (revision 7071)
@@ -521,15 +521,15 @@
///
/// This test reflects the problem found in MWDAM-3279 when creating a new soil profile with a surface line very close to the
- /// original surface line from the soil profile.
+ /// original surface line from the soil profile. If both surface lines are too close, the original surface line is used.
///
[Test]
- [TestCase(1, 2, 2)]
- [TestCase(0.1, 0.2, 2)]
- [TestCase(0.01, 0.02, 2)]
- [TestCase(0.007, 0.008, 1)]
- [TestCase(0.001, 0.002, 1)]
- public void GivenSoilProfile2DWithSteepOrShallowSlopeInTwoPartsAndSurfaceLineCrossingTheSlope_WhenCombiningWithSurfaceLine_ThenExpectedNewSoilProfile2DCreated(double widthLowestSlope, double widthHighestSlope,int expectedLayerCount)
+ [TestCase(1, 2, false)]
+ [TestCase(0.1, 0.2, false)]
+ [TestCase(0.01, 0.02, false)]
+ [TestCase(0.007, 0.008, true)]
+ [TestCase(0.001, 0.002, true)]
+ public void GivenSoilProfile2DWithSteepOrShallowSlopeInTwoPartsAndSurfaceLineCrossingTheSlope_WhenCombiningWithSurfaceLine_ThenExpectedNewSoilProfile2DCreated(double widthLowestSlope, double widthHighestSlope, bool isNewSurfaceLineTooCloseToOriginalSurfaceLine)
{
// Given
SoilProfile2D soilProfile2D = FactoryForSoilProfiles.CreateSoilProfile2DWithSteepOrShallowSlopeInTwoParts(widthLowestSlope, widthHighestSlope);
@@ -547,27 +547,26 @@
// Then
Assert.That(newSoilProfile2D, Is.Not.Null);
- Assert.That(newSoilProfile2D.Surfaces, Has.Count.EqualTo(expectedLayerCount));
- var lineNewSurfaceLine = new Line(surfaceLine.Geometry.Points[1], surfaceLine.Geometry.Points[2]);
- var lineSurfaceSeparation = new Line(new Point2D(widthLowestSlope, -4.15), new Point2D(10, -4.15));
- var intersectionPoint = new Point2D();
- Assert.That(LineHelper.DetermineStrictIntersectionPoint(lineNewSurfaceLine, lineSurfaceSeparation, ref intersectionPoint), Is.True);
+ Assert.That(newSoilProfile2D.Surfaces, Has.Count.EqualTo(2));
- if (expectedLayerCount == 2)
+ var intersectionPoint = new Point2D();
+ if (isNewSurfaceLineTooCloseToOriginalSurfaceLine)
{
- var soil1 = new Soil("Surface 1");
- var soil2 = new Soil("Surface 2");
- SoilLayer2D expectedSurface1 = FactoryForSoilProfiles.CreatePolygonSoilLayer2D([intersectionPoint, new Point2D(widthLowestSlope + widthHighestSlope, -4.05), new Point2D(10, -4.05), new Point2D(10, -4.15)], soil1, null);
- SoilLayer2D expectedSurface2 = FactoryForSoilProfiles.CreatePolygonSoilLayer2D([new Point2D(-10, -4.25), new Point2D(0, -4.25), intersectionPoint, new Point2D(10, -4.15), new Point2D(10, -5), new Point2D(-10, -5)], soil2, null);
- CheckSoilProfileContainsSoilLayer(newSoilProfile2D, expectedSurface1);
- CheckSoilProfileContainsSoilLayer(newSoilProfile2D, expectedSurface2);
+ intersectionPoint = originalSurfaceLine.Points[2];
}
-
- if (expectedLayerCount == 1)
+ else
{
- // When the surface line is too close to the original surface line, the top surface is not generated.
- CheckSoilProfileContainsSoilLayer(newSoilProfile2D, soilProfile2D.Surfaces[1]);
+ var lineNewSurfaceLine = new Line(surfaceLine.Geometry.Points[1], surfaceLine.Geometry.Points[2]);
+ var lineSurfaceSeparation = new Line(new Point2D(widthLowestSlope, -4.15), new Point2D(10, -4.15));
+ Assert.That(LineHelper.DetermineStrictIntersectionPoint(lineNewSurfaceLine, lineSurfaceSeparation, ref intersectionPoint), Is.True);
}
+
+ var soil1 = new Soil("Surface 1");
+ var soil2 = new Soil("Surface 2");
+ SoilLayer2D expectedSurface1 = FactoryForSoilProfiles.CreatePolygonSoilLayer2D([intersectionPoint, new Point2D(widthLowestSlope + widthHighestSlope, -4.05), new Point2D(10, -4.05), new Point2D(10, -4.15)], soil1, null);
+ SoilLayer2D expectedSurface2 = FactoryForSoilProfiles.CreatePolygonSoilLayer2D([new Point2D(-10, -4.25), new Point2D(0, -4.25), intersectionPoint, new Point2D(10, -4.15), new Point2D(10, -5), new Point2D(-10, -5)], soil2, null);
+ CheckSoilProfileContainsSoilLayer(newSoilProfile2D, expectedSurface1);
+ CheckSoilProfileContainsSoilLayer(newSoilProfile2D, expectedSurface2);
}
///