Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs =================================================================== diff -u -r1fb8f412abb01d504e4f546dfed0ca365c1984ae -r8cdbb1c76ccda6f711ec3bb02339896e7eb660c0 --- 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 8cdbb1c76ccda6f711ec3bb02339896e7eb660c0) @@ -298,22 +298,34 @@ // Assert Exception exception = Assert.Throws(test); - Assert.AreEqual($"Parameter '{parameter}' is niet verschoven lognormaal verdeeld.", exception.Message); + Assert.AreEqual($"Parameter '{parameter}' moet verschoven lognormaal verdeeld zijn.", 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); + Assert.AreEqual($"Parameter '{parameter}' moet lognormaal verdeeld zijn.", 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); + Assert.AreEqual($"Parameter '{parameter}' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.", exception.Message); + } + + [Test] public void SoilLayer2DTransform_SoilLayer2DNull_ThrowsArgumentNullException() { // Call @@ -497,7 +509,7 @@ } [Test] - [TestCaseSource(nameof(IncorrectShiftedLogNormalDistributionsSoilLayer2D))] + [TestCaseSource(nameof(IncorrectShiftedLogNormalDistributionsTypeSoilLayer2D))] public void SoilLayer2DTransform_IncorrectShiftedLogNormalDistribution_ThrowsImportedDataTransformException( SoilLayer2D layer, string parameter) { @@ -506,22 +518,34 @@ // Assert Exception exception = Assert.Throws(test); - Assert.AreEqual($"Parameter '{parameter}' is niet verschoven lognormaal verdeeld.", exception.Message); + Assert.AreEqual($"Parameter '{parameter}' moet verschoven lognormaal verdeeld zijn.", 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); + Assert.AreEqual($"Parameter '{parameter}' moet lognormaal verdeeld zijn.", 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); + Assert.AreEqual($"Parameter '{parameter}' moet lognormaal verdeeld zijn met een verschuiving gelijk aan 0.", exception.Message); + } + + [Test] [TestCaseSource(nameof(GetSoilLayerWithInvalidGeometry))] public void SoilLayer2DTransform_SoilLayer2DWithInvalidLoops_ThrowsImportedDataException(SoilLayer2D soilLayer) { @@ -702,107 +726,122 @@ 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