Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformerTest.cs =================================================================== diff -u -r9622873faf35255d36a4543501d4788baa399af7 -r76aba900dac58a4328145a2946b774ebd4a37aa5 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformerTest.cs (.../MacroStabilityInwardsStochasticSoilModelTransformerTest.cs) (revision 9622873faf35255d36a4543501d4788baa399af7) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformerTest.cs (.../MacroStabilityInwardsStochasticSoilModelTransformerTest.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.Linq; using Core.Common.Base.Geometry; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.IO.Exceptions; using Ringtoets.Common.IO.SoilProfile; @@ -208,6 +209,88 @@ Assert.AreSame(stochasticSoilProfile1.SoilProfile, stochasticSoilProfile2.SoilProfile); } + [Test] + public void Transform_ValidStochasticSoilModelWithSameProfileInTwoStochasticSoilProfiles_ReturnsExpectedPipingStochasticSoilModel() + { + // Setup + const string soilModelName = "name"; + const string soilProfileName = "SoilProfile"; + const double intersectionX = 1.0; + + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2D(); + var profile = new SoilProfile2D(0, soilProfileName, new[] + { + layer + }) + { + IntersectionX = intersectionX + }; + + var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer(); + var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Stability) + { + StochasticSoilProfiles = + { + new StochasticSoilProfile(0.2, profile), + new StochasticSoilProfile(0.7, profile) + } + }; + + MacroStabilityInwardsStochasticSoilModel transformed = null; + + // Call + Action call = () => transformed = transformer.Transform(soilModel); + + // Assert + string expectedMessage = $"Ondergrondschematisatie '{soilProfileName}' is meerdere keren gevonden in ondergrondmodel '{soilModelName}'. " + + "Kansen van voorkomen worden opgeteld."; + TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Warn)); + List transformedStochasticSoilProfiles = transformed.StochasticSoilProfiles; + Assert.AreEqual(1, transformedStochasticSoilProfiles.Count); + Assert.AreEqual(0.9, transformedStochasticSoilProfiles[0].Probability, 1e-6); + } + + [Test] + public void Transform_ValidStochasticSoilModelWithSimilarProfileInTwoStochasticSoilProfiles_ReturnsExpectedPipingStochasticSoilModel() + { + // Setup + const string soilModelName = "name"; + const string soilProfileName = "SoilProfile"; + const double intersectionX = 1.0; + + var soilProfile2D = new SoilProfile2D(0, soilProfileName, new[] + { + SoilLayer2DTestFactory.CreateSoilLayer2D() + }) + { + IntersectionX = intersectionX + }; + + var soilProfile1D = new SoilProfile1D(0, soilProfileName, 0, new[] + { + new SoilLayer1D(1) + }); + + var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer(); + var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Stability) + { + StochasticSoilProfiles = + { + new StochasticSoilProfile(0.2, soilProfile2D), + new StochasticSoilProfile(0.7, soilProfile1D) + } + }; + + // Call + MacroStabilityInwardsStochasticSoilModel transformed = transformer.Transform(soilModel); + + // Assert + List transformedStochasticSoilProfiles = transformed.StochasticSoilProfiles; + Assert.AreEqual(2, transformedStochasticSoilProfiles.Count); + Assert.AreEqual(0.2, transformedStochasticSoilProfiles[0].Probability, 1e-6); + Assert.AreEqual(0.7, transformedStochasticSoilProfiles[1].Probability, 1e-6); + } + private static void AssertStochasticSoilProfile(MacroStabilityInwardsStochasticSoilProfile expected, MacroStabilityInwardsStochasticSoilProfile actual) {