Index: Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs
===================================================================
diff -u -ra30271e26ecc2c171e2133fe0aace8556d0b504e -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision a30271e26ecc2c171e2133fe0aace8556d0b504e)
+++ Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -1,25 +1,4 @@
-// Copyright (C) Stichting Deltares 2017. All rights reserved.
-//
-// This file is part of Ringtoets.
-//
-// Ringtoets is free software: you can redistribute it and/or modify
-// it under the terms of the GNU Lesser General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU Lesser General Public License for more details.
-//
-// You should have received a copy of the GNU Lesser General Public License
-// along with this program. If not, see .
-//
-// All names, logos, and references to "Deltares" are registered trademarks of
-// Stichting Deltares and remain full property of Stichting Deltares at all times.
-// All rights reserved.
-
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
@@ -281,5 +260,15 @@
return ResourceManager.GetString("Segment2D_Constructor_Segment_must_be_created_with_two_points", resourceCulture);
}
}
+
+ ///
+ /// Looks up a localized string similar to Ondergrondschematisatie '{0}' is meerdere keren gevonden in ondergrondmodel '{1}'. Kansen van voorkomen worden opgeteld..
+ ///
+ public static string StochasticSoilProfileHelper_GetValidatedStochasticProfilesToTransform_StochasticSoilProfile_0_has_multiple_occurences_in_SoilModel_1_Probability_Summed {
+ get {
+ return ResourceManager.GetString("StochasticSoilProfileHelper_GetValidatedStochasticProfilesToTransform_StochasticS" +
+ "oilProfile_0_has_multiple_occurences_in_SoilModel_1_Probability_Summed", resourceCulture);
+ }
+ }
}
}
Index: Core/Common/src/Core.Common.Base/Properties/Resources.resx
===================================================================
diff -u -rfae525350cc755ecc783bd4ac3fc13aed2e4ccaa -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision fae525350cc755ecc783bd4ac3fc13aed2e4ccaa)
+++ Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -183,4 +183,7 @@
{0} moeten een unieke {1} hebben. Gevonden dubbele elementen: {2}.
+
+ Ondergrondschematisatie '{0}' is meerdere keren gevonden in ondergrondmodel '{1}'. Kansen van voorkomen worden opgeteld.
+
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -r564d08f23d1931635a55e1aa9240320dfdbfda6a -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 564d08f23d1931635a55e1aa9240320dfdbfda6a)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -1,25 +1,4 @@
-// Copyright (C) Stichting Deltares 2017. All rights reserved.
-//
-// This file is part of Ringtoets.
-//
-// Ringtoets is free software: you can redistribute it and/or modify
-// it under the terms of the GNU General Public License as published by
-// the Free Software Foundation, either version 3 of the License, or
-// (at your option) any later version.
-//
-// This program is distributed in the hope that it will be useful,
-// but WITHOUT ANY WARRANTY; without even the implied warranty of
-// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-// GNU General Public License for more details.
-//
-// You should have received a copy of the GNU General Public License
-// along with this program. If not, see .
-//
-// All names, logos, and references to "Deltares" are registered trademarks of
-// Stichting Deltares and remain full property of Stichting Deltares at all times.
-// All rights reserved.
-
-//------------------------------------------------------------------------------
+//------------------------------------------------------------------------------
//
// This code was generated by a tool.
// Runtime Version:4.0.30319.42000
@@ -1142,10 +1121,10 @@
///
/// Looks up a localized string similar to Het stochastische ondergrondmodel met '{0}' als faalmechanisme type is niet ondersteund. Alleen stochastische ondergrondmodellen met '{1}' als faalmechanisme type zijn ondersteund..
///
- public static string IStochasticSoilModelTransformer_Cannot_tranform_FailureMechanismType_0_Only_FailureMechanismType_1_supported {
+ public static string IStochasticSoilModelTransformer_Cannot_transform_FailureMechanismType_0_Only_FailureMechanismType_1_supported {
get {
- return ResourceManager.GetString("IStochasticSoilModelTransformer_Cannot_tranform_FailureMechanismType_0_Only_Failu" +
- "reMechanismType_1_supported", resourceCulture);
+ return ResourceManager.GetString("IStochasticSoilModelTransformer_Cannot_transform_FailureMechanismType_0_Only_Fail" +
+ "ureMechanismType_1_supported", resourceCulture);
}
}
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx
===================================================================
diff -u -r564d08f23d1931635a55e1aa9240320dfdbfda6a -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 564d08f23d1931635a55e1aa9240320dfdbfda6a)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -874,7 +874,7 @@
Geen lagen gevonden voor de ondergrondschematisatie.
-
+
Het stochastische ondergrondmodel met '{0}' als faalmechanisme type is niet ondersteund. Alleen stochastische ondergrondmodellen met '{1}' als faalmechanisme type zijn ondersteund.
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -r613d5197233c721a6cf95c4f722f1c1941f3081d -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 613d5197233c721a6cf95c4f722f1c1941f3081d)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -155,6 +155,7 @@
+
Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfile.cs
===================================================================
diff -u -rbe4427a66ef77dfa213048b0a823824ea679bce3 -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfile.cs (.../StochasticSoilProfile.cs) (revision be4427a66ef77dfa213048b0a823824ea679bce3)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfile.cs (.../StochasticSoilProfile.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -74,13 +74,26 @@
if (!probabilityValidityRange.InRange(value))
{
throw new ArgumentOutOfRangeException(
- nameof(value),
+ null,
string.Format(
Resources.StochasticSoilProfile_Probability_Should_be_in_range_0_,
probabilityValidityRange.ToString(FormattableConstants.ShowAtLeastOneDecimal, CultureInfo.CurrentCulture)));
}
probability = value;
}
}
+
+ ///
+ /// Updates the probability of the
+ /// by adding .
+ ///
+ /// The amount to increase the
+ /// with.
+ /// Thrown when the
+ /// is outside the range [0, 1].
+ public void AddProbability(double probabilityToAdd)
+ {
+ Probability += probabilityToAdd;
+ }
}
}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfileHelper.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfileHelper.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfileHelper.cs (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -0,0 +1,89 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base.Properties;
+using log4net;
+using Ringtoets.Common.IO.Exceptions;
+
+namespace Ringtoets.Common.IO.SoilProfile
+{
+ ///
+ /// Class which provides helper methods for the .
+ ///
+ public static class StochasticSoilProfileHelper
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(StochasticSoilProfileHelper));
+
+ ///
+ /// Validates a collection of to determine which items
+ /// should be transformed.
+ ///
+ /// The collection of
+ /// to validate.
+ /// The name of the soil model.
+ ///
+ /// Thrown when any parameter is null.
+ /// Thrown when a
+ /// is invalid.
+ public static List GetValidatedStochasticProfilesToTransform(IEnumerable stochasticSoilProfiles,
+ string soilModelName)
+ {
+ if (stochasticSoilProfiles == null)
+ {
+ throw new ArgumentNullException(nameof(stochasticSoilProfiles));
+ }
+ if (soilModelName == null)
+ {
+ throw new ArgumentNullException(nameof(soilModelName));
+ }
+
+ List profilesToTransform = stochasticSoilProfiles.ToList();
+ List allStochasticSoilProfiles = profilesToTransform.ToList();
+
+ try
+ {
+ for (var i = 1; i < allStochasticSoilProfiles.Count; i++)
+ {
+ StochasticSoilProfile previousProfile = allStochasticSoilProfiles[i - 1];
+ StochasticSoilProfile currentProfile = allStochasticSoilProfiles[i];
+ if (ReferenceEquals(currentProfile.SoilProfile, previousProfile.SoilProfile))
+ {
+ log.Warn(string.Format(Resources.StochasticSoilProfileHelper_GetValidatedStochasticProfilesToTransform_StochasticSoilProfile_0_has_multiple_occurences_in_SoilModel_1_Probability_Summed,
+ previousProfile.SoilProfile.Name,
+ soilModelName));
+
+ previousProfile.AddProbability(currentProfile.Probability);
+ profilesToTransform.Remove(currentProfile);
+ }
+ }
+ }
+ catch (ArgumentOutOfRangeException e)
+ {
+ throw new ImportedDataTransformException(e.Message, e);
+ }
+
+ return profilesToTransform;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj
===================================================================
diff -u -r613d5197233c721a6cf95c4f722f1c1941f3081d -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 613d5197233c721a6cf95c4f722f1c1941f3081d)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -135,6 +135,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileHelperTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileHelperTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileHelperTest.cs (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -0,0 +1,173 @@
+// Copyright (C) Stichting Deltares 2017. All rights reserved.
+//
+// This file is part of Ringtoets.
+//
+// Ringtoets is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.IO.Exceptions;
+using Ringtoets.Common.IO.SoilProfile;
+
+namespace Ringtoets.Common.IO.Test.SoilProfile
+{
+ [TestFixture]
+ public class StochasticSoilProfileHelperTest
+ {
+ [Test]
+ public void GetValidatedSoilProfilesToTransform_StochasticSoilProfilesNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(null,
+ string.Empty);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("stochasticSoilProfiles", exception.ParamName);
+ }
+
+ [Test]
+ public void GetValidatedSoilProfilesToTransform_SoilModelNameNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () =>
+ StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(Enumerable.Empty(),
+ null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("soilModelName", exception.ParamName);
+ }
+
+ [Test]
+ public void GetValidatedSoilProfilesToTransform_DistinctSoilProfiles_ReturnsExpectedSoilProfiles()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var soilProfileOne = mocks.Stub();
+ var soilProfileTwo = mocks.Stub();
+ mocks.ReplayAll();
+
+ var profileOne = new StochasticSoilProfile(0.5, soilProfileOne);
+ var profileTwo = new StochasticSoilProfile(0.8, soilProfileTwo);
+ var stochasticSoilProfiles = new[]
+ {
+ profileOne,
+ profileTwo
+ };
+
+ // Call
+ List profilesToTransform =
+ StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles,
+ string.Empty);
+
+ // Assert
+ CollectionAssert.AreEqual(stochasticSoilProfiles, profilesToTransform);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void GetValidatedSoilProfilesToTransform_SameSoilProfile_ReturnsExpectedSoilProfiles()
+ {
+ // Setup
+ const string soilProfileName = "A profile name";
+ const string soilModelName = "A model name";
+
+ var mocks = new MockRepository();
+ var profile = mocks.Stub();
+ profile.Stub(p => p.Name).Return(soilProfileName);
+ mocks.ReplayAll();
+
+ const double probabilityOne = 0.5;
+ const double probabilityTwo = 0.1;
+ var profileOne = new StochasticSoilProfile(probabilityOne, profile);
+ var profileTwo = new StochasticSoilProfile(probabilityTwo, profile);
+ var stochasticSoilProfiles = new[]
+ {
+ profileOne,
+ profileTwo
+ };
+
+ List profilesToTransform = null;
+
+ // Call
+ Action call = () => profilesToTransform =
+ StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles,
+ soilModelName);
+
+ // 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));
+
+ StochasticSoilProfile profileToTransform = profilesToTransform.Single();
+ Assert.AreEqual(profileOne, profileToTransform);
+ const double expectedProbability = probabilityOne + probabilityTwo;
+ Assert.AreEqual(expectedProbability, profileToTransform.Probability, 1e-6);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ public void GetValidatedSoilProfilesToTransform_SameSoilProfileProbabilityInvalid_ThrowsImportedDataException()
+ {
+ // Setup
+ const string soilProfileName = "A profile name";
+ const string soilModelName = "A model name";
+
+ var mocks = new MockRepository();
+ var profile = mocks.Stub();
+ profile.Stub(p => p.Name).Return(soilProfileName);
+ mocks.ReplayAll();
+
+ var profileOne = new StochasticSoilProfile(0.9, profile);
+ var profileTwo = new StochasticSoilProfile(0.9, profile);
+ var stochasticSoilProfiles = new[]
+ {
+ profileOne,
+ profileTwo
+ };
+
+ // Precondition
+ double totalProbabilitySum = profileOne.Probability + profileTwo.Probability;
+ Assert.GreaterOrEqual(totalProbabilitySum, 1);
+
+ List profilesToTransform = null;
+
+ // Call
+ TestDelegate call = () => profilesToTransform =
+ StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles,
+ soilModelName);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ const string expectedNessage = "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel " +
+ "moet in het bereik [0,0, 1,0] liggen.";
+ Assert.AreEqual(expectedNessage, exception.Message);
+ Assert.IsInstanceOf(exception.InnerException);
+
+ Assert.IsNull(profilesToTransform);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileTest.cs
===================================================================
diff -u -rbe4427a66ef77dfa213048b0a823824ea679bce3 -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision be4427a66ef77dfa213048b0a823824ea679bce3)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -54,6 +54,57 @@
mockRepository.VerifyAll();
}
+ [Test]
+ [SetCulture("nl-NL")]
+ [TestCase(-1)]
+ [TestCase(1)]
+ [TestCase(-0.51)]
+ [TestCase(0.51)]
+ public void AddProbability_ProbabilityToAddResultsInInvalidProbability_ThrowsArgumentOutOfrangeException(double probabilityToAdd)
+ {
+ // Setup
+ const double probability = 0.5;
+
+ var mockRepository = new MockRepository();
+ var soilProfile = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var stochasticSoilProfile = new StochasticSoilProfile(probability, soilProfile);
+
+ // Call
+ TestDelegate call = () => stochasticSoilProfile.AddProbability(probabilityToAdd);
+
+ // Assert
+ const string expectedMessage = "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel moet in het bereik [0,0, 1,0] liggen.";
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(0.5)]
+ [TestCase(-0.5)]
+ [TestCase(-0.2)]
+ [TestCase(0.2)]
+ public void AddProbability_ProbabilityToAddResultsInValidProbability_ReturnsExpectedProbability(double probabilityToAdd)
+ {
+ // Setup
+ const double probability = 0.5;
+
+ var mockRepository = new MockRepository();
+ var soilProfile = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var stochasticSoilProfile = new StochasticSoilProfile(probability, soilProfile);
+
+ // Call
+ stochasticSoilProfile.AddProbability(probabilityToAdd);
+
+ // Assert
+ double expectedProbability = probability + probabilityToAdd;
+ Assert.AreEqual(expectedProbability, stochasticSoilProfile.Probability, 1e-6);
+ }
+
[TestCase]
public void Constructor_SoilProfileNull_ThrowsArgumentNullException()
{
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs
===================================================================
diff -u -r9622873faf35255d36a4543501d4788baa399af7 -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs (.../MacroStabilityInwardsStochasticSoilModelTransformer.cs) (revision 9622873faf35255d36a4543501d4788baa399af7)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs (.../MacroStabilityInwardsStochasticSoilModelTransformer.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -47,7 +47,7 @@
if (stochasticSoilModel.FailureMechanismType != FailureMechanismType.Stability)
{
- string message = string.Format(RingtoetsCommonIOResources.IStochasticSoilModelTransformer_Cannot_tranform_FailureMechanismType_0_Only_FailureMechanismType_1_supported,
+ string message = string.Format(RingtoetsCommonIOResources.IStochasticSoilModelTransformer_Cannot_transform_FailureMechanismType_0_Only_FailureMechanismType_1_supported,
stochasticSoilModel.FailureMechanismType,
FailureMechanismType.Stability);
throw new ImportedDataTransformException(message);
@@ -56,21 +56,27 @@
var macroStabilityInwardsModel = new MacroStabilityInwardsStochasticSoilModel(stochasticSoilModel.Name);
macroStabilityInwardsModel.Geometry.AddRange(stochasticSoilModel.Geometry);
macroStabilityInwardsModel.StochasticSoilProfiles.AddRange(
- TransformStochasticSoilProfiles(stochasticSoilModel.StochasticSoilProfiles).ToArray());
+ TransformStochasticSoilProfiles(stochasticSoilModel.StochasticSoilProfiles, stochasticSoilModel.Name).ToArray());
return macroStabilityInwardsModel;
}
///
/// Transforms all generic into .
///
/// The stochastic soil profiles to use in the transformation.
+ /// The name of the soil model.
/// The transformed stochastic soil profiles.
/// Thrown when transformation would
/// not result in a valid transformed instance.
private IEnumerable TransformStochasticSoilProfiles(
- IEnumerable stochasticSoilProfiles)
+ IEnumerable stochasticSoilProfiles,
+ string soilModelName)
{
- return stochasticSoilProfiles.Select(
+ List profilesToTransform =
+ StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles,
+ soilModelName);
+
+ return profilesToTransform.Select(
ssp => MacroStabilityInwardsStochasticSoilProfileTransformer.Transform(
ssp,
GetTransformedSoilProfile(ssp.SoilProfile))).ToArray();
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)
{
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs
===================================================================
diff -u -r40a0586962f6df49b0ca60f5260ee2792fe4fd08 -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (.../PipingStochasticSoilModelTransformer.cs) (revision 40a0586962f6df49b0ca60f5260ee2792fe4fd08)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (.../PipingStochasticSoilModelTransformer.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5)
@@ -46,7 +46,7 @@
}
if (stochasticSoilModel.FailureMechanismType != FailureMechanismType.Piping)
{
- string message = string.Format(RingtoetsCommonIOResources.IStochasticSoilModelTransformer_Cannot_tranform_FailureMechanismType_0_Only_FailureMechanismType_1_supported,
+ string message = string.Format(RingtoetsCommonIOResources.IStochasticSoilModelTransformer_Cannot_transform_FailureMechanismType_0_Only_FailureMechanismType_1_supported,
stochasticSoilModel.FailureMechanismType,
FailureMechanismType.Piping);
throw new ImportedDataTransformException(message);
@@ -55,7 +55,7 @@
var pipingModel = new PipingStochasticSoilModel(stochasticSoilModel.Name);
pipingModel.Geometry.AddRange(stochasticSoilModel.Geometry);
pipingModel.StochasticSoilProfiles.AddRange(
- TransformStochasticSoilProfiles(stochasticSoilModel.StochasticSoilProfiles).ToArray());
+ TransformStochasticSoilProfiles(stochasticSoilModel.StochasticSoilProfiles, stochasticSoilModel.Name).ToArray());
return pipingModel;
}
@@ -64,15 +64,19 @@
/// Transforms all generic into .
///
/// The stochastic soil profiles to use in the transformation.
+ /// The name of the soil model.
/// The transformed piping stochastic soil profiles.
/// Thrown when transformation would
/// not result in a valid transformed instance.
- private IEnumerable TransformStochasticSoilProfiles(IEnumerable stochasticSoilProfiles)
+ private IEnumerable TransformStochasticSoilProfiles(IEnumerable stochasticSoilProfiles,
+ string soilModelName)
{
- return stochasticSoilProfiles.Select(
- ssp => PipingStochasticSoilProfileTransformer.Transform(
- ssp,
- GetTransformedPipingSoilProfile(ssp.SoilProfile)));
+ List profilesToTransform = StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles,
+ soilModelName);
+
+ return profilesToTransform.Select(ssp => PipingStochasticSoilProfileTransformer.Transform(
+ ssp,
+ GetTransformedPipingSoilProfile(ssp.SoilProfile))).ToArray();
}
///
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs
===================================================================
diff -u -r0321f85aefaf574d1c4005329a5034c1b34ba4d2 -r76aba900dac58a4328145a2946b774ebd4a37aa5
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.cs) (revision 0321f85aefaf574d1c4005329a5034c1b34ba4d2)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.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;
@@ -235,6 +236,88 @@
Assert.AreSame(pipingStochasticSoilProfile1.SoilProfile, pipingStochasticSoilProfile2.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 PipingStochasticSoilModelTransformer();
+ var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Piping)
+ {
+ StochasticSoilProfiles =
+ {
+ new StochasticSoilProfile(0.2, profile),
+ new StochasticSoilProfile(0.7, profile)
+ }
+ };
+
+ PipingStochasticSoilModel 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 PipingStochasticSoilModelTransformer();
+ var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Piping)
+ {
+ StochasticSoilProfiles =
+ {
+ new StochasticSoilProfile(0.2, soilProfile2D),
+ new StochasticSoilProfile(0.7, soilProfile1D)
+ }
+ };
+
+ // Call
+ PipingStochasticSoilModel 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 AssertPipingStochasticSoilProfiles(IList expected,
IList actual)
{