Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -ra557c00f0de18bc9636711c7dbb0c3ab428c21b6 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a557c00f0de18bc9636711c7dbb0c3ab428c21b6)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -1545,14 +1545,14 @@
}
///
- /// Looks up a localized string similar to BEGIN TRANSACTION;
- ///CREATE TABLE "TimeIntegrationSettings" (
- /// "LocationID" INTEGER NOT NULL,
- /// "CalculationTypeID" INTEGER NOT NULL,
- /// "TimeIntegrationSchemeID" INTEGER NOT NULL,
- /// CONSTRAINT timeintegrationsettings_pk PRIMARY KEY ("LocationID", "CalculationTypeID"),
- /// CONSTRAINT calculationtypes_timeintegrationsettings_fk FOREIGN KEY ("CalculationTypeID") REFERENCES CalculationTypes ("CalculationTypeID") ON DELETE NO ACTION ON UPDATE NO ACTION
- ///);
+ /// Looks up a localized string similar to BEGIN TRANSACTION;
+ ///CREATE TABLE "TimeIntegrationSettings" (
+ /// "LocationID" INTEGER NOT NULL,
+ /// "CalculationTypeID" INTEGER NOT NULL,
+ /// "TimeIntegrationSchemeID" INTEGER NOT NULL,
+ /// CONSTRAINT timeintegrationsettings_pk PRIMARY KEY ("LocationID", "CalculationTypeID"),
+ /// CONSTRAINT calculationtypes_timeintegrationsettings_fk FOREIGN KEY ("CalculationTypeID") REFERENCES CalculationTypes ("CalculationTypeID") ON DELETE NO ACTION ON UPDATE NO ACTION
+ ///);
///CREATE TABLE "Numeri [rest of string was truncated]";.
///
public static string settings_schema {
@@ -1640,15 +1640,6 @@
}
///
- /// Looks up a localized string similar to Parameter '{0}' is niet verschoven lognormaal verdeeld..
- ///
- public static string SoilLayer_Stochastic_parameter_0_has_no_shifted_lognormal_distribution {
- get {
- return ResourceManager.GetString("SoilLayer_Stochastic_parameter_0_has_no_shifted_lognormal_distribution", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Coördinaat van een punt bevat ongeldige waarde..
///
public static string SoilLayer2DGeometryReader_Could_not_parse_point_location {
@@ -1749,15 +1740,33 @@
}
///
- /// Looks up a localized string similar to Parameter '{0}' is niet lognormaal verdeeld..
+ /// Looks up a localized string similar to Parameter '{0}' moet verschoven lognormaal verdeeld zijn..
///
- public static string Stochastic_parameter_0_has_no_lognormal_distribution {
+ public static string Stochastic_parameter_0_has_no_shifted_lognormal_distribution {
get {
- return ResourceManager.GetString("Stochastic_parameter_0_has_no_lognormal_distribution", resourceCulture);
+ return ResourceManager.GetString("Stochastic_parameter_0_has_no_shifted_lognormal_distribution", resourceCulture);
}
}
///
+ /// Looks up a localized string similar to Parameter '{0}' moet lognormaal verdeeld zijn..
+ ///
+ public static string Stochastic_parameter_0_must_be_a_lognormal_distribution {
+ get {
+ return ResourceManager.GetString("Stochastic_parameter_0_must_be_a_lognormal_distribution", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Parameter '{0}' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0..
+ ///
+ public static string Stochastic_parameter_0_must_be_a_lognormal_distribution_with_zero_shift {
+ get {
+ return ResourceManager.GetString("Stochastic_parameter_0_must_be_a_lognormal_distribution_with_zero_shift", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Kon geen stochastische ondergrondmodellen verkrijgen uit de database..
///
public static string StochasticSoilModelDatabaseReader_Failed_to_read_database {
@@ -2517,6 +2526,24 @@
}
///
+ /// Looks up a localized string similar to Er is een fout opgetreden bij het inlezen van grondlaag '{0}': {1}.
+ ///
+ public static string Transform_Error_occurred_when_transforming_SoilLayer_0_ErrorMessage_1_ {
+ get {
+ return ResourceManager.GetString("Transform_Error_occurred_when_transforming_SoilLayer_0_ErrorMessage_1_", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Er is een fout opgetreden bij het inlezen van ondergrondschematisatie '{0}': {1}.
+ ///
+ public static string Transform_Error_occurred_when_transforming_SoilProfile_0_ErrorMessage_1_ {
+ get {
+ return ResourceManager.GetString("Transform_Error_occurred_when_transforming_SoilProfile_0_ErrorMessage_1_", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Ongeldige waarde voor parameter '{0}'..
///
public static string Transform_Invalid_value_ParameterName_0 {
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx
===================================================================
diff -u -ra557c00f0de18bc9636711c7dbb0c3ab428c21b6 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision a557c00f0de18bc9636711c7dbb0c3ab428c21b6)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -850,14 +850,14 @@
Het lezen van de ondergrondschematisatie '{0}' is mislukt. Geen geldige waarde in kolom '{1}'.
-
- Parameter '{0}' is niet lognormaal verdeeld.
+
+ Parameter '{0}' moet lognormaal verdeeld zijn.
De ondergrondschematisatie van het type '{0}' is niet ondersteund. Alleen ondergrondschematisaties van het type '{1}' of '{2}' zijn ondersteund.
-
- Parameter '{0}' is niet verschoven lognormaal verdeeld.
+
+ Parameter '{0}' moet verschoven lognormaal verdeeld zijn.
Is aquifer
@@ -871,4 +871,13 @@
Ondergrondschematisatie '{0}' is meerdere keren gevonden in ondergrondmodel '{1}'. Kansen van voorkomen worden opgeteld.
+
+ Parameter '{0}' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.
+
+
+ Er is een fout opgetreden bij het inlezen van grondlaag '{0}': {1}
+
+
+ Er is een fout opgetreden bij het inlezen van ondergrondschematisatie '{0}': {1}
+
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/DistributionHelper.cs
===================================================================
diff -u -r6ef5e439a6d9f40ebd9926251945e0935fbbc314 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/DistributionHelper.cs (.../DistributionHelper.cs) (revision 6ef5e439a6d9f40ebd9926251945e0935fbbc314)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/DistributionHelper.cs (.../DistributionHelper.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -43,32 +43,39 @@
/// is null.
/// Thrown when the parameter is not a
/// log normal distribution with a zero shift.
- public static void ValidateIsNonShiftedLogNormal(long? distributionType, double shift, string parameterName)
+ public static void ValidateLogNormalDistribution(long? distributionType, double shift, string parameterName)
{
if (parameterName == null)
{
throw new ArgumentNullException(nameof(parameterName));
}
- if (distributionType.HasValue && (distributionType.Value != SoilLayerConstants.LogNormalDistributionValue
- || Math.Abs(shift) > tolerance))
+ if (distributionType.HasValue)
{
- throw new ImportedDataTransformException(string.Format(
- Resources.Stochastic_parameter_0_has_no_lognormal_distribution,
- parameterName));
+ if (distributionType.Value != SoilLayerConstants.LogNormalDistributionValue)
+ throw new ImportedDataTransformException(string.Format(
+ Resources.Stochastic_parameter_0_must_be_a_lognormal_distribution,
+ parameterName));
+
+ if (Math.Abs(shift) > tolerance)
+ {
+ throw new ImportedDataTransformException(string.Format(
+ Resources.Stochastic_parameter_0_must_be_a_lognormal_distribution_with_zero_shift,
+ parameterName));
+ }
}
}
///
- /// Validates that the distribution is a log normal distribution.
+ /// Validates that the distribution is a (shifted) log normal distribution.
///
/// The distribution type.
/// The name of the parameter to be validated.
/// Thrown when
/// is null.
/// Thrown when the parameter is not a
/// log normal distribution.
- public static void ValidateIsLogNormal(long? distributionType, string parameterName)
+ public static void ValidateShiftedLogNormalDistribution(long? distributionType, string parameterName)
{
if (parameterName == null)
{
@@ -78,7 +85,7 @@
if (distributionType.HasValue && distributionType != SoilLayerConstants.LogNormalDistributionValue)
{
throw new ImportedDataTransformException(string.Format(
- Resources.SoilLayer_Stochastic_parameter_0_has_no_shifted_lognormal_distribution,
+ Resources.Stochastic_parameter_0_has_no_shifted_lognormal_distribution,
parameterName));
}
}
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/DistributionHelperTest.cs
===================================================================
diff -u -r6ef5e439a6d9f40ebd9926251945e0935fbbc314 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/DistributionHelperTest.cs (.../DistributionHelperTest.cs) (revision 6ef5e439a6d9f40ebd9926251945e0935fbbc314)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/DistributionHelperTest.cs (.../DistributionHelperTest.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -30,15 +30,15 @@
public class DistributionHelperTest
{
[Test]
- public void ValidateIsNonShiftedLogNormal_ParameterNameNull_ThrowsArgumentNullException()
+ public void ValidateLogNormalDistribution_ParameterNameNull_ThrowsArgumentNullException()
{
// Setup
var random = new Random(21);
long distributionType = random.Next();
double shift = random.NextDouble();
// Call
- TestDelegate call = () => DistributionHelper.ValidateIsNonShiftedLogNormal(distributionType,
+ TestDelegate call = () => DistributionHelper.ValidateLogNormalDistribution(distributionType,
shift,
null);
@@ -48,34 +48,54 @@
}
[Test]
- [TestCase(-1, 0)]
- [TestCase(3, 10)]
- public void ValidateIsNonShiftedLogNormal_InvalidDistributionProperties_ThrowsImportedDataException(
- long distributionType,
- double shift)
+ public void ValidateLogNormalDistribution_InvalidDistributionType_ThrowsImportedDataException()
{
// Setup
+ const long distributionType = -1;
const string parameterName = "Just a name";
+ var random = new Random(21);
+ double shift = random.NextDouble();
+
// Call
- TestDelegate call = () => DistributionHelper.ValidateIsNonShiftedLogNormal(distributionType,
+ TestDelegate call = () => DistributionHelper.ValidateLogNormalDistribution(distributionType,
shift,
parameterName);
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual($"Parameter '{parameterName}' is niet lognormaal verdeeld.", exception.Message);
+ Assert.AreEqual($"Parameter '{parameterName}' moet lognormaal verdeeld zijn.", exception.Message);
}
[Test]
- public void ValidateIsNonShiftedLogNormal_ValidDistribution_DoesNotThrowException()
+ public void ValidateLogNormalDistribution_ShiftNonZero_ThrowsImportedDataTransformException()
{
// Setup
- const long distributionType = 3;
+ const long distributionType = SoilLayerConstants.LogNormalDistributionValue;
+ const string parameterName = "Just a name";
+
+ var random = new Random(21);
+ double shift = random.NextDouble();
+
+ // Call
+ TestDelegate call = () => DistributionHelper.ValidateLogNormalDistribution(distributionType,
+ shift,
+ parameterName);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual($"Parameter '{parameterName}' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.", exception.Message);
+ }
+
+ [Test]
+ public void ValidateLogNormalDistribution_ValidDistribution_DoesNotThrowException()
+ {
+ // Setup
+ const long distributionType = SoilLayerConstants.LogNormalDistributionValue;
const double shift = 0;
// Call
- TestDelegate call = () => DistributionHelper.ValidateIsNonShiftedLogNormal(distributionType,
+ TestDelegate call = () => DistributionHelper.ValidateLogNormalDistribution(distributionType,
shift,
string.Empty);
@@ -84,15 +104,15 @@
}
[Test]
- public void ValidateIsNonShiftedLogNormal_DistributionTypeNull_DoesNotThrowException()
+ public void ValidateLogNormalDistribution_DistributionTypeNull_DoesNotThrowException()
{
// Setup
var random = new Random(21);
double shift = random.NextDouble();
const string parameterName = "Just a name";
// Call
- TestDelegate call = () => DistributionHelper.ValidateIsNonShiftedLogNormal(null,
+ TestDelegate call = () => DistributionHelper.ValidateLogNormalDistribution(null,
shift,
parameterName);
@@ -101,60 +121,60 @@
}
[Test]
- public void ValidateIsLogNormal_ParameterNameNull_ThrowsArgumentNullException()
+ public void ValidateShiftedLogNormalDistribution_ParameterNameNull_ThrowsArgumentNullException()
{
// Setup
var random = new Random(21);
long distributionType = random.Next();
// Call
- TestDelegate call = () => DistributionHelper.ValidateIsLogNormal(distributionType,
- null);
+ TestDelegate call = () => DistributionHelper.ValidateShiftedLogNormalDistribution(distributionType,
+ null);
// Assert
var exception = Assert.Throws(call);
Assert.AreEqual("parameterName", exception.ParamName);
}
[Test]
- public void ValidateIsLogNormal_InvalidDistributionProperties_ThrowsImportedDataException()
+ public void ValidateShiftedLogNormalDistribution_InvalidDistributionType_ThrowsImportedDataException()
{
// Setup
const long invalidDistributionType = -1;
const string parameterName = "Just a name";
// Call
- TestDelegate call = () => DistributionHelper.ValidateIsLogNormal(invalidDistributionType,
- parameterName);
+ TestDelegate call = () => DistributionHelper.ValidateShiftedLogNormalDistribution(invalidDistributionType,
+ parameterName);
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual($"Parameter '{parameterName}' is niet verschoven lognormaal verdeeld.", exception.Message);
+ Assert.AreEqual($"Parameter '{parameterName}' moet verschoven lognormaal verdeeld zijn.", exception.Message);
}
[Test]
- public void ValidateIsLogNormal_ValidDistribution_DoesNotThrowException()
+ public void ValidateShiftedLogNormalDistribution_ValidDistribution_DoesNotThrowException()
{
// Setup
- const long distributionType = 3;
+ const long distributionType = SoilLayerConstants.LogNormalDistributionValue;
// Call
- TestDelegate call = () => DistributionHelper.ValidateIsLogNormal(distributionType,
- string.Empty);
+ TestDelegate call = () => DistributionHelper.ValidateShiftedLogNormalDistribution(distributionType,
+ string.Empty);
// Assert
Assert.DoesNotThrow(call);
}
[Test]
- public void ValidateIsLogNormal_DistributionTypeNull_DoesNotThrowException()
+ public void ValidateShiftedLogNormalDistribution_DistributionTypeNull_DoesNotThrowException()
{
// Setup
const string parameterName = "Just a name";
// Call
- TestDelegate call = () => DistributionHelper.ValidateIsLogNormal(null,
- parameterName);
+ TestDelegate call = () => DistributionHelper.ValidateShiftedLogNormalDistribution(null,
+ parameterName);
// Assert
Assert.DoesNotThrow(call);
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -rc20bf4d294bbee92c96364ee32dc9f7e242646d5 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c20bf4d294bbee92c96364ee32dc9f7e242646d5)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -399,5 +399,25 @@
"ry", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Er is een fout opgetreden bij het inlezen van grondlaag '{0}' voor parameter '{1}': {2}.
+ ///
+ public static string Transform_Error_occurred_when_transforming_SoilLayer_0_for_Parameter_1_ErrorMessage_2_ {
+ get {
+ return ResourceManager.GetString("Transform_Error_occurred_when_transforming_SoilLayer_0_for_Parameter_1_ErrorMessa" +
+ "ge_2_", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Grensspanning op locatie {0} heeft een ongeldige waarde. {1}.
+ ///
+ public static string Transform_PreconsolidationStressLocation_0_has_invalid_configuration_ErrorMessage_1_ {
+ get {
+ return ResourceManager.GetString("Transform_PreconsolidationStressLocation_0_has_invalid_configuration_ErrorMessage" +
+ "_1_", resourceCulture);
+ }
+ }
}
}
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.resx
===================================================================
diff -u -rc20bf4d294bbee92c96364ee32dc9f7e242646d5 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision c20bf4d294bbee92c96364ee32dc9f7e242646d5)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -205,4 +205,10 @@
Een waarde van '{0}' als aantal verticale punten is ongeldig.
+
+ Er is een fout opgetreden bij het inlezen van grondlaag '{0}' voor parameter '{1}': {2}
+
+
+ Grensspanning op locatie {0} heeft een ongeldige waarde. {1}
+
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsPreconsolidationStressTransformer.cs
===================================================================
diff -u -r31f59cfc48a6839453e372572d03ecc6ae6f0d00 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsPreconsolidationStressTransformer.cs (.../MacroStabilityInwardsPreconsolidationStressTransformer.cs) (revision 31f59cfc48a6839453e372572d03ecc6ae6f0d00)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsPreconsolidationStressTransformer.cs (.../MacroStabilityInwardsPreconsolidationStressTransformer.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -27,7 +27,6 @@
using Ringtoets.Common.IO.SoilProfile;
using Ringtoets.MacroStabilityInwards.Data.SoilProfile;
using Ringtoets.MacroStabilityInwards.IO.Properties;
-using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources;
namespace Ringtoets.MacroStabilityInwards.IO.SoilProfiles
{
@@ -57,10 +56,11 @@
throw new ArgumentNullException(nameof(preconsolidationStress));
}
- DistributionHelper.ValidateIsNonShiftedLogNormal(preconsolidationStress.StressDistributionType,
- preconsolidationStress.StressShift,
- Resources.PreconsolidationStress_DisplayName);
+ var location = new Point2D(preconsolidationStress.XCoordinate,
+ preconsolidationStress.ZCoordinate);
+ ValidateDistribution(preconsolidationStress, location);
+
try
{
var distribution = new VariationCoefficientLogNormalDistribution
@@ -69,21 +69,47 @@
CoefficientOfVariation = (RoundedDouble) preconsolidationStress.StressCoefficientOfVariation
};
- var location = new Point2D(preconsolidationStress.XCoordinate,
- preconsolidationStress.ZCoordinate);
-
return new MacroStabilityInwardsPreconsolidationStress(location, distribution);
}
catch (ArgumentOutOfRangeException e)
{
- string errorMessage = string.Format(RingtoetsCommonIOResources.Stochastic_parameter_0_has_no_lognormal_distribution,
- Resources.PreconsolidationStress_DisplayName);
+ string errorMessage = CreateErrorMessage(location, e.Message);
throw new ImportedDataTransformException(errorMessage, e);
}
catch (ArgumentException e)
{
throw new ImportedDataTransformException(e.Message, e);
}
}
+
+ private static string CreateErrorMessage(Point2D location, string errorMessage)
+ {
+ return string.Format(Resources.Transform_PreconsolidationStressLocation_0_has_invalid_configuration_ErrorMessage_1_,
+ location,
+ errorMessage);
+ }
+
+ ///
+ /// Validates whether the values of the
+ /// are correct for creating the log normal distribution of a reconsolidation stress.
+ ///
+ /// The to validate.
+ /// The location of the
+ /// Thrown when the stochastic parameters
+ /// are not defined as a log normal distribution.
+ private static void ValidateDistribution(PreconsolidationStress preconsolidationStress, Point2D location)
+ {
+ try
+ {
+ DistributionHelper.ValidateLogNormalDistribution(preconsolidationStress.StressDistributionType,
+ preconsolidationStress.StressShift,
+ Resources.PreconsolidationStress_DisplayName);
+ }
+ catch (ImportedDataTransformException e)
+ {
+ string errorMessage = CreateErrorMessage(location, e.Message);
+ throw new ImportedDataTransformException(errorMessage, e);
+ }
+ }
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs
===================================================================
diff -u -r53d2734c780c83d29b435303f9d82bcbaac94fe7 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs (.../MacroStabilityInwardsSoilLayerTransformer.cs) (revision 53d2734c780c83d29b435303f9d82bcbaac94fe7)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs (.../MacroStabilityInwardsSoilLayerTransformer.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -60,7 +60,6 @@
}
ValidateStochasticParameters(soilLayer);
-
return new MacroStabilityInwardsSoilLayer1D(soilLayer.Top, ConvertSoilLayerData(soilLayer));
}
@@ -82,7 +81,6 @@
}
ValidateStochasticParameters(soilLayer);
-
return ConvertLayerRecursively(soilLayer);
}
@@ -95,7 +93,7 @@
/// in a valid transformed instance.
private static MacroStabilityInwardsSoilLayer2D ConvertLayerRecursively(SoilLayer2D soilLayer)
{
- return new MacroStabilityInwardsSoilLayer2D(TransformSegmentsToRing(soilLayer.OuterLoop.Segments),
+ return new MacroStabilityInwardsSoilLayer2D(TransformSegmentsToRing(soilLayer.OuterLoop.Segments, soilLayer.MaterialName),
ConvertSoilLayerData(soilLayer),
soilLayer.NestedLayers.Select(ConvertLayerRecursively).ToArray());
}
@@ -108,72 +106,130 @@
/// in a valid transformed instance.
private static MacroStabilityInwardsSoilLayerData ConvertSoilLayerData(SoilLayerBase soilLayer)
{
+ string soilLayerName = soilLayer.MaterialName;
return new MacroStabilityInwardsSoilLayerData
{
- ShearStrengthModel = TransformShearStrengthModel(soilLayer.ShearStrengthModel),
- UsePop = TransformUsePop(soilLayer.UsePop),
+ ShearStrengthModel = TransformShearStrengthModel(soilLayer.ShearStrengthModel, soilLayerName),
+ UsePop = TransformUsePop(soilLayer.UsePop, soilLayerName),
- MaterialName = soilLayer.MaterialName,
- IsAquifer = TransformIsAquifer(soilLayer.IsAquifer),
+ MaterialName = soilLayerName,
+ IsAquifer = TransformIsAquifer(soilLayer.IsAquifer, soilLayerName),
Color = SoilLayerColorConverter.Convert(soilLayer.Color),
- AbovePhreaticLevel = new VariationCoefficientLogNormalDistribution
- {
- Mean = (RoundedDouble) soilLayer.AbovePhreaticLevelMean,
- CoefficientOfVariation = (RoundedDouble) soilLayer.AbovePhreaticLevelCoefficientOfVariation,
- Shift = (RoundedDouble) soilLayer.AbovePhreaticLevelShift
- },
- BelowPhreaticLevel = new VariationCoefficientLogNormalDistribution
- {
- Mean = (RoundedDouble) soilLayer.BelowPhreaticLevelMean,
- CoefficientOfVariation = (RoundedDouble) soilLayer.BelowPhreaticLevelCoefficientOfVariation,
- Shift = (RoundedDouble) soilLayer.BelowPhreaticLevelShift
- },
- Cohesion = new VariationCoefficientLogNormalDistribution
- {
- Mean = (RoundedDouble) soilLayer.CohesionMean,
- CoefficientOfVariation = (RoundedDouble) soilLayer.CohesionCoefficientOfVariation
- },
- FrictionAngle = new VariationCoefficientLogNormalDistribution
- {
- Mean = (RoundedDouble) soilLayer.FrictionAngleMean,
- CoefficientOfVariation = (RoundedDouble) soilLayer.FrictionAngleCoefficientOfVariation
- },
- ShearStrengthRatio = new VariationCoefficientLogNormalDistribution
- {
- Mean = (RoundedDouble) soilLayer.ShearStrengthRatioMean,
- CoefficientOfVariation = (RoundedDouble) soilLayer.ShearStrengthRatioCoefficientOfVariation
- },
- StrengthIncreaseExponent = new VariationCoefficientLogNormalDistribution
- {
- Mean = (RoundedDouble) soilLayer.StrengthIncreaseExponentMean,
- CoefficientOfVariation = (RoundedDouble) soilLayer.StrengthIncreaseExponentCoefficientOfVariation
- },
- Pop = new VariationCoefficientLogNormalDistribution
- {
- Mean = (RoundedDouble) soilLayer.PopMean,
- CoefficientOfVariation = (RoundedDouble) soilLayer.PopCoefficientOfVariation
- }
+
+ AbovePhreaticLevel = TransformLogNormalDistribution(soilLayer.AbovePhreaticLevelMean,
+ soilLayer.AbovePhreaticLevelCoefficientOfVariation,
+ soilLayer.AbovePhreaticLevelShift,
+ soilLayerName,
+ Resources.SoilLayerData_AbovePhreaticLevelDistribution_Description),
+ BelowPhreaticLevel = TransformLogNormalDistribution(soilLayer.BelowPhreaticLevelMean,
+ soilLayer.BelowPhreaticLevelCoefficientOfVariation,
+ soilLayer.BelowPhreaticLevelShift,
+ soilLayerName,
+ Resources.SoilLayerData_BelowPhreaticLevelDistribution_DisplayName),
+
+ Cohesion = TransformLogNormalDistribution(soilLayer.CohesionMean,
+ soilLayer.CohesionCoefficientOfVariation,
+ soilLayerName,
+ Resources.SoilLayerData_CohesionDistribution_DisplayName),
+ FrictionAngle = TransformLogNormalDistribution(soilLayer.FrictionAngleMean,
+ soilLayer.FrictionAngleCoefficientOfVariation,
+ soilLayerName,
+ Resources.SoilLayerData_FrictionAngleDistribution_DisplayName),
+ ShearStrengthRatio = TransformLogNormalDistribution(soilLayer.ShearStrengthRatioMean,
+ soilLayer.ShearStrengthRatioCoefficientOfVariation,
+ soilLayerName,
+ Resources.SoilLayerData_ShearStrengthRatioDistribution_DisplayName),
+ StrengthIncreaseExponent = TransformLogNormalDistribution(soilLayer.StrengthIncreaseExponentMean,
+ soilLayer.StrengthIncreaseExponentCoefficientOfVariation,
+ soilLayerName,
+ Resources.SoilLayerData_StrengthIncreaseExponentDistribution_DisplayName),
+ Pop = TransformLogNormalDistribution(soilLayer.PopMean,
+ soilLayer.PopCoefficientOfVariation,
+ soilLayerName,
+ Resources.SoilLayerData_PopDistribution_DisplayName)
};
}
///
+ /// Transforms the input arguments into a log normal distribution for a parameter of a soil layer.
+ ///
+ /// The mean of the distribution.
+ /// The coefficient of variation of the distribution.
+ /// The name of the soil layer.
+ /// The name of the parameter to create a distribution for.
+ /// A based on the input arguments.
+ /// Thrown when a
+ /// cannot be created due to invalid values for , .
+ private static VariationCoefficientLogNormalDistribution TransformLogNormalDistribution(double mean,
+ double coefficientOfVariation,
+ string soilLayerName,
+ string parameterName)
+ {
+ return TransformLogNormalDistribution(mean,
+ coefficientOfVariation,
+ new VariationCoefficientLogNormalDistribution().Shift,
+ soilLayerName,
+ parameterName);
+ }
+
+ ///
+ /// Transforms the input arguments into a log normal distribution for a parameter of a soil layer.
+ ///
+ /// The mean of the distribution.
+ /// The coefficient of variation of the distribution.
+ /// The shift of the distribution.
+ /// The name of the soil layer.
+ /// The name of the parameter to create a distribution for.
+ /// A based on the input arguments.
+ /// Thrown when a
+ /// cannot be created due to invalid values for ,
+ /// or .
+ private static VariationCoefficientLogNormalDistribution TransformLogNormalDistribution(double mean,
+ double coefficientOfVariation,
+ double shift,
+ string soilLayerName,
+ string parameterName)
+ {
+ try
+ {
+ return new VariationCoefficientLogNormalDistribution
+ {
+ Mean = (RoundedDouble) mean,
+ CoefficientOfVariation = (RoundedDouble) coefficientOfVariation,
+ Shift = (RoundedDouble) shift
+ };
+ }
+ catch (ArgumentOutOfRangeException e)
+ {
+ string exceptionMessage = string.Format(Resources.Transform_Error_occurred_when_transforming_SoilLayer_0_for_Parameter_1_ErrorMessage_2_,
+ soilLayerName,
+ parameterName,
+ e.Message);
+ throw new ImportedDataTransformException(exceptionMessage, e);
+ }
+ }
+
+ ///
/// Transforms a to a for the
/// is aquifer property of soil layers.
///
/// The value to transform.
+ /// The name of the soil layer.
/// A based on .
/// Thrown when
/// could not be transformed.
- private static bool TransformIsAquifer(double? isAquifer)
+ private static bool TransformIsAquifer(double? isAquifer, string soilLayerName)
{
try
{
return SoilLayerIsAquiferConverter.Convert(isAquifer);
}
- catch (NotSupportedException)
+ catch (NotSupportedException e)
{
- throw new ImportedDataTransformException(string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0,
- RingtoetsCommonIOResources.SoilLayerData_IsAquifer_DisplayName));
+ string exceptionMessage = CreateErrorMessage(soilLayerName,
+ string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0,
+ RingtoetsCommonIOResources.SoilLayerData_IsAquifer_DisplayName));
+ throw new ImportedDataTransformException(exceptionMessage, e);
}
}
@@ -182,10 +238,11 @@
/// use POP property of soil layers.
///
/// The value to transform.
+ /// The name of the soil layer.
/// A based on .
/// Thrown when
/// could not be transformed.
- private static bool TransformUsePop(double? usePop)
+ private static bool TransformUsePop(double? usePop, string soilLayerName)
{
if (!usePop.HasValue)
{
@@ -197,21 +254,26 @@
return false;
}
- throw new ImportedDataTransformException(string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0,
- Resources.SoilLayerData_UsePop_Description));
+ string exceptionMessage = CreateErrorMessage(soilLayerName,
+ string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0,
+ Resources.SoilLayerData_UsePop_Description));
+ throw new ImportedDataTransformException(exceptionMessage);
}
///
/// Transforms a to a for the
/// shear strength model of soil layers.
///
/// The value to transform.
+ /// The name of the soil layer.
/// A based
/// on .
/// Thrown when
/// could not be transformed.
- private static MacroStabilityInwardsShearStrengthModel TransformShearStrengthModel(double? shearStrengthModel)
+ private static MacroStabilityInwardsShearStrengthModel TransformShearStrengthModel(double? shearStrengthModel,
+ string soilLayerName)
{
+ string exceptionMessage;
if (!shearStrengthModel.HasValue)
{
return MacroStabilityInwardsShearStrengthModel.CPhi;
@@ -226,29 +288,36 @@
}
if (Math.Abs(shearStrengthModel.Value - 1) < tolerance)
{
- throw new ImportedDataTransformException(Resources.MacroStabilityInwardsSoilLayerTransformer_TransformShearStrengthModel_No_MacroStabilityInwardsShearStrengthModel);
+ exceptionMessage = CreateErrorMessage(soilLayerName,
+ Resources.MacroStabilityInwardsSoilLayerTransformer_TransformShearStrengthModel_No_MacroStabilityInwardsShearStrengthModel);
+ throw new ImportedDataTransformException(exceptionMessage);
}
- throw new ImportedDataTransformException(string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0,
- Resources.SoilLayerData_ShearStrengthModel_Description));
+ exceptionMessage = CreateErrorMessage(soilLayerName,
+ string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0,
+ Resources.SoilLayerData_ShearStrengthModel_Description));
+ throw new ImportedDataTransformException(exceptionMessage);
}
///
/// Transforms a collection of to .
///
/// The segments to transform.
+ /// The name of the soil layer.
/// A based on .
/// Thrown when
/// could not be transformed to a .
- private static Ring TransformSegmentsToRing(IEnumerable segments)
+ private static Ring TransformSegmentsToRing(IEnumerable segments, string soilLayerName)
{
try
{
return new Ring(segments.Select(s => s.FirstPoint));
}
catch (ArgumentException e)
{
- throw new ImportedDataTransformException(Resources.MacroStabilityInwardsSoilLayerTransformer_TransformSegmentToRing_Invalid_geometry_for_Ring, e);
+ string exceptionMessage = CreateErrorMessage(soilLayerName,
+ Resources.MacroStabilityInwardsSoilLayerTransformer_TransformSegmentToRing_Invalid_geometry_for_Ring);
+ throw new ImportedDataTransformException(exceptionMessage, e);
}
}
@@ -261,37 +330,52 @@
/// stochastic parameters is not defined as log normal or is shifted when it should not be.
private static void ValidateStochasticParameters(SoilLayerBase soilLayer)
{
- DistributionHelper.ValidateIsLogNormal(soilLayer.AbovePhreaticLevelDistributionType,
- Resources.SoilLayerData_AbovePhreaticLevelDistribution_Description);
+ try
+ {
+ DistributionHelper.ValidateShiftedLogNormalDistribution(soilLayer.AbovePhreaticLevelDistributionType,
+ Resources.SoilLayerData_AbovePhreaticLevelDistribution_Description);
- DistributionHelper.ValidateIsLogNormal(
- soilLayer.BelowPhreaticLevelDistributionType,
- Resources.SoilLayerData_BelowPhreaticLevelDistribution_DisplayName);
+ DistributionHelper.ValidateShiftedLogNormalDistribution(
+ soilLayer.BelowPhreaticLevelDistributionType,
+ Resources.SoilLayerData_BelowPhreaticLevelDistribution_DisplayName);
- DistributionHelper.ValidateIsNonShiftedLogNormal(
- soilLayer.CohesionDistributionType,
- soilLayer.CohesionShift,
- Resources.SoilLayerData_CohesionDistribution_DisplayName);
+ DistributionHelper.ValidateLogNormalDistribution(
+ soilLayer.CohesionDistributionType,
+ soilLayer.CohesionShift,
+ Resources.SoilLayerData_CohesionDistribution_DisplayName);
- DistributionHelper.ValidateIsNonShiftedLogNormal(
- soilLayer.FrictionAngleDistributionType,
- soilLayer.FrictionAngleShift,
- Resources.SoilLayerData_FrictionAngleDistribution_DisplayName);
+ DistributionHelper.ValidateLogNormalDistribution(
+ soilLayer.FrictionAngleDistributionType,
+ soilLayer.FrictionAngleShift,
+ Resources.SoilLayerData_FrictionAngleDistribution_DisplayName);
- DistributionHelper.ValidateIsNonShiftedLogNormal(
- soilLayer.ShearStrengthRatioDistributionType,
- soilLayer.ShearStrengthRatioShift,
- Resources.SoilLayerData_ShearStrengthRatioDistribution_DisplayName);
+ DistributionHelper.ValidateLogNormalDistribution(
+ soilLayer.ShearStrengthRatioDistributionType,
+ soilLayer.ShearStrengthRatioShift,
+ Resources.SoilLayerData_ShearStrengthRatioDistribution_DisplayName);
- DistributionHelper.ValidateIsNonShiftedLogNormal(
- soilLayer.StrengthIncreaseExponentDistributionType,
- soilLayer.StrengthIncreaseExponentShift,
- Resources.SoilLayerData_StrengthIncreaseExponentDistribution_DisplayName);
+ DistributionHelper.ValidateLogNormalDistribution(
+ soilLayer.StrengthIncreaseExponentDistributionType,
+ soilLayer.StrengthIncreaseExponentShift,
+ Resources.SoilLayerData_StrengthIncreaseExponentDistribution_DisplayName);
- DistributionHelper.ValidateIsNonShiftedLogNormal(
- soilLayer.PopDistributionType,
- soilLayer.PopShift,
- Resources.SoilLayerData_PopDistribution_DisplayName);
+ DistributionHelper.ValidateLogNormalDistribution(
+ soilLayer.PopDistributionType,
+ soilLayer.PopShift,
+ Resources.SoilLayerData_PopDistribution_DisplayName);
+ }
+ catch (ImportedDataTransformException e)
+ {
+ string errorMessage = CreateErrorMessage(soilLayer.MaterialName, e.Message);
+ throw new ImportedDataTransformException(errorMessage, e);
+ }
}
+
+ private static string CreateErrorMessage(string soilLayerName, string errorMessage)
+ {
+ return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilLayer_0_ErrorMessage_1_,
+ soilLayerName,
+ errorMessage);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs
===================================================================
diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs (.../MacroStabilityInwardsSoilProfileTransformer.cs) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs (.../MacroStabilityInwardsSoilProfileTransformer.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.Linq;
using Ringtoets.Common.IO.Exceptions;
using Ringtoets.Common.IO.SoilProfile;
@@ -89,7 +90,8 @@
}
catch (ArgumentException e)
{
- throw new ImportedDataTransformException(e.Message, e);
+ string message = CreateErrorMessage(soilProfile.Name, e.Message);
+ throw new ImportedDataTransformException(message, e);
}
}
@@ -109,14 +111,41 @@
soilProfile.Layers
.Select(MacroStabilityInwardsSoilLayerTransformer.Transform)
.ToArray(),
- soilProfile.PreconsolidationStresses
- .Select(MacroStabilityInwardsPreconsolidationStressTransformer.Transform)
- .ToArray());
+ TransformPreconsolidationStresses(soilProfile.Name, soilProfile.PreconsolidationStresses));
}
catch (ArgumentException e)
{
- throw new ImportedDataTransformException(e.Message, e);
+ string message = CreateErrorMessage(soilProfile.Name, e.Message);
+ throw new ImportedDataTransformException(message, e);
}
}
+
+ ///
+ /// Transforms the generic collection of into a .
+ ///
+ /// The name of the soil profile.
+ /// The collection of to transform.
+ /// An based on .
+ /// Thrown when the
+ /// could not be transformed into valid .
+ private static IEnumerable TransformPreconsolidationStresses(string soilProfileName,
+ IEnumerable preconsolidationStresses)
+ {
+ try
+ {
+ return preconsolidationStresses.Select(MacroStabilityInwardsPreconsolidationStressTransformer.Transform)
+ .ToArray();
+ }
+ catch (ImportedDataTransformException e)
+ {
+ string message = CreateErrorMessage(soilProfileName, e.Message);
+ throw new ImportedDataTransformException(message, e);
+ }
+ }
+
+ private static string CreateErrorMessage(string soilProfileName, string errorMessage)
+ {
+ return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilProfile_0_ErrorMessage_1_, soilProfileName, errorMessage);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsPreconsolidationStressTransformerTest.cs
===================================================================
diff -u -rd2548d8c57adf0df3e06c5e7ceb3eb9086d84cb2 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsPreconsolidationStressTransformerTest.cs (.../MacroStabilityInwardsPreconsolidationStressTransformerTest.cs) (revision d2548d8c57adf0df3e06c5e7ceb3eb9086d84cb2)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsPreconsolidationStressTransformerTest.cs (.../MacroStabilityInwardsPreconsolidationStressTransformerTest.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using Core.Common.Base.Geometry;
using NUnit.Framework;
using Ringtoets.Common.Data.Probabilistics;
using Ringtoets.Common.Data.TestUtil;
@@ -79,20 +80,21 @@
[Test]
[TestCaseSource(nameof(GetPreconsolidationStressCombinationWithNaNValues))]
public void Transform_PreconsolidationStressValuesNaN_ThrowsImportedDataTransformException(
- PreconsolidationStress preconsolidationStress,
- string parameterName)
+ PreconsolidationStress preconsolidationStress)
{
// Call
TestDelegate call = () => MacroStabilityInwardsPreconsolidationStressTransformer.Transform(preconsolidationStress);
// Assert
var exception = Assert.Throws(call);
- string expectedMessage = $"De waarde voor parameter '{parameterName}' voor de grensspanning moet een concreet getal zijn.";
- Assert.AreEqual(expectedMessage, exception.Message);
- Assert.IsInstanceOf(exception.InnerException);
+
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ Assert.AreEqual(innerException.Message, exception.Message);
}
[Test]
+ [SetCulture("NL-nl")]
[TestCaseSource(nameof(GetPreconsolidationStressInvalidDistributionValues))]
public void Transform_InvalidPreconsolidationStressDistributionValues_ThrowsImportedDataTransformException(PreconsolidationStress preconsolidationStress)
{
@@ -101,40 +103,65 @@
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("Parameter 'Grensspanning' is niet lognormaal verdeeld.", exception.Message);
- Assert.IsInstanceOf(exception.InnerException);
+
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ var coordinate = new Point2D(preconsolidationStress.XCoordinate, preconsolidationStress.ZCoordinate);
+ string expectedMessage = CreateExpectedErrorMessage(coordinate, innerException.Message);
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
- [TestCaseSource(nameof(GetInvalidStochastConfiguration))]
- public void Transform_InvalidStochasticDistributionProperties_ThrowsImportedDataTransformException(
- PreconsolidationStress preconsolidationStress)
+ public void Transform_InvalidStochasticDistributionType_ThrowsImportedDataTransformException()
{
+ // Setup
+ var random = new Random(21);
+ var preconsolidationStress = new PreconsolidationStress
+ {
+ StressDistributionType = random.Next(3, int.MaxValue),
+ StressShift = 0
+ };
+
// Call
TestDelegate call = () => MacroStabilityInwardsPreconsolidationStressTransformer.Transform(preconsolidationStress);
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("Parameter 'Grensspanning' is niet lognormaal verdeeld.", exception.Message);
+ var coordinate = new Point2D(preconsolidationStress.XCoordinate, preconsolidationStress.ZCoordinate);
+ string expectedMessage = CreateExpectedErrorMessage(coordinate,
+ "Parameter 'Grensspanning' moet lognormaal verdeeld zijn.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
- private static IEnumerable GetInvalidStochastConfiguration()
+ [Test]
+ public void Transform_InvalidStochasticDistributionShift_ThrowsImportedDataTransformException()
{
+ // Setup
var random = new Random(21);
-
- yield return new TestCaseData(new PreconsolidationStress
+ var preconsolidationStress = new PreconsolidationStress
{
- StressDistributionType = random.Next(3, int.MaxValue),
- StressShift = 0
- }).SetName("Invalid DistributionType");
-
- yield return new TestCaseData(new PreconsolidationStress
- {
- StressDistributionType = 3,
+ StressDistributionType = SoilLayerConstants.LogNormalDistributionValue,
StressShift = random.NextDouble()
- }).SetName("Invalid Shift");
+ };
+
+ // Call
+ TestDelegate call = () => MacroStabilityInwardsPreconsolidationStressTransformer.Transform(preconsolidationStress);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ var coordinate = new Point2D(preconsolidationStress.XCoordinate, preconsolidationStress.ZCoordinate);
+ string expectedMessage = CreateExpectedErrorMessage(coordinate,
+ "Parameter 'Grensspanning' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
+ private static string CreateExpectedErrorMessage(Point2D location, string errorMessage)
+ {
+ return $"Grensspanning op locatie {location} heeft een ongeldige waarde. {errorMessage}";
+ }
+
+ #region Test data
+
private static IEnumerable GetPreconsolidationStressInvalidDistributionValues()
{
var random = new Random(21);
@@ -170,14 +197,16 @@
ZCoordinate = zCoordinate,
StressMean = preconsolidationStressMean,
StressCoefficientOfVariation = preconsolidationStressCoefficientOfVariation
- }, "X-coördinaat").SetName("XCoordinate NaN");
+ }).SetName("XCoordinate NaN");
yield return new TestCaseData(new PreconsolidationStress
{
XCoordinate = xCoordinate,
ZCoordinate = double.NaN,
StressMean = preconsolidationStressMean,
StressCoefficientOfVariation = preconsolidationStressCoefficientOfVariation
- }, "Z-coördinaat").SetName("ZCoordinate NaN");
+ }).SetName("ZCoordinate NaN");
}
+
+ #endregion
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs
===================================================================
diff -u -r1fb8f412abb01d504e4f546dfed0ca365c1984ae -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs (.../MacroStabilityInwardsSoilLayerTransformerTest.cs) (revision 1fb8f412abb01d504e4f546dfed0ca365c1984ae)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs (.../MacroStabilityInwardsSoilLayerTransformerTest.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -189,7 +189,9 @@
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual("Ongeldige waarde voor parameter 'Gebruik POP'.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Ongeldige waarde voor parameter 'Gebruik POP'.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -222,7 +224,9 @@
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("Er is geen schuifsterkte model opgegeven.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Er is geen schuifsterkte model opgegeven.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -237,7 +241,9 @@
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual("Ongeldige waarde voor parameter 'Schuifsterkte model'.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Ongeldige waarde voor parameter 'Schuifsterkte model'.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -271,7 +277,10 @@
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("Ongeldige waarde voor parameter 'Is aquifer'.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Ongeldige waarde voor parameter 'Is aquifer'.");
+ Assert.AreEqual(expectedMessage, exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
}
[Test]
@@ -298,22 +307,56 @@
// Assert
Exception exception = Assert.Throws(test);
- Assert.AreEqual($"Parameter '{parameter}' is niet verschoven lognormaal verdeeld.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet verschoven lognormaal verdeeld zijn.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
- [TestCaseSource(nameof(IncorrectNonShiftedLogNormalDistributionsSoilLayer1D))]
- public void SoilLayer1DTransform_IncorrectLogNormalDistribution_ThrowImportedDataTransformException(SoilLayer1D layer, string parameter)
+ [TestCaseSource(nameof(IncorrectNonShiftedLogNormalDistributionsTypeSoilLayer1D))]
+ public void SoilLayer1DTransform_IncorrectLogNormalDistributionType_ThrowImportedDataTransformException(SoilLayer1D layer, string parameter)
{
// Call
TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);
// Assert
Exception exception = Assert.Throws(test);
- Assert.AreEqual($"Parameter '{parameter}' is niet lognormaal verdeeld.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet lognormaal verdeeld zijn.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
+ [TestCaseSource(nameof(IncorrectNonShiftedLogNormalDistributionsShiftSoilLayer1D))]
+ public void SoilLayer1DTransform_IncorrectLogNormalDistributionShift_ThrowImportedDataTransformException(SoilLayer1D layer, string parameter)
+ {
+ // Call
+ TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);
+
+ // Assert
+ Exception exception = Assert.Throws(test);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.");
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
+ [TestCaseSource(nameof(InvalidStochasticDistributionValuesSoilLayer1D))]
+ public void SoilLayer1DTransform_InvalidStochasticDistributionValues_ThrowImportedDataTransformException(SoilLayer1D layer, string parameter)
+ {
+ // Call
+ TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);
+
+ // Assert
+ Exception exception = Assert.Throws(test);
+
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ string expectedMessage = $"Er is een fout opgetreden bij het inlezen van grondlaag '{layer.MaterialName}' voor parameter '{parameter}': {innerException.Message}";
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
public void SoilLayer2DTransform_SoilLayer2DNull_ThrowsArgumentNullException()
{
// Call
@@ -395,7 +438,9 @@
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual("Ongeldige waarde voor parameter 'Gebruik POP'.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Ongeldige waarde voor parameter 'Gebruik POP'.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -429,7 +474,9 @@
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("Er is geen schuifsterkte model opgegeven.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Er is geen schuifsterkte model opgegeven.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -444,7 +491,9 @@
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual("Ongeldige waarde voor parameter 'Schuifsterkte model'.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Ongeldige waarde voor parameter 'Schuifsterkte model'.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -478,7 +527,10 @@
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("Ongeldige waarde voor parameter 'Is aquifer'.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Ongeldige waarde voor parameter 'Is aquifer'.");
+ Assert.AreEqual(expectedMessage, exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
}
[Test]
@@ -497,7 +549,7 @@
}
[Test]
- [TestCaseSource(nameof(IncorrectShiftedLogNormalDistributionsSoilLayer2D))]
+ [TestCaseSource(nameof(IncorrectShiftedLogNormalDistributionsTypeSoilLayer2D))]
public void SoilLayer2DTransform_IncorrectShiftedLogNormalDistribution_ThrowsImportedDataTransformException(
SoilLayer2D layer, string parameter)
{
@@ -506,22 +558,40 @@
// Assert
Exception exception = Assert.Throws(test);
- Assert.AreEqual($"Parameter '{parameter}' is niet verschoven lognormaal verdeeld.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet verschoven lognormaal verdeeld zijn.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
- [TestCaseSource(nameof(IncorrectNonShiftedLogNormalDistributionsSoilLayer2D))]
- public void SoilLayer2DTransform_IncorrectLogNormalDistribution_ThrowImportedDataTransformException(SoilLayer2D layer, string parameter)
+ [TestCaseSource(nameof(IncorrectNonShiftedLogNormalDistributionsTypeSoilLayer2D))]
+ public void SoilLayer2DTransform_IncorrectLogNormalDistributionType_ThrowImportedDataTransformException(SoilLayer2D layer, string parameter)
{
// Call
TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);
// Assert
Exception exception = Assert.Throws(test);
- Assert.AreEqual($"Parameter '{parameter}' is niet lognormaal verdeeld.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet lognormaal verdeeld zijn.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
+ [TestCaseSource(nameof(IncorrectNonShiftedLogNormalDistributionsShiftSoilLayer2D))]
+ public void SoilLayer2DTransform_IncorrectLogNormalDistributionShift_ThrowImportedDataTransformException(SoilLayer2D layer, string parameter)
+ {
+ // Call
+ TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);
+
+ // Assert
+ Exception exception = Assert.Throws(test);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.");
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
[TestCaseSource(nameof(GetSoilLayerWithInvalidGeometry))]
public void SoilLayer2DTransform_SoilLayer2DWithInvalidLoops_ThrowsImportedDataException(SoilLayer2D soilLayer)
{
@@ -530,10 +600,28 @@
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("De laag bevat een ongeldige geometrie.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(soilLayer.MaterialName,
+ "De laag bevat een ongeldige geometrie.");
+ Assert.AreEqual(expectedMessage, exception.Message);
Assert.IsInstanceOf(exception.InnerException);
}
+ [Test]
+ [TestCaseSource(nameof(InvalidStochasticDistributionValuesSoilLayer2D))]
+ public void SoilLayer2DTransform_InvalidStochasticDistributionValues_ThrowImportedDataTransformException(SoilLayer2D layer, string parameter)
+ {
+ // Call
+ TestDelegate test = () => MacroStabilityInwardsSoilLayerTransformer.Transform(layer);
+
+ // Assert
+ Exception exception = Assert.Throws(test);
+
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ string expectedMessage = $"Er is een fout opgetreden bij het inlezen van grondlaag '{layer.MaterialName}' voor parameter '{parameter}': {innerException.Message}";
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
private static SoilLayer2DLoop CreateRandomLoop(int seed)
{
var random = new Random(seed);
@@ -574,6 +662,11 @@
layer.PopCoefficientOfVariation = random.NextDouble();
}
+ private static string CreateExpectedErrorMessage(string materialName, string errorMessage)
+ {
+ return $"Er is een fout opgetreden bij het inlezen van grondlaag '{materialName}': {errorMessage}";
+ }
+
private static void AssertSoilLayer(SoilLayer2D original, MacroStabilityInwardsSoilLayer2D actual)
{
AssertOuterRing(original, actual);
@@ -695,114 +788,188 @@
#endregion
+ #region Distribution properties
+
+ private static IEnumerable InvalidStochasticDistributionValuesSoilLayer1D()
+ {
+ return InvalidStochasticDistributionValues(() => SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(), nameof(SoilLayer1D));
+ }
+
+ private static IEnumerable InvalidStochasticDistributionValuesSoilLayer2D()
+ {
+ return InvalidStochasticDistributionValues(SoilLayer2DTestFactory.CreateSoilLayer2D, nameof(SoilLayer2D));
+ }
+
+ private static IEnumerable InvalidStochasticDistributionValues(Func soilLayer, string typeName)
+ {
+ const string testNameFormat = "{0}Transform_InvalidStochasticDistributionValues{{1}}_ThrowsImportedDataTransformException";
+ const double invalidMean = 0;
+
+ SoilLayerBase invalidCohesion = soilLayer();
+ invalidCohesion.CohesionMean = invalidMean;
+ yield return new TestCaseData(invalidCohesion, "Cohesie"
+ ).SetName(string.Format(testNameFormat, typeName));
+
+ SoilLayerBase invalidFrictionAngle = soilLayer();
+ invalidFrictionAngle.FrictionAngleMean = invalidMean;
+ yield return new TestCaseData(invalidFrictionAngle, "Wrijvingshoek"
+ ).SetName(string.Format(testNameFormat, typeName));
+
+ SoilLayerBase invalidShearStrengthRatio = soilLayer();
+ invalidShearStrengthRatio.ShearStrengthRatioMean = invalidMean;
+ yield return new TestCaseData(invalidShearStrengthRatio, "Schuifsterkte ratio (S)"
+ ).SetName(string.Format(testNameFormat, typeName));
+
+ SoilLayerBase invalidStrengthIncreaseExponent = soilLayer();
+ invalidStrengthIncreaseExponent.StrengthIncreaseExponentMean = invalidMean;
+ yield return new TestCaseData(invalidStrengthIncreaseExponent, "Sterkte toename exp (m)"
+ ).SetName(string.Format(testNameFormat, typeName));
+
+ SoilLayerBase invalidPop = soilLayer();
+ invalidPop.PopMean = invalidMean;
+ yield return new TestCaseData(invalidPop, "POP"
+ ).SetName(string.Format(testNameFormat, typeName));
+
+ const double validMean = 1;
+ const double invalidShift = 2;
+ SoilLayerBase invalidBelowPhreaticLevel = soilLayer();
+ invalidBelowPhreaticLevel.BelowPhreaticLevelMean = validMean;
+ invalidBelowPhreaticLevel.BelowPhreaticLevelShift = invalidShift;
+ yield return new TestCaseData(invalidBelowPhreaticLevel, "Verzadigd gewicht")
+ .SetName(string.Format(testNameFormat, typeName));
+
+ SoilLayerBase invalidAbovePhreaticLevel = soilLayer();
+ invalidAbovePhreaticLevel.AbovePhreaticLevelMean = validMean;
+ invalidAbovePhreaticLevel.AbovePhreaticLevelShift = invalidShift;
+ yield return new TestCaseData(invalidAbovePhreaticLevel, "Onverzadigd gewicht")
+ .SetName(string.Format(testNameFormat, typeName));
+ }
+
+ #endregion
+
#region Test Data: Shifted Log Normal Distributions
private static IEnumerable IncorrectShiftedLogNormalDistributionsSoilLayer1D()
{
return IncorrectShiftedLogNormalDistributions(() => new SoilLayer1D(0.0), nameof(SoilLayer1D));
}
- private static IEnumerable IncorrectShiftedLogNormalDistributionsSoilLayer2D()
+ private static IEnumerable IncorrectShiftedLogNormalDistributionsTypeSoilLayer2D()
{
return IncorrectShiftedLogNormalDistributions(SoilLayer2DTestFactory.CreateSoilLayer2D, nameof(SoilLayer2D));
}
private static IEnumerable IncorrectShiftedLogNormalDistributions(Func soilLayer, string typeName)
{
- const string testNameFormat = "{0}Transform_Incorrect{1}{{1}}_ThrowsImportedDataTransformException";
+ const string testNameFormat = "{0}Transform_IncorrectDistribution{{1}}_ThrowsImportedDataTransformException";
SoilLayerBase invalidBelowPhreaticLevel = soilLayer();
invalidBelowPhreaticLevel.BelowPhreaticLevelDistributionType = -1;
yield return new TestCaseData(invalidBelowPhreaticLevel, "Verzadigd gewicht")
- .SetName(string.Format(testNameFormat, typeName, "Distribution"));
+ .SetName(string.Format(testNameFormat, typeName));
SoilLayerBase invalidAbovePhreaticLevel = soilLayer();
invalidAbovePhreaticLevel.AbovePhreaticLevelDistributionType = -1;
yield return new TestCaseData(invalidAbovePhreaticLevel, "Onverzadigd gewicht")
- .SetName(string.Format(testNameFormat, typeName, "Distribution"));
+ .SetName(string.Format(testNameFormat, typeName));
}
#endregion
#region Test Data: NonShifted Log Normal Distributions
- private static IEnumerable IncorrectNonShiftedLogNormalDistributionsSoilLayer1D()
+ private static IEnumerable IncorrectNonShiftedLogNormalDistributionsTypeSoilLayer1D()
{
- return IncorrectNonShiftedLogNormalDistributions(() => new SoilLayer1D(0.0), nameof(SoilLayer1D));
+ return IncorrectNonShiftedLogNormalDistributionsType(() => new SoilLayer1D(0.0), nameof(SoilLayer1D));
}
- private static IEnumerable IncorrectNonShiftedLogNormalDistributionsSoilLayer2D()
+ private static IEnumerable IncorrectNonShiftedLogNormalDistributionsShiftSoilLayer1D()
{
- return IncorrectNonShiftedLogNormalDistributions(SoilLayer2DTestFactory.CreateSoilLayer2D, nameof(SoilLayer2D));
+ return IncorrectNonShiftedLogNormalDistributionsShift(() => new SoilLayer1D(0.0), nameof(SoilLayer1D));
}
- private static IEnumerable IncorrectNonShiftedLogNormalDistributions(Func soilLayer, string typeName)
+ private static IEnumerable IncorrectNonShiftedLogNormalDistributionsTypeSoilLayer2D()
{
- const string testNameFormat = "{0}Transform_Incorrect{1}{{1}}_ThrowsImportedDataTransformException";
- const long validDistributionType = SoilLayerConstants.LogNormalDistributionValue;
- const double validShift = 0.0;
+ return IncorrectNonShiftedLogNormalDistributionsType(SoilLayer2DTestFactory.CreateSoilLayer2D, nameof(SoilLayer2D));
+ }
- SoilLayerBase invalidCohesionShift = soilLayer();
- invalidCohesionShift.CohesionDistributionType = validDistributionType;
- invalidCohesionShift.CohesionShift = -1;
- yield return new TestCaseData(invalidCohesionShift, "Cohesie"
- ).SetName(string.Format(testNameFormat, typeName, "Shift"));
+ private static IEnumerable IncorrectNonShiftedLogNormalDistributionsShiftSoilLayer2D()
+ {
+ return IncorrectNonShiftedLogNormalDistributionsShift(SoilLayer2DTestFactory.CreateSoilLayer2D, nameof(SoilLayer2D));
+ }
+ private static IEnumerable IncorrectNonShiftedLogNormalDistributionsType(Func soilLayer, string typeName)
+ {
+ const string testNameFormat = "{0}Transform_IncorrectDistribution{{1}}_ThrowsImportedDataTransformException";
+ const double validShift = 0.0;
+
SoilLayerBase invalidCohesionDistribution = soilLayer();
invalidCohesionDistribution.CohesionDistributionType = -1;
invalidCohesionDistribution.CohesionShift = validShift;
yield return new TestCaseData(invalidCohesionDistribution, "Cohesie"
- ).SetName(string.Format(testNameFormat, typeName, "Distribution"));
+ ).SetName(string.Format(testNameFormat, typeName));
- SoilLayerBase invalidFrictionAngleShift = soilLayer();
- invalidFrictionAngleShift.FrictionAngleDistributionType = validDistributionType;
- invalidFrictionAngleShift.FrictionAngleShift = -1;
- yield return new TestCaseData(invalidFrictionAngleShift, "Wrijvingshoek"
- ).SetName(string.Format(testNameFormat, typeName, "Shift"));
-
SoilLayerBase invalidFrictionAngleDistribution = soilLayer();
invalidFrictionAngleDistribution.FrictionAngleDistributionType = -1;
invalidFrictionAngleDistribution.FrictionAngleShift = validShift;
yield return new TestCaseData(invalidFrictionAngleDistribution, "Wrijvingshoek"
- ).SetName(string.Format(testNameFormat, typeName, "Distribution"));
+ ).SetName(string.Format(testNameFormat, typeName));
- SoilLayerBase invalidShearStrengthRatioShift = soilLayer();
- invalidShearStrengthRatioShift.ShearStrengthRatioDistributionType = validDistributionType;
- invalidShearStrengthRatioShift.ShearStrengthRatioShift = -1;
- yield return new TestCaseData(invalidShearStrengthRatioShift, "Schuifsterkte ratio (S)"
- ).SetName(string.Format(testNameFormat, typeName, "Shift"));
-
SoilLayerBase invalidShearStrengthRatioDistribution = soilLayer();
invalidShearStrengthRatioDistribution.ShearStrengthRatioDistributionType = -1;
invalidShearStrengthRatioDistribution.ShearStrengthRatioShift = validShift;
yield return new TestCaseData(invalidShearStrengthRatioDistribution, "Schuifsterkte ratio (S)"
- ).SetName(string.Format(testNameFormat, typeName, "Distribution"));
+ ).SetName(string.Format(testNameFormat, typeName));
- SoilLayerBase invalidStrengthIncreaseExponentShift = soilLayer();
- invalidStrengthIncreaseExponentShift.StrengthIncreaseExponentDistributionType = validDistributionType;
- invalidStrengthIncreaseExponentShift.StrengthIncreaseExponentShift = -1;
- yield return new TestCaseData(invalidStrengthIncreaseExponentShift, "Sterkte toename exp (m)"
- ).SetName(string.Format(testNameFormat, typeName, "Shift"));
-
SoilLayerBase invalidStrengthIncreaseExponentDistribution = soilLayer();
invalidStrengthIncreaseExponentDistribution.StrengthIncreaseExponentDistributionType = -1;
invalidStrengthIncreaseExponentDistribution.StrengthIncreaseExponentShift = validShift;
yield return new TestCaseData(invalidStrengthIncreaseExponentDistribution, "Sterkte toename exp (m)"
- ).SetName(string.Format(testNameFormat, typeName, "Distribution"));
+ ).SetName(string.Format(testNameFormat, typeName));
- SoilLayerBase invalidPopShift = soilLayer();
- invalidPopShift.PopDistributionType = validDistributionType;
- invalidPopShift.PopShift = -1;
- yield return new TestCaseData(invalidPopShift, "POP"
- ).SetName(string.Format(testNameFormat, typeName, "Shift"));
-
SoilLayerBase invalidPopDistribution = soilLayer();
invalidPopDistribution.PopDistributionType = -1;
invalidPopDistribution.PopShift = validShift;
yield return new TestCaseData(invalidPopDistribution, "POP"
- ).SetName(string.Format(testNameFormat, typeName, "Distribution"));
+ ).SetName(string.Format(testNameFormat, typeName));
}
+ private static IEnumerable IncorrectNonShiftedLogNormalDistributionsShift(Func soilLayer, string typeName)
+ {
+ const string testNameFormat = "{0}Transform_IncorrectShift{{1}}_ThrowsImportedDataTransformException";
+ const long validDistributionType = SoilLayerConstants.LogNormalDistributionValue;
+
+ SoilLayerBase invalidCohesionShift = soilLayer();
+ invalidCohesionShift.CohesionDistributionType = validDistributionType;
+ invalidCohesionShift.CohesionShift = -1;
+ yield return new TestCaseData(invalidCohesionShift, "Cohesie"
+ ).SetName(string.Format(testNameFormat, typeName));
+
+ SoilLayerBase invalidFrictionAngleShift = soilLayer();
+ invalidFrictionAngleShift.FrictionAngleDistributionType = validDistributionType;
+ invalidFrictionAngleShift.FrictionAngleShift = -1;
+ yield return new TestCaseData(invalidFrictionAngleShift, "Wrijvingshoek"
+ ).SetName(string.Format(testNameFormat, typeName));
+
+ SoilLayerBase invalidShearStrengthRatioShift = soilLayer();
+ invalidShearStrengthRatioShift.ShearStrengthRatioDistributionType = validDistributionType;
+ invalidShearStrengthRatioShift.ShearStrengthRatioShift = -1;
+ yield return new TestCaseData(invalidShearStrengthRatioShift, "Schuifsterkte ratio (S)"
+ ).SetName(string.Format(testNameFormat, typeName));
+
+ SoilLayerBase invalidStrengthIncreaseExponentShift = soilLayer();
+ invalidStrengthIncreaseExponentShift.StrengthIncreaseExponentDistributionType = validDistributionType;
+ invalidStrengthIncreaseExponentShift.StrengthIncreaseExponentShift = -1;
+ yield return new TestCaseData(invalidStrengthIncreaseExponentShift, "Sterkte toename exp (m)"
+ ).SetName(string.Format(testNameFormat, typeName));
+
+ SoilLayerBase invalidPopShift = soilLayer();
+ invalidPopShift.PopDistributionType = validDistributionType;
+ invalidPopShift.PopShift = -1;
+ yield return new TestCaseData(invalidPopShift, "POP"
+ ).SetName(string.Format(testNameFormat, typeName));
+ }
+
#endregion
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilProfileTransformerTest.cs
===================================================================
diff -u -r6f92c6b83004d3de670def257b70157e1369da9a -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilProfileTransformerTest.cs (.../MacroStabilityInwardsSoilProfileTransformerTest.cs) (revision 6f92c6b83004d3de670def257b70157e1369da9a)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilProfileTransformerTest.cs (.../MacroStabilityInwardsSoilProfileTransformerTest.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -82,7 +82,8 @@
Exception innerException = exception.InnerException;
Assert.IsInstanceOf(innerException);
- Assert.AreEqual(innerException.Message, exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(profile.Name, innerException.Message);
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -117,8 +118,8 @@
var exception = Assert.Throws(call);
Exception innerException = exception.InnerException;
- Assert.IsInstanceOf(innerException);
- Assert.AreEqual(innerException.Message, exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(profile.Name, innerException.Message);
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -149,7 +150,7 @@
{
XCoordinate = random.NextDouble(),
ZCoordinate = random.NextDouble(),
- StressDistributionType = 3,
+ StressDistributionType = SoilLayerConstants.LogNormalDistributionValue,
StressMean = random.NextDouble(),
StressCoefficientOfVariation = random.NextDouble(),
StressShift = 0
@@ -170,6 +171,46 @@
AssertPreconsolidationStress(preconsolidationStress, transformedProfile.PreconsolidationStresses.Single());
}
+ [Test]
+ public void Transform_SoilProfile2DWithInvalidPreconsolidationStress_ThrowsImportedDataException()
+ {
+ var random = new Random(21);
+ var preconsolidationStress = new PreconsolidationStress
+ {
+ XCoordinate = double.NaN,
+ ZCoordinate = random.NextDouble(),
+ StressDistributionType = SoilLayerConstants.LogNormalDistributionValue,
+ StressMean = random.NextDouble(),
+ StressCoefficientOfVariation = random.NextDouble(),
+ StressShift = 0
+ };
+
+ var profile = new SoilProfile2D(1, "test", new[]
+ {
+ SoilLayer2DTestFactory.CreateSoilLayer2D()
+ }, new[]
+ {
+ preconsolidationStress
+ });
+
+ // Call
+ TestDelegate call = () => MacroStabilityInwardsSoilProfileTransformer.Transform(profile);
+
+ // Assert
+ var exception = Assert.Throws(call);
+
+ Exception innerException = exception.InnerException;
+ Assert.IsInstanceOf(innerException);
+ string expectedMessage = CreateExpectedErrorMessage(profile.Name, innerException.Message);
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ private static string CreateExpectedErrorMessage(string soilProfileName, string errorMessage)
+ {
+ return $"Er is een fout opgetreden bij het inlezen van ondergrondschematisatie '{soilProfileName}': " +
+ $"{errorMessage}";
+ }
+
private static void AssertPreconsolidationStress(PreconsolidationStress preconsolidationStress,
MacroStabilityInwardsPreconsolidationStress transformedPreconsolidationStress)
{
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs
===================================================================
diff -u -r94cb41fb18a59fc737dd3bcaf0e1898a3fadcaa5 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision 94cb41fb18a59fc737dd3bcaf0e1898a3fadcaa5)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -56,7 +56,7 @@
var pipingSoilLayer = new PipingSoilLayer(soilLayer.Top)
{
- IsAquifer = TransformIsAquifer(soilLayer.IsAquifer),
+ IsAquifer = TransformIsAquifer(soilLayer.IsAquifer, soilLayer.MaterialName),
MaterialName = soilLayer.MaterialName,
Color = SoilLayerColorConverter.Convert(soilLayer.Color)
};
@@ -79,7 +79,6 @@
public static IEnumerable Transform(SoilLayer2D soilLayer, double atX, out double bottom)
{
bottom = double.MaxValue;
-
var soilLayers = new Collection();
Transform(soilLayer, atX, soilLayers, ref bottom);
return soilLayers;
@@ -110,14 +109,17 @@
return;
}
- double[] outerLoopIntersectionHeights = GetLoopIntersectionHeights(soilLayer.OuterLoop.Segments, atX).ToArray();
+ string soilLayerName = soilLayer.MaterialName;
+ double[] outerLoopIntersectionHeights = GetLoopIntersectionHeights(soilLayer.OuterLoop.Segments, atX, soilLayerName).ToArray();
if (!outerLoopIntersectionHeights.Any())
{
return;
}
- IEnumerable> innerLoopsIntersectionHeights = soilLayer.NestedLayers.Select(l => GetLoopIntersectionHeights(l.OuterLoop.Segments, atX));
+ IEnumerable> innerLoopsIntersectionHeights = soilLayer.NestedLayers.Select(l => GetLoopIntersectionHeights(l.OuterLoop.Segments,
+ atX,
+ soilLayerName));
IEnumerable> innerLoopIntersectionHeightPairs = GetOrderedStartAndEndPairsIn1D(innerLoopsIntersectionHeights).ToList();
IEnumerable> outerLoopIntersectionHeightPairs = GetOrderedStartAndEndPairsIn1D(outerLoopIntersectionHeights).ToList();
@@ -130,7 +132,7 @@
{
var pipingSoilLayer = new PipingSoilLayer(height)
{
- IsAquifer = TransformIsAquifer(soilLayer.IsAquifer),
+ IsAquifer = TransformIsAquifer(soilLayer.IsAquifer, soilLayerName),
MaterialName = soilLayer.MaterialName,
Color = SoilLayerColorConverter.Convert(soilLayer.Color)
};
@@ -156,35 +158,44 @@
/// stochastic parameters is not defined as lognormal or is shifted when it should not be.
private static void ValidateStochasticParameters(SoilLayerBase soilLayer)
{
- DistributionHelper.ValidateIsLogNormal(
- soilLayer.BelowPhreaticLevelDistributionType,
- Resources.SoilLayer_BelowPhreaticLevelDistribution_DisplayName);
- DistributionHelper.ValidateIsNonShiftedLogNormal(
- soilLayer.DiameterD70DistributionType,
- soilLayer.DiameterD70Shift,
- Resources.SoilLayer_DiameterD70Distribution_DisplayName);
- DistributionHelper.ValidateIsNonShiftedLogNormal(
- soilLayer.PermeabilityDistributionType,
- soilLayer.PermeabilityShift,
- Resources.SoilLayer_PermeabilityDistribution_DisplayName);
+ try
+ {
+ DistributionHelper.ValidateShiftedLogNormalDistribution(
+ soilLayer.BelowPhreaticLevelDistributionType,
+ Resources.SoilLayer_BelowPhreaticLevelDistribution_DisplayName);
+ DistributionHelper.ValidateLogNormalDistribution(
+ soilLayer.DiameterD70DistributionType,
+ soilLayer.DiameterD70Shift,
+ Resources.SoilLayer_DiameterD70Distribution_DisplayName);
+ DistributionHelper.ValidateLogNormalDistribution(
+ soilLayer.PermeabilityDistributionType,
+ soilLayer.PermeabilityShift,
+ Resources.SoilLayer_PermeabilityDistribution_DisplayName);
+ }
+ catch (ImportedDataTransformException e)
+ {
+ string errorMessage = CreateExceptionMessage(soilLayer.MaterialName,
+ e.Message);
+ throw new ImportedDataTransformException(errorMessage, e);
+ }
}
///
/// Sets the values of the stochastic parameters for the given .
///
/// The to set the property values for.
- /// The to get the properties from.
+ /// The to get the properties from.
/// This method does not perform validation. Use to
/// verify whether the distributions for the stochastic parameters are correctly defined.
- private static void SetStochasticParameters(PipingSoilLayer pipingSoilLayer, SoilLayerBase soilLayer1D)
+ private static void SetStochasticParameters(PipingSoilLayer pipingSoilLayer, SoilLayerBase soilLayer)
{
- pipingSoilLayer.BelowPhreaticLevelMean = soilLayer1D.BelowPhreaticLevelMean;
- pipingSoilLayer.BelowPhreaticLevelDeviation = soilLayer1D.BelowPhreaticLevelDeviation;
- pipingSoilLayer.BelowPhreaticLevelShift = soilLayer1D.BelowPhreaticLevelShift;
- pipingSoilLayer.DiameterD70Mean = soilLayer1D.DiameterD70Mean;
- pipingSoilLayer.DiameterD70CoefficientOfVariation = soilLayer1D.DiameterD70CoefficientOfVariation;
- pipingSoilLayer.PermeabilityMean = soilLayer1D.PermeabilityMean;
- pipingSoilLayer.PermeabilityCoefficientOfVariation = soilLayer1D.PermeabilityCoefficientOfVariation;
+ pipingSoilLayer.BelowPhreaticLevelMean = soilLayer.BelowPhreaticLevelMean;
+ pipingSoilLayer.BelowPhreaticLevelDeviation = soilLayer.BelowPhreaticLevelDeviation;
+ pipingSoilLayer.BelowPhreaticLevelShift = soilLayer.BelowPhreaticLevelShift;
+ pipingSoilLayer.DiameterD70Mean = soilLayer.DiameterD70Mean;
+ pipingSoilLayer.DiameterD70CoefficientOfVariation = soilLayer.DiameterD70CoefficientOfVariation;
+ pipingSoilLayer.PermeabilityMean = soilLayer.PermeabilityMean;
+ pipingSoilLayer.PermeabilityCoefficientOfVariation = soilLayer.PermeabilityCoefficientOfVariation;
}
private static bool HeightInInnerLoop(Tuple tuple, double height)
@@ -224,21 +235,32 @@
///
/// The sequence of which together create a loop.
/// The point on the x-axis where the vertical line is constructed do determine intersections with.
+ /// The name of the soil layer.
/// A of , representing the height at which the
/// intersects the vertical line at .
/// Thrown when a segment is vertical at and thus
/// no deterministic intersection points can be determined.
- private static IEnumerable GetLoopIntersectionHeights(IEnumerable loop, double atX)
+ private static IEnumerable GetLoopIntersectionHeights(IEnumerable loop,
+ double atX,
+ string soilLayerName)
{
Segment2D[] segment2Ds = loop.ToArray();
if (segment2Ds.Any(segment => IsVerticalAtX(segment, atX)))
{
- string message = string.Format(Resources.Error_Can_not_determine_1D_profile_with_vertical_segments_at_X_0_, atX);
+ string message = CreateExceptionMessage(soilLayerName,
+ string.Format(Resources.Error_Can_not_determine_1D_profile_with_vertical_segments_at_X_0_, atX));
throw new ImportedDataTransformException(message);
}
return Math2D.SegmentsIntersectionWithVerticalLine(segment2Ds, atX).Select(p => p.Y);
}
+ private static string CreateExceptionMessage(string soilLayerName, string errorMessage)
+ {
+ return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilLayer_0_ErrorMessage_1_,
+ soilLayerName,
+ errorMessage);
+ }
+
private static bool IsVerticalAtX(Segment2D segment, double atX)
{
return segment.FirstPoint.X.Equals(atX) && segment.IsVertical();
@@ -249,19 +271,22 @@
/// .
///
/// The value to transform.
+ /// The name of the soil layer.
/// A based on .
/// Thrown when
/// could not be transformed.
- private static bool TransformIsAquifer(double? isAquifer)
+ private static bool TransformIsAquifer(double? isAquifer, string soilLayerName)
{
try
{
return SoilLayerIsAquiferConverter.Convert(isAquifer);
}
- catch (NotSupportedException)
+ catch (NotSupportedException e)
{
- throw new ImportedDataTransformException(string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0,
- RingtoetsCommonIOResources.SoilLayerData_IsAquifer_DisplayName));
+ string message = CreateExceptionMessage(soilLayerName,
+ string.Format(RingtoetsCommonIOResources.Transform_Invalid_value_ParameterName_0,
+ RingtoetsCommonIOResources.SoilLayerData_IsAquifer_DisplayName));
+ throw new ImportedDataTransformException(message, e);
}
}
}
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilProfileTransformer.cs
===================================================================
diff -u -rd0d3ed3067ec66c52283bd4d1c44011b1a412492 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilProfileTransformer.cs (.../PipingSoilProfileTransformer.cs) (revision d0d3ed3067ec66c52283bd4d1c44011b1a412492)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilProfileTransformer.cs (.../PipingSoilProfileTransformer.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -112,7 +112,8 @@
}
catch (ArgumentException e)
{
- throw new ImportedDataTransformException(e.Message, e);
+ string message = CreateErrorMessage(soilProfile2D.Name, e.Message);
+ throw new ImportedDataTransformException(message, e);
}
}
@@ -136,8 +137,14 @@
}
catch (ArgumentException e)
{
- throw new ImportedDataTransformException(e.Message, e);
+ string message = CreateErrorMessage(soilProfile1D.Name, e.Message);
+ throw new ImportedDataTransformException(message, e);
}
}
+
+ private static string CreateErrorMessage(string soilProfileName, string errorMessage)
+ {
+ return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilProfile_0_ErrorMessage_1_, soilProfileName, errorMessage);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs
===================================================================
diff -u -r94cb41fb18a59fc737dd3bcaf0e1898a3fadcaa5 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs (.../PipingSoilLayerTransformerTest.cs) (revision 94cb41fb18a59fc737dd3bcaf0e1898a3fadcaa5)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs (.../PipingSoilLayerTransformerTest.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -95,7 +95,10 @@
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("Ongeldige waarde voor parameter 'Is aquifer'.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Ongeldige waarde voor parameter 'Is aquifer'.");
+ Assert.AreEqual(expectedMessage, exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
}
[Test]
@@ -195,30 +198,49 @@
// Setup
var layer = new SoilLayer1D(0.0)
{
- BelowPhreaticLevelDistributionType = -1
+ BelowPhreaticLevelDistributionType = -1,
+ MaterialName = nameof(SoilLayer1D)
};
// Call
TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer);
// Assert
Exception exception = Assert.Throws(test);
- Assert.AreEqual("Parameter 'Verzadigd gewicht' is niet verschoven lognormaal verdeeld.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Parameter 'Verzadigd gewicht' moet verschoven lognormaal verdeeld zijn.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
- [TestCaseSource(nameof(IncorrectLogNormalDistributionsSoilLayer1D))]
- public void SoilLayer1DTransform_IncorrectLogNormalDistribution_ThrowsImportedDataTransformException(SoilLayer1D layer, string parameter)
+ [TestCaseSource(nameof(IncorrectLogNormalDistributionsTypeSoilLayer1D))]
+ public void SoilLayer1DTransform_IncorrectLogNormalDistributionType_ThrowsImportedDataTransformException(SoilLayer1D layer, string parameter)
{
// Call
TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer);
// Assert
Exception exception = Assert.Throws(test);
- Assert.AreEqual($"Parameter '{parameter}' is niet lognormaal verdeeld.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet lognormaal verdeeld zijn.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
+ [TestCaseSource(nameof(IncorrectLogNormalDistributionsShiftSoilLayer1D))]
+ public void SoilLayer1DTransform_IncorrectLogNormalDistributionShift_ThrowsImportedDataTransformException(SoilLayer1D layer, string parameter)
+ {
+ // Call
+ TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer);
+
+ // Assert
+ Exception exception = Assert.Throws(test);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.");
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
+ [Test]
public void SoilLayer2DTransform_SoilLayer2DNull_ThrowsArgumentNullException()
{
// Setup
@@ -373,8 +395,10 @@
// Assert
var exception = Assert.Throws(call);
- Assert.AreEqual("Ongeldige waarde voor parameter 'Is aquifer'.", exception.Message);
-
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Ongeldige waarde voor parameter 'Is aquifer'.");
+ Assert.AreEqual(expectedMessage, exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
Assert.IsNull(pipingSoilLayers);
}
@@ -918,7 +942,9 @@
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual($"Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D laag verticaal lopen op de gekozen positie: x = {atX}.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D laag verticaal lopen op de gekozen positie: x = {atX}.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -951,7 +977,9 @@
// Assert
var exception = Assert.Throws(test);
- Assert.AreEqual($"Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D laag verticaal lopen op de gekozen positie: x = {atX}.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D laag verticaal lopen op de gekozen positie: x = {atX}.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -969,12 +997,14 @@
// Assert
Exception exception = Assert.Throws(test);
- Assert.AreEqual("Parameter 'Verzadigd gewicht' is niet verschoven lognormaal verdeeld.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ "Parameter 'Verzadigd gewicht' moet verschoven lognormaal verdeeld zijn.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
- [TestCaseSource(nameof(IncorrectLogNormalDistributionsSoilLayer2D))]
- public void SoilLayer2DTransform_IncorrectLogNormalDistribution_ThrowsImportedDataTransformException(SoilLayer2D layer, string parameter)
+ [TestCaseSource(nameof(IncorrectLogNormalDistributionsTypeSoilLayer2D))]
+ public void SoilLayer2DTransform_IncorrectLogNormalDistributionType_ThrowsImportedDataTransformException(SoilLayer2D layer, string parameter)
{
// Setup
double bottom;
@@ -984,9 +1014,28 @@
// Assert
Exception exception = Assert.Throws(test);
- Assert.AreEqual($"Parameter '{parameter}' is niet lognormaal verdeeld.", exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet lognormaal verdeeld zijn.");
+ Assert.AreEqual(expectedMessage, exception.Message);
}
+ [Test]
+ [TestCaseSource(nameof(IncorrectLogNormalDistributionsShiftSoilLayer2D))]
+ public void SoilLayer2DTransform_IncorrectLogNormalDistributionShift_ThrowsImportedDataTransformException(SoilLayer2D layer, string parameter)
+ {
+ // Setup
+ double bottom;
+
+ // Call
+ TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer, 0, out bottom);
+
+ // Assert
+ Exception exception = Assert.Throws(test);
+ string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName,
+ $"Parameter '{parameter}' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.");
+ Assert.AreEqual(expectedMessage, exception.Message);
+ }
+
private static SoilLayer2D CreateValidConfiguredSoilLayer2D(double x1, double x3)
{
var random = new Random(21);
@@ -1007,19 +1056,29 @@
return SoilLayer2DTestFactory.CreateSoilLayer2D(Enumerable.Empty>(), outerLoop);
}
- private static IEnumerable IncorrectLogNormalDistributionsSoilLayer1D()
+ private static IEnumerable IncorrectLogNormalDistributionsTypeSoilLayer1D()
{
- return IncorrectLogNormalDistributions(() => new SoilLayer1D(0.0), nameof(SoilLayer1D));
+ return IncorrectLogNormalDistributionsType(() => new SoilLayer1D(0.0), nameof(SoilLayer1D));
}
- private static IEnumerable IncorrectLogNormalDistributionsSoilLayer2D()
+ private static IEnumerable IncorrectLogNormalDistributionsShiftSoilLayer1D()
{
- return IncorrectLogNormalDistributions(SoilLayer2DTestFactory.CreateSoilLayer2D, nameof(SoilLayer2D));
+ return IncorrectLogNormalDistributionsShift(() => new SoilLayer1D(0.0), nameof(SoilLayer1D));
}
- private static IEnumerable IncorrectLogNormalDistributions(Func soilLayer, string typeName)
+ private static IEnumerable IncorrectLogNormalDistributionsTypeSoilLayer2D()
{
- const string testNameFormat = "{0}Transform_Incorrect{1}{{1}}_ThrowsImportedDataTransformException";
+ return IncorrectLogNormalDistributionsType(SoilLayer2DTestFactory.CreateSoilLayer2D, nameof(SoilLayer2D));
+ }
+
+ private static IEnumerable IncorrectLogNormalDistributionsShiftSoilLayer2D()
+ {
+ return IncorrectLogNormalDistributionsShift(SoilLayer2DTestFactory.CreateSoilLayer2D, nameof(SoilLayer2D));
+ }
+
+ private static IEnumerable IncorrectLogNormalDistributionsType(Func soilLayer, string typeName)
+ {
+ const string testNameFormat = "{0}Transform_IncorrectDistribution{{1}}_ThrowsImportedDataTransformException";
const long validDistributionType = SoilLayerConstants.LogNormalDistributionValue;
const double validShift = 0.0;
@@ -1031,18 +1090,8 @@
invalidDiameterD70Distribution.PermeabilityShift = validShift;
yield return new TestCaseData(invalidDiameterD70Distribution, "Korrelgrootte"
- ).SetName(string.Format(testNameFormat, typeName, "Distribution"));
+ ).SetName(string.Format(testNameFormat, typeName));
- SoilLayerBase invalidDiameterD70Shift = soilLayer();
- invalidDiameterD70Shift.BelowPhreaticLevelDistributionType = validDistributionType;
- invalidDiameterD70Shift.DiameterD70DistributionType = validDistributionType;
- invalidDiameterD70Shift.DiameterD70Shift = -1;
- invalidDiameterD70Shift.PermeabilityDistributionType = validDistributionType;
- invalidDiameterD70Shift.PermeabilityShift = validShift;
-
- yield return new TestCaseData(invalidDiameterD70Shift, "Korrelgrootte"
- ).SetName(string.Format(testNameFormat, typeName, "Shift"));
-
SoilLayerBase invalidPermeabilityDistribution = soilLayer();
invalidPermeabilityDistribution.BelowPhreaticLevelDistributionType = validDistributionType;
invalidPermeabilityDistribution.DiameterD70DistributionType = validDistributionType;
@@ -1051,8 +1100,25 @@
invalidPermeabilityDistribution.PermeabilityShift = validShift;
yield return new TestCaseData(invalidPermeabilityDistribution, "Doorlatendheid"
- ).SetName(string.Format(testNameFormat, typeName, "Distribution"));
+ ).SetName(string.Format(testNameFormat, typeName));
+ }
+ private static IEnumerable IncorrectLogNormalDistributionsShift(Func soilLayer, string typeName)
+ {
+ const string testNameFormat = "{0}Transform_IncorrectShift{{1}}_ThrowsImportedDataTransformException";
+ const long validDistributionType = SoilLayerConstants.LogNormalDistributionValue;
+ const double validShift = 0.0;
+
+ SoilLayerBase invalidDiameterD70Shift = soilLayer();
+ invalidDiameterD70Shift.BelowPhreaticLevelDistributionType = validDistributionType;
+ invalidDiameterD70Shift.DiameterD70DistributionType = validDistributionType;
+ invalidDiameterD70Shift.DiameterD70Shift = -1;
+ invalidDiameterD70Shift.PermeabilityDistributionType = validDistributionType;
+ invalidDiameterD70Shift.PermeabilityShift = validShift;
+
+ yield return new TestCaseData(invalidDiameterD70Shift, "Korrelgrootte"
+ ).SetName(string.Format(testNameFormat, typeName));
+
SoilLayerBase invalidPermeabilityShift = soilLayer();
invalidPermeabilityShift.BelowPhreaticLevelDistributionType = validDistributionType;
invalidPermeabilityShift.DiameterD70DistributionType = validDistributionType;
@@ -1061,9 +1127,14 @@
invalidPermeabilityShift.PermeabilityShift = -1;
yield return new TestCaseData(invalidPermeabilityShift, "Doorlatendheid"
- ).SetName(string.Format(testNameFormat, typeName, "Shift"));
+ ).SetName(string.Format(testNameFormat, typeName));
}
+ private static string CreateExpectedErrorMessage(string materialName, string errorMessage)
+ {
+ return $"Er is een fout opgetreden bij het inlezen van grondlaag '{materialName}': {errorMessage}";
+ }
+
private static IEnumerable GetColorCases()
{
yield return new TestCaseData(null, Color.Empty)
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilProfileTransformerTest.cs
===================================================================
diff -u -r94cb41fb18a59fc737dd3bcaf0e1898a3fadcaa5 -r9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilProfileTransformerTest.cs (.../PipingSoilProfileTransformerTest.cs) (revision 94cb41fb18a59fc737dd3bcaf0e1898a3fadcaa5)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilProfileTransformerTest.cs (.../PipingSoilProfileTransformerTest.cs) (revision 9c8f63537efbe5c5efb2b2bc066bc7e7358d3cab)
@@ -153,7 +153,8 @@
// Assert
var exception = Assert.Throws(test);
- string message = "Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D " +
+ string message = $"Er is een fout opgetreden bij het inlezen van grondlaag '{layer.MaterialName}': " +
+ "Er kan geen 1D-profiel bepaald worden wanneer segmenten in een 2D " +
$"laag verticaal lopen op de gekozen positie: x = {atX}.";
Assert.AreEqual(message, exception.Message);
}
@@ -182,7 +183,7 @@
{
// Setup
var random = new Random(21);
- var profile = new SoilProfile2D(0, string.Empty, Enumerable.Empty(), Enumerable.Empty())
+ var profile = new SoilProfile2D(0, "A profile name", Enumerable.Empty(), Enumerable.Empty())
{
IntersectionX = random.NextDouble()
};
@@ -195,7 +196,8 @@
Exception innerException = exception.InnerException;
Assert.IsInstanceOf(innerException);
- Assert.AreEqual(innerException.Message, exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(profile.Name, innerException.Message);
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -393,7 +395,8 @@
Exception innerException = exception.InnerException;
Assert.IsInstanceOf(innerException);
- Assert.AreEqual(innerException.Message, exception.Message);
+ string expectedMessage = CreateExpectedErrorMessage(profileName, innerException.Message);
+ Assert.AreEqual(expectedMessage, exception.Message);
}
[Test]
@@ -458,6 +461,12 @@
Assert.AreEqual(bottom, transformed.Bottom);
}
+ private static string CreateExpectedErrorMessage(string soilProfileName, string errorMessage)
+ {
+ return $"Er is een fout opgetreden bij het inlezen van ondergrondschematisatie '{soilProfileName}': " +
+ $"{errorMessage}";
+ }
+
private static void AssertPipingSoilLayers(IEnumerable expectedSoilLayer2Ds,
IEnumerable actualSoilLayer2Ds)
{