Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs =================================================================== diff -u -r5013 -r5015 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 5013) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverterTests.cs (.../PlLinesToWaternetConverterTests.cs) (revision 5015) @@ -260,7 +260,8 @@ } [Test] - public void Given1DSoilProfileWithoutAquifer_WhenCreatingWaternetBasedOnPlLinesAnd1DSoilProfile_ThenReturnsNoWaternetLinesForPl234() + [SetUICulture("en-EN")] + public void Given1DSoilProfileWithoutAquifer_WhenCreatingWaternetBasedOnPlLinesAnd1DSoilProfile_ThenReturnsException() { PlLines plLines = CreatePlLinesForTest(); SoilProfile1D soilProfile1D = CreateSoilProfile1DForTest(out GeometryPointString surfaceLine); @@ -290,15 +291,11 @@ Assert.That(waternet.WaternetLineList[2].Points[0].Z, Is.EqualTo(-6.111).Within(precision3Decimals)); }); - // check that no waternet lines are added for pl2, pl3 and pl4 when no aquifer present + // check that an exception is raised when no aquifer present soilProfile1D = CreateSoilProfile1DWithoutAquifersForTest(); - waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile1D, surfaceLine, penetrateLength, 0, 0, IntrusionVerticalWaterPressureType.SemiTimeDependent); - Assert.Multiple(() => - { - Assert.That(waternet.HeadLineList, Has.Count.EqualTo(1)); - Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(1)); - Assert.That(waternet.WaternetLineList[0].HeadLine.Name, Is.SameAs(waternet.PhreaticLine.Name)); - }); + Assert.That(() => PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile1D, surfaceLine, penetrationLength, 0, 0, IntrusionVerticalWaterPressureType.Standard), + Throws.InstanceOf().With.Message.EqualTo("The deepest layer is not an aquifer in soilprofile 'DefaultNameSoilProfile1D'.")); + } /// X_a X_b @@ -1108,7 +1105,8 @@ /// -------------------------| Level -20 m /// [Test] - public void CreateWaternetBasedOnPlLines_ValidPLLinesAndSoilProfile2DWithDiscontinuousBottomAquiferLayer_ReturnsOneWaternetLineAssignedToPl1() + [SetUICulture("nl-NL")] + public void CreateWaternetBasedOnPlLines_ValidPLLinesAndSoilProfile2DWithDiscontinuousBottomAquiferLayer_ReturnsException() { // Setup SoilLayer2D soilLayer = CreateRectangularSoilLayer2D(0, -10, leftCoordinate, rightCoordinate, false); @@ -1121,22 +1119,19 @@ Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 - } + }, + Name = "SoilProfileTest" }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferPartOne); soilProfile.Surfaces.Add(soilLayerAquiferPartTwo); PlLines plLines = CreateAllPlLines(); - // Call - Waternet waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile, penetrationLength, IntrusionVerticalWaterPressureType.Standard); - - // Assert - Assert.That(waternet.HeadLineList, Has.Count.EqualTo(0)); - AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(1)); - Assert.That(waternet.WaternetLineList[0].HeadLine.Name, Is.SameAs(waternet.PhreaticLine.Name)); + // Call and assert + Assert.That(() => PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile, penetrationLength, IntrusionVerticalWaterPressureType.Standard), + Throws.InstanceOf().With.Message.EqualTo("De onderste laag is geen watervoerende laag in grondprofiel 'SoilProfileTest'.")); + } /// @@ -1147,9 +1142,10 @@ /// -------------------------|------------------------- Level -20 m /// [Test] + [SetUICulture("nl-NL")] [TestCase(true, false)] [TestCase(false, true)] - public void CreateWaternetBasedOnPlLines_ValidPLLinesAndSoilProfile2DWithBottomAquiferLayerNotSpanningWholeInterval_ReturnsOneWaternetLineAssignedToPl1( + public void CreateWaternetBasedOnPlLines_ValidPLLinesAndSoilProfile2DWithBottomAquiferLayerNotSpanningWholeInterval_ReturnsException( bool isLeftBottomLayerAquifer, bool isRightBottomLayerAquifer) { // Setup @@ -1164,25 +1160,19 @@ Left = leftCoordinate, Right = rightCoordinate, Bottom = -20 - } + }, + Name = "SoilProfileTest" }; soilProfile.Surfaces.Add(soilLayer); soilProfile.Surfaces.Add(soilLayerAquiferPartOne); soilProfile.Surfaces.Add(soilLayerAquiferPartTwo); PlLines plLines = CreateAllPlLines(); - // Call - Waternet waternet = PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile, penetrationLength, IntrusionVerticalWaterPressureType.Standard); - - // Assert - AssertGeometry(plLines.Lines[PlLineType.Pl1].Points, waternet.PhreaticLine.Points); - Assert.Multiple(() => - { - Assert.That(waternet.HeadLineList, Has.Count.EqualTo(0)); - Assert.That(waternet.WaternetLineList, Has.Count.EqualTo(1)); - }); - Assert.That(waternet.WaternetLineList[0].HeadLine.Name, Is.SameAs(waternet.PhreaticLine.Name)); + // Call and assert + Assert.That(() => PlLinesToWaternetConverter.CreateWaternetBasedOnPlLines(plLines, soilProfile, penetrationLength, IntrusionVerticalWaterPressureType.Standard), + Throws.InstanceOf().With.Message.EqualTo("De onderste laag is geen watervoerende laag in grondprofiel 'SoilProfileTest'.")); + } [Test] Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs =================================================================== diff -u -r4988 -r5015 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs (.../PlLinesToWaternetConverter.cs) (revision 4988) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/PlLinesToWaternetConverter.cs (.../PlLinesToWaternetConverter.cs) (revision 5015) @@ -63,13 +63,21 @@ /// Left side of the 2D profile. /// Right side of the 2D profile. /// The type of distribution of the vertical water pressures. - /// + /// A . + /// Thrown when , or + /// is null. public static Waternet CreateWaternetBasedOnPlLines(PlLines plLines, SoilProfile1D soilProfile1D, GeometryPointString surfaceLine, double penetrationLength, double xLeft, double xRight, IntrusionVerticalWaterPressureType? pressureType) { ThrowWhenPlLinesIsNull(plLines); ThrowWhenSoilProfileIsNull(soilProfile1D); ThrowWhenSurfaceLineIsNull(surfaceLine); + + if (soilProfile1D.BottomAquiferLayer == null) + { + throw new Exception(string.Format(Resources.NoBottomAquiferLayer, soilProfile1D.Name)); + } + var waternet = new Waternet(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; @@ -86,7 +94,7 @@ plLine = plLines.Lines[PlLineType.Pl2]; headLine = CreateLine(plLine, headLine2Name); - if (headLine != null && !IsBelowSoilProfile(soilProfile1D, plLine) && soilProfile1D.BottomAquiferLayer != null && + if (headLine != null && !IsBelowSoilProfile(soilProfile1D, plLine) && pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent && penetrationLength > 0) { waternet.HeadLineList.Add(headLine); @@ -99,7 +107,7 @@ plLine = plLines.Lines[PlLineType.Pl3]; headLine = CreateLine(plLine, headLine3Name); - if (headLine != null && !IsBelowSoilProfile(soilProfile1D, plLine) && soilProfile1D.BottomAquiferLayer != null && + if (headLine != null && !IsBelowSoilProfile(soilProfile1D, plLine) && pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) { waternet.HeadLineList.Add(headLine); @@ -133,6 +141,10 @@ ThrowWhenSoilProfileIsNull(soilProfile); Point2D[] bottomAquiferCoordinates = DetermineLayerBoundaryPoints(LayerType.BottomAquifer, soilProfile).ToArray(); + if (!bottomAquiferCoordinates.Any()) + { + throw new Exception(string.Format(Resources.NoBottomAquiferLayer, soilProfile.Name)); + } var waternet = new Waternet(); PlLine plLine = plLines.Lines[PlLineType.Pl1]; @@ -147,26 +159,26 @@ } plLine = plLines.Lines[PlLineType.Pl2]; - if (plLine != null && bottomAquiferCoordinates.Any() && pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent && penetrationLength > 0) - { - var headLine = CreateLine(plLine, headLine2Name); - waternet.HeadLineList.Add(headLine); - WaternetLine waternetLine = CreateWaternetLine(bottomAquiferCoordinates, penetrationLength); - waternetLine.Name = waternetLine2Name; - waternetLine.HeadLine = headLine; - waternet.WaternetLineList.Add(waternetLine); + if (plLine != null && pressureType == IntrusionVerticalWaterPressureType.SemiTimeDependent && penetrationLength > 0) + { + var headLine = CreateLine(plLine, headLine2Name); + waternet.HeadLineList.Add(headLine); + WaternetLine waternetLine = CreateWaternetLine(bottomAquiferCoordinates, penetrationLength); + waternetLine.Name = waternetLine2Name; + waternetLine.HeadLine = headLine; + waternet.WaternetLineList.Add(waternetLine); } plLine = plLines.Lines[PlLineType.Pl3]; - if (plLine != null && bottomAquiferCoordinates.Any() && pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) - { - var headLine = CreateLine(plLine, headLine3Name); - waternet.HeadLineList.Add(headLine); + if (plLine != null && pressureType != IntrusionVerticalWaterPressureType.FullHydroStatic) + { + var headLine = CreateLine(plLine, headLine3Name); + waternet.HeadLineList.Add(headLine); - WaternetLine waternetLine = CreateWaternetLine(bottomAquiferCoordinates); - waternetLine.HeadLine = headLine; - waternetLine.Name = waternetLine3Name; - waternet.WaternetLineList.Add(waternetLine); + WaternetLine waternetLine = CreateWaternetLine(bottomAquiferCoordinates); + waternetLine.HeadLine = headLine; + waternetLine.Name = waternetLine3Name; + waternet.WaternetLineList.Add(waternetLine); } CreateWaternetLinesForInBetweenAquifers(waternet, soilProfile, plLines.Lines[PlLineType.Pl4], pressureType); @@ -204,7 +216,7 @@ { return; } - + if (soilProfile1D.GetInBetweenAquiferClusters == null || pressureType == IntrusionVerticalWaterPressureType.FullHydroStatic) { return; @@ -678,7 +690,7 @@ throw new NoNullAllowedException(Resources.PlLinesToWaternetConverter_NoPlLinesDefined); } } - + /// /// Throws when the surface line object is not assigned. ///