Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs =================================================================== diff -u -r4527fba69ffc2609b555916097c97da212acd96a -r38940fd430501da3c19ac8c90f660b21f8938909 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs (.../PipingSoilLayerTransformerTest.cs) (revision 4527fba69ffc2609b555916097c97da212acd96a) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs (.../PipingSoilLayerTransformerTest.cs) (revision 38940fd430501da3c19ac8c90f660b21f8938909) @@ -95,10 +95,7 @@ // Assert var exception = Assert.Throws(call); - string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName, - "Ongeldige waarde voor parameter 'Is aquifer'."); - Assert.AreEqual(expectedMessage, exception.Message); - Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual("Ongeldige waarde voor parameter 'Is aquifer'.", exception.Message); } [Test] @@ -198,49 +195,30 @@ // Setup var layer = new SoilLayer1D(0.0) { - BelowPhreaticLevelDistributionType = -1, - MaterialName = nameof(SoilLayer1D) + BelowPhreaticLevelDistributionType = -1 }; // Call TestDelegate test = () => PipingSoilLayerTransformer.Transform(layer); // Assert Exception exception = Assert.Throws(test); - string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName, - "Parameter 'Verzadigd gewicht' moet verschoven lognormaal verdeeld zijn."); - Assert.AreEqual(expectedMessage, exception.Message); + Assert.AreEqual("Parameter 'Verzadigd gewicht' is niet verschoven lognormaal verdeeld.", exception.Message); } [Test] - [TestCaseSource(nameof(IncorrectLogNormalDistributionsTypeSoilLayer1D))] - public void SoilLayer1DTransform_IncorrectLogNormalDistributionType_ThrowsImportedDataTransformException(SoilLayer1D layer, string parameter) + [TestCaseSource(nameof(IncorrectLogNormalDistributionsSoilLayer1D))] + public void SoilLayer1DTransform_IncorrectLogNormalDistribution_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."); - Assert.AreEqual(expectedMessage, exception.Message); + Assert.AreEqual($"Parameter '{parameter}' is niet lognormaal verdeeld.", 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 @@ -395,10 +373,8 @@ // Assert var exception = Assert.Throws(call); - string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName, - "Ongeldige waarde voor parameter 'Is aquifer'."); - Assert.AreEqual(expectedMessage, exception.Message); - Assert.IsInstanceOf(exception.InnerException); + Assert.AreEqual("Ongeldige waarde voor parameter 'Is aquifer'.", exception.Message); + Assert.IsNull(pipingSoilLayers); } @@ -942,9 +918,7 @@ // Assert var exception = Assert.Throws(test); - 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); + 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); } [Test] @@ -977,9 +951,7 @@ // Assert var exception = Assert.Throws(test); - 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); + 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); } [Test] @@ -997,14 +969,12 @@ // Assert Exception exception = Assert.Throws(test); - string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName, - "Parameter 'Verzadigd gewicht' moet verschoven lognormaal verdeeld zijn."); - Assert.AreEqual(expectedMessage, exception.Message); + Assert.AreEqual("Parameter 'Verzadigd gewicht' is niet verschoven lognormaal verdeeld.", exception.Message); } [Test] - [TestCaseSource(nameof(IncorrectLogNormalDistributionsTypeSoilLayer2D))] - public void SoilLayer2DTransform_IncorrectLogNormalDistributionType_ThrowsImportedDataTransformException(SoilLayer2D layer, string parameter) + [TestCaseSource(nameof(IncorrectLogNormalDistributionsSoilLayer2D))] + public void SoilLayer2DTransform_IncorrectLogNormalDistribution_ThrowsImportedDataTransformException(SoilLayer2D layer, string parameter) { // Setup double bottom; @@ -1014,28 +984,9 @@ // Assert Exception exception = Assert.Throws(test); - string expectedMessage = CreateExpectedErrorMessage(layer.MaterialName, - $"Parameter '{parameter}' moet lognormaal verdeeld zijn."); - Assert.AreEqual(expectedMessage, exception.Message); + Assert.AreEqual($"Parameter '{parameter}' is niet lognormaal verdeeld.", 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); @@ -1056,29 +1007,19 @@ return SoilLayer2DTestFactory.CreateSoilLayer2D(Enumerable.Empty>(), outerLoop); } - private static IEnumerable IncorrectLogNormalDistributionsTypeSoilLayer1D() + private static IEnumerable IncorrectLogNormalDistributionsSoilLayer1D() { - return IncorrectLogNormalDistributionsType(() => new SoilLayer1D(0.0), nameof(SoilLayer1D)); + return IncorrectLogNormalDistributions(() => new SoilLayer1D(0.0), nameof(SoilLayer1D)); } - private static IEnumerable IncorrectLogNormalDistributionsShiftSoilLayer1D() + private static IEnumerable IncorrectLogNormalDistributionsSoilLayer2D() { - return IncorrectLogNormalDistributionsShift(() => new SoilLayer1D(0.0), nameof(SoilLayer1D)); + return IncorrectLogNormalDistributions(SoilLayer2DTestFactory.CreateSoilLayer2D, nameof(SoilLayer2D)); } - private static IEnumerable IncorrectLogNormalDistributionsTypeSoilLayer2D() + private static IEnumerable IncorrectLogNormalDistributions(Func soilLayer, string typeName) { - 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 string testNameFormat = "{0}Transform_Incorrect{1}{{1}}_ThrowsImportedDataTransformException"; const long validDistributionType = SoilLayerConstants.LogNormalDistributionValue; const double validShift = 0.0; @@ -1090,25 +1031,8 @@ invalidDiameterD70Distribution.PermeabilityShift = validShift; yield return new TestCaseData(invalidDiameterD70Distribution, "Korrelgrootte" - ).SetName(string.Format(testNameFormat, typeName)); + ).SetName(string.Format(testNameFormat, typeName, "Distribution")); - SoilLayerBase invalidPermeabilityDistribution = soilLayer(); - invalidPermeabilityDistribution.BelowPhreaticLevelDistributionType = validDistributionType; - invalidPermeabilityDistribution.DiameterD70DistributionType = validDistributionType; - invalidPermeabilityDistribution.DiameterD70Shift = validShift; - invalidPermeabilityDistribution.PermeabilityDistributionType = -1; - invalidPermeabilityDistribution.PermeabilityShift = validShift; - - yield return new TestCaseData(invalidPermeabilityDistribution, "Doorlatendheid" - ).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; @@ -1117,8 +1041,18 @@ invalidDiameterD70Shift.PermeabilityShift = validShift; yield return new TestCaseData(invalidDiameterD70Shift, "Korrelgrootte" - ).SetName(string.Format(testNameFormat, typeName)); + ).SetName(string.Format(testNameFormat, typeName, "Shift")); + SoilLayerBase invalidPermeabilityDistribution = soilLayer(); + invalidPermeabilityDistribution.BelowPhreaticLevelDistributionType = validDistributionType; + invalidPermeabilityDistribution.DiameterD70DistributionType = validDistributionType; + invalidPermeabilityDistribution.DiameterD70Shift = validShift; + invalidPermeabilityDistribution.PermeabilityDistributionType = -1; + invalidPermeabilityDistribution.PermeabilityShift = validShift; + + yield return new TestCaseData(invalidPermeabilityDistribution, "Doorlatendheid" + ).SetName(string.Format(testNameFormat, typeName, "Distribution")); + SoilLayerBase invalidPermeabilityShift = soilLayer(); invalidPermeabilityShift.BelowPhreaticLevelDistributionType = validDistributionType; invalidPermeabilityShift.DiameterD70DistributionType = validDistributionType; @@ -1127,14 +1061,9 @@ invalidPermeabilityShift.PermeabilityShift = -1; yield return new TestCaseData(invalidPermeabilityShift, "Doorlatendheid" - ).SetName(string.Format(testNameFormat, typeName)); + ).SetName(string.Format(testNameFormat, typeName, "Shift")); } - 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)