Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -r4527fba69ffc2609b555916097c97da212acd96a -r9f9b40be8a207b1d4ff944bee747f472a64077a7
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 4527fba69ffc2609b555916097c97da212acd96a)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 9f9b40be8a207b1d4ff944bee747f472a64077a7)
@@ -2547,13 +2547,22 @@
///
/// 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 {
+ 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);
+ 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 -rc71efcd328d420bd869028dd35d035ff02d98ec2 -r9f9b40be8a207b1d4ff944bee747f472a64077a7
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision c71efcd328d420bd869028dd35d035ff02d98ec2)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 9f9b40be8a207b1d4ff944bee747f472a64077a7)
@@ -880,7 +880,10 @@
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/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs
===================================================================
diff -u -r4527fba69ffc2609b555916097c97da212acd96a -r9f9b40be8a207b1d4ff944bee747f472a64077a7
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs (.../MacroStabilityInwardsSoilLayerTransformer.cs) (revision 4527fba69ffc2609b555916097c97da212acd96a)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs (.../MacroStabilityInwardsSoilLayerTransformer.cs) (revision 9f9b40be8a207b1d4ff944bee747f472a64077a7)
@@ -373,7 +373,7 @@
private static string CreateErrorMessage(string soilLayerName, string errorMessage)
{
- return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilLayer_0_ErrorMessage_1,
+ return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilLayer_0_ErrorMessage_1_,
soilLayerName,
errorMessage);
}
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs
===================================================================
diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -r9f9b40be8a207b1d4ff944bee747f472a64077a7
--- 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 9f9b40be8a207b1d4ff944bee747f472a64077a7)
@@ -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/MacroStabilityInwardsSoilProfileTransformerTest.cs
===================================================================
diff -u -r6f92c6b83004d3de670def257b70157e1369da9a -r9f9b40be8a207b1d4ff944bee747f472a64077a7
--- 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 9f9b40be8a207b1d4ff944bee747f472a64077a7)
@@ -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 -r4527fba69ffc2609b555916097c97da212acd96a -r9f9b40be8a207b1d4ff944bee747f472a64077a7
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision 4527fba69ffc2609b555916097c97da212acd96a)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision 9f9b40be8a207b1d4ff944bee747f472a64077a7)
@@ -256,7 +256,7 @@
private static string CreateExceptionMessage(string soilLayerName, string errorMessage)
{
- return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilLayer_0_ErrorMessage_1,
+ return string.Format(RingtoetsCommonIOResources.Transform_Error_occurred_when_transforming_SoilLayer_0_ErrorMessage_1_,
soilLayerName,
errorMessage);
}