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) {