Index: test/Plugins/Wti/Wti.IO.Test/Builders/SoilLayer2DTest.cs =================================================================== diff -u -r2423a70958e7fecfc92afa462c34194cc695a81e -r4f83a029b2b4967a5f9e91dcd2ce06ecbbd09ddb --- test/Plugins/Wti/Wti.IO.Test/Builders/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision 2423a70958e7fecfc92afa462c34194cc695a81e) +++ test/Plugins/Wti/Wti.IO.Test/Builders/SoilLayer2DTest.cs (.../SoilLayer2DTest.cs) (revision 4f83a029b2b4967a5f9e91dcd2ce06ecbbd09ddb) @@ -309,27 +309,109 @@ var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, "6", "........", + "...12...", "........", + "...43...", + "........", + "........")); + + var innerLoop2 = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "6", + "........", + "........", "...12...", "........", "........", "...43...")); - var innerLoop2 = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + var layer = new SoilLayer2D + { + OuterLoop = outerLoop, + InnerLoops = + { + innerLoop, + innerLoop2 + } + }; + + // Call + double bottom; + var result = layer.AsPipingSoilLayers(3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(1, result.Length); + Assert.AreEqual(4.0, bottom); + CollectionAssert.AreEquivalent(new[] { 5.0 }, result.Select(rl => rl.Top)); + } + + [Test] + public void AsPipingSoilLayers_OuterLoopInnerLoopOnBorderBottom_ReturnsTwoLayers() + { + // Setup + var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, "6", + "..1..2..", "........", + "........", + "........", + ".4....3.", + "........")); + + var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "6", + "........", + "........", "...12...", "........", "...43...", + "........")); + + var layer = new SoilLayer2D + { + OuterLoop = outerLoop, + InnerLoops = + { + innerLoop + } + }; + + // Call + double bottom; + var result = layer.AsPipingSoilLayers(3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(2, result.Length); + Assert.AreEqual(3.0, bottom); + CollectionAssert.AreEquivalent(new[] { 5.0, 1.0 }, result.Select(rl => rl.Top)); + } + + [Test] + public void AsPipingSoilLayers_OuterLoopInnerLoopOverlapTop_ReturnsOneLayer() + { + // Setup + var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "6", "........", + "..1..2..", + "........", + "........", + ".4....3.", "........")); + var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "6", + "...43...", + "........", + "...12...", + "........", + "........", + "........")); + var layer = new SoilLayer2D { OuterLoop = outerLoop, InnerLoops = { - innerLoop2, innerLoop } }; @@ -340,11 +422,52 @@ // Assert Assert.AreEqual(1, result.Length); - Assert.AreEqual(4.0, bottom); - CollectionAssert.AreEquivalent(new[] { 5.0 }, result.Select(rl => rl.Top)); + Assert.AreEqual(1.0, bottom); + CollectionAssert.AreEquivalent(new[] { 3.0 }, result.Select(rl => rl.Top)); } [Test] + public void AsPipingSoilLayers_OuterLoopInnerLoopOnBorderTop_ReturnsOneLayer() + { + // Setup + var outerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "6", + "..1..2..", + "........", + "........", + "........", + ".4....3.", + "........")); + + var innerLoop = PointCollectionHelper.CreateFromString(String.Join(Environment.NewLine, + "6", + "...43...", + "........", + "...12...", + "........", + "........", + "........")); + + var layer = new SoilLayer2D + { + OuterLoop = outerLoop, + InnerLoops = + { + innerLoop + } + }; + + // Call + double bottom; + var result = layer.AsPipingSoilLayers(3.5, out bottom).ToArray(); + + // Assert + Assert.AreEqual(1, result.Length); + Assert.AreEqual(1.0, bottom); + CollectionAssert.AreEquivalent(new[] { 3.0 }, result.Select(rl => rl.Top)); + } + + [Test] public void AsPipingSoilLayers_OuterLoopVerticalAtX_ThrowsException() { // Setup