Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/Input/SoilProfileCreator.cs
===================================================================
diff -u -rd3d8ce69baae082c576e3e3a3fedff5b5b57a1e9 -r44219345a24b6fe20ec684d2a0fc61a84abee67f
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/Input/SoilProfileCreator.cs (.../SoilProfileCreator.cs) (revision d3d8ce69baae082c576e3e3a3fedff5b5b57a1e9)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.KernelWrapper/Creators/Input/SoilProfileCreator.cs (.../SoilProfileCreator.cs) (revision 44219345a24b6fe20ec684d2a0fc61a84abee67f)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using Deltares.WTIStability.Data.Geo;
using Deltares.WTIStability.Data.Standard;
@@ -66,7 +67,7 @@
IsAquifer = layerWithSoil.Key.IsAquifer,
Soil = layerWithSoil.Value,
GeometrySurface = CreateGeometrySurface(layerWithSoil.Key),
- WaterpressureInterpolationModel = WaterpressureInterpolationModel.Automatic
+ WaterpressureInterpolationModel = ConvertWaterPressureInterpolationModel(layerWithSoil.Key.WaterPressureInterpolationModel)
});
}
@@ -163,5 +164,34 @@
return geometryData;
}
+
+ ///
+ /// Converts a into a .
+ ///
+ /// The to convert.
+ /// A based on .
+ /// Thrown when
+ /// is an invalid value.
+ /// Thrown when
+ /// is a valid value but unsupported.
+ private static WaterpressureInterpolationModel ConvertWaterPressureInterpolationModel(UpliftVanWaterPressureInterpolationModel waterPressureInterpolationModel)
+ {
+ if (!Enum.IsDefined(typeof(UpliftVanWaterPressureInterpolationModel), waterPressureInterpolationModel))
+ {
+ throw new InvalidEnumArgumentException(nameof(waterPressureInterpolationModel),
+ (int) waterPressureInterpolationModel,
+ typeof(UpliftVanWaterPressureInterpolationModel));
+ }
+
+ switch (waterPressureInterpolationModel)
+ {
+ case UpliftVanWaterPressureInterpolationModel.Automatic:
+ return WaterpressureInterpolationModel.Automatic;
+ case UpliftVanWaterPressureInterpolationModel.Hydrostatic:
+ return WaterpressureInterpolationModel.Hydrostatic;
+ default:
+ throw new NotSupportedException();
+ }
+ }
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/Input/SoilProfileCreatorTest.cs
===================================================================
diff -u -re3dfe9525dcd4383d8c98a3c9f24626dd5f8324b -r44219345a24b6fe20ec684d2a0fc61a84abee67f
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/Input/SoilProfileCreatorTest.cs (.../SoilProfileCreatorTest.cs) (revision e3dfe9525dcd4383d8c98a3c9f24626dd5f8324b)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.KernelWrapper.Test/Creators/Input/SoilProfileCreatorTest.cs (.../SoilProfileCreatorTest.cs) (revision 44219345a24b6fe20ec684d2a0fc61a84abee67f)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using Core.Common.Base.Data;
using Core.Common.TestUtil;
@@ -63,9 +64,43 @@
}
[Test]
- public void Create_WithAllData_ReturnSoilProfile2D()
+ public void Create_InvalidWaterPressureInterpolationModel_ThrowInvalidEnumArgumentException()
{
// Setup
+ var layer = new UpliftVanSoilLayer(
+ new[]
+ {
+ new Point2D(0, 0),
+ new Point2D(1, 1)
+ }, Enumerable.Empty(),
+ new UpliftVanSoilLayer.ConstructionProperties
+ {
+ WaterPressureInterpolationModel = (UpliftVanWaterPressureInterpolationModel) 99
+ });
+
+ var soilProfile = new UpliftVanSoilProfile(new[]
+ {
+ layer
+ }, Enumerable.Empty());
+
+ // Call
+ TestDelegate test = () => SoilProfileCreator.Create(soilProfile, new Dictionary
+ {
+ {
+ layer, new Soil()
+ }
+ });
+
+ // Assert
+ string message = $"The value of argument 'waterPressureInterpolationModel' ({99}) is invalid for Enum type '{typeof(UpliftVanWaterPressureInterpolationModel).Name}'.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message);
+ }
+
+ [TestCase(UpliftVanWaterPressureInterpolationModel.Automatic, WaterpressureInterpolationModel.Automatic)]
+ [TestCase(UpliftVanWaterPressureInterpolationModel.Hydrostatic, WaterpressureInterpolationModel.Hydrostatic)]
+ public void Create_WithAllData_ReturnSoilProfile2D(UpliftVanWaterPressureInterpolationModel upliftVanWaterPressureInterpolationModel, WaterpressureInterpolationModel waterpressureInterpolationModel)
+ {
+ // Setup
var random = new Random(11);
double preconsolidationStressXCoordinate = random.Next();
double preconsolidationStressZCoordinate = random.Next();
@@ -97,7 +132,8 @@
outerRing, holes,
new UpliftVanSoilLayer.ConstructionProperties
{
- IsAquifer = true
+ IsAquifer = true,
+ WaterPressureInterpolationModel = upliftVanWaterPressureInterpolationModel
});
var soil = new Soil();
@@ -132,7 +168,7 @@
Assert.AreSame(soil, surface.Soil);
Assert.IsFalse(string.IsNullOrEmpty(surface.Name)); // Unused property
Assert.AreEqual(layer.IsAquifer, surface.IsAquifer);
- Assert.AreEqual(WaterpressureInterpolationModel.Automatic, surface.WaterpressureInterpolationModel);
+ Assert.AreEqual(waterpressureInterpolationModel, surface.WaterpressureInterpolationModel);
var point1 = new WTIStabilityPoint2D(0, 0);
var point2 = new WTIStabilityPoint2D(10, 10);