Index: Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs =================================================================== diff -u -r76aba900dac58a4328145a2946b774ebd4a37aa5 -rc71f15ef23debdc4df0719145291de37aea66c97 --- Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) +++ Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) @@ -1,4 +1,25 @@ -//------------------------------------------------------------------------------ +// 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 Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r76aba900dac58a4328145a2946b774ebd4a37aa5 -rc71f15ef23debdc4df0719145291de37aea66c97 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) @@ -1,4 +1,25 @@ -//------------------------------------------------------------------------------ +// 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 @@ -1515,14 +1536,14 @@ } /// - /// Looks up a localized string similar to BEGIN TRANSACTION; - ///CREATE TABLE "TimeIntegrationSettings" ( - /// "LocationID" INTEGER NOT NULL, - /// "CalculationTypeID" INTEGER NOT NULL, - /// "TimeIntegrationSchemeID" INTEGER NOT NULL, - /// CONSTRAINT timeintegrationsettings_pk PRIMARY KEY ("LocationID", "CalculationTypeID"), - /// CONSTRAINT calculationtypes_timeintegrationsettings_fk FOREIGN KEY ("CalculationTypeID") REFERENCES CalculationTypes ("CalculationTypeID") ON DELETE NO ACTION ON UPDATE NO ACTION - ///); + /// Looks up a localized string similar to BEGIN TRANSACTION; + ///CREATE TABLE "TimeIntegrationSettings" ( + /// "LocationID" INTEGER NOT NULL, + /// "CalculationTypeID" INTEGER NOT NULL, + /// "TimeIntegrationSchemeID" INTEGER NOT NULL, + /// CONSTRAINT timeintegrationsettings_pk PRIMARY KEY ("LocationID", "CalculationTypeID"), + /// CONSTRAINT calculationtypes_timeintegrationsettings_fk FOREIGN KEY ("CalculationTypeID") REFERENCES CalculationTypes ("CalculationTypeID") ON DELETE NO ACTION ON UPDATE NO ACTION + ///); ///CREATE TABLE "Numeri [rest of string was truncated]";. /// public static string settings_schema { Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfileHelper.cs =================================================================== diff -u -r76aba900dac58a4328145a2946b774ebd4a37aa5 -rc71f15ef23debdc4df0719145291de37aea66c97 --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfileHelper.cs (.../StochasticSoilProfileHelper.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfileHelper.cs (.../StochasticSoilProfileHelper.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections; using System.Collections.Generic; using System.Linq; using Core.Common.Base.Properties; @@ -42,12 +43,11 @@ /// The collection of /// to validate. /// The name of the soil model. - /// + /// A collection of validated to transform. /// Thrown when any parameter is null. /// Thrown when a /// is invalid. - public static List GetValidatedStochasticProfilesToTransform(IEnumerable stochasticSoilProfiles, - string soilModelName) + public static IEnumerable GetValidatedStochasticProfilesToTransform(IEnumerable stochasticSoilProfiles, string soilModelName) { if (stochasticSoilProfiles == null) { @@ -59,11 +59,11 @@ } List profilesToTransform = stochasticSoilProfiles.ToList(); - List allStochasticSoilProfiles = profilesToTransform.ToList(); + StochasticSoilProfile[] allStochasticSoilProfiles = profilesToTransform.ToArray(); try { - for (var i = 1; i < allStochasticSoilProfiles.Count; i++) + for (var i = 1; i < allStochasticSoilProfiles.Length; i++) { StochasticSoilProfile previousProfile = allStochasticSoilProfiles[i - 1]; StochasticSoilProfile currentProfile = allStochasticSoilProfiles[i]; Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileHelperTest.cs =================================================================== diff -u -r76aba900dac58a4328145a2946b774ebd4a37aa5 -rc71f15ef23debdc4df0719145291de37aea66c97 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileHelperTest.cs (.../StochasticSoilProfileHelperTest.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileHelperTest.cs (.../StochasticSoilProfileHelperTest.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) @@ -76,7 +76,7 @@ }; // Call - List profilesToTransform = + IEnumerable profilesToTransform = StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles, string.Empty); @@ -108,7 +108,7 @@ profileTwo }; - List profilesToTransform = null; + IEnumerable profilesToTransform = null; // Call Action call = () => profilesToTransform = @@ -120,6 +120,7 @@ "Kansen van voorkomen worden opgeteld."; TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Warn)); + Assert.IsNotNull(profilesToTransform); StochasticSoilProfile profileToTransform = profilesToTransform.Single(); Assert.AreEqual(profileOne, profileToTransform); const double expectedProbability = probabilityOne + probabilityTwo; @@ -153,7 +154,7 @@ double totalProbabilitySum = profileOne.Probability + profileTwo.Probability; Assert.GreaterOrEqual(totalProbabilitySum, 1); - List profilesToTransform = null; + IEnumerable profilesToTransform = null; // Call TestDelegate call = () => profilesToTransform = Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs =================================================================== diff -u -r76aba900dac58a4328145a2946b774ebd4a37aa5 -rc71f15ef23debdc4df0719145291de37aea66c97 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs (.../MacroStabilityInwardsStochasticSoilModelTransformer.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs (.../MacroStabilityInwardsStochasticSoilModelTransformer.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) @@ -72,7 +72,7 @@ IEnumerable stochasticSoilProfiles, string soilModelName) { - List profilesToTransform = + IEnumerable profilesToTransform = StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles, soilModelName); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformerTest.cs =================================================================== diff -u -r76aba900dac58a4328145a2946b774ebd4a37aa5 -rc71f15ef23debdc4df0719145291de37aea66c97 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformerTest.cs (.../MacroStabilityInwardsStochasticSoilModelTransformerTest.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformerTest.cs (.../MacroStabilityInwardsStochasticSoilModelTransformerTest.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) @@ -25,6 +25,7 @@ using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; +using Rhino.Mocks; using Ringtoets.Common.IO.Exceptions; using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Common.IO.SoilProfile.Schema; @@ -153,7 +154,7 @@ { new Point2D(1.0, 1.0), new Point2D(2.0, 1.0) - }), + }) }) { Properties = @@ -210,7 +211,7 @@ } [Test] - public void Transform_ValidStochasticSoilModelWithSameProfileInTwoStochasticSoilProfiles_ReturnsExpectedPipingStochasticSoilModel() + public void Transform_ValidStochasticSoilModelWithSameProfileInTwoStochasticSoilProfiles_ReturnsExpectedMacroStabilityInwardsStochasticSoilModel() { // Setup const string soilModelName = "name"; @@ -225,17 +226,19 @@ { IntersectionX = intersectionX }; - - var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer(); + + const double originalProfileOneProbability = 0.2; + const double originalProfileTwoProbability = 0.7; var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Stability) { StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, profile), - new StochasticSoilProfile(0.7, profile) + new StochasticSoilProfile(originalProfileOneProbability, profile), + new StochasticSoilProfile(originalProfileTwoProbability, profile) } }; + var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer(); MacroStabilityInwardsStochasticSoilModel transformed = null; // Call @@ -245,16 +248,55 @@ 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); + const double expectedProbability = originalProfileOneProbability + originalProfileTwoProbability; + Assert.AreEqual(expectedProbability, transformedStochasticSoilProfiles[0].Probability, 1e-6); } [Test] - public void Transform_ValidStochasticSoilModelWithSimilarProfileInTwoStochasticSoilProfiles_ReturnsExpectedPipingStochasticSoilModel() + [SetCulture("nl-NL")] + public void Transform_ValidStochasticSoilModelWithSameProfileProbabilitExceedingValidRange_ThrowsImportedDataException() { // Setup const string soilModelName = "name"; + + var mocks = new MockRepository(); + var profile = mocks.Stub(); + mocks.ReplayAll(); + + var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Stability) + { + StochasticSoilProfiles = + { + new StochasticSoilProfile(0.9, profile), + new StochasticSoilProfile(0.9, profile) + } + }; + + var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer(); + MacroStabilityInwardsStochasticSoilModel transformed = null; + + // Call + TestDelegate call = () => transformed = transformer.Transform(soilModel); + + // Assert + var exception = Assert.Throws(call); + const string expectedMessage = "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel " + + "moet in het bereik [0,0, 1,0] liggen."; + Assert.AreEqual(expectedMessage, exception.Message); + + Assert.IsNull(transformed); + + mocks.VerifyAll(); + } + + [Test] + public void Transform_ValidStochasticSoilModelWithSimilarProfileInTwoStochasticSoilProfiles_ReturnsExpectedMacroStabilityInwardsStochasticSoilModel() + { + // Setup + const string soilModelName = "name"; const string soilProfileName = "SoilProfile"; const double intersectionX = 1.0; @@ -265,30 +307,33 @@ { IntersectionX = intersectionX }; + var stochasticSoilProfile2D = new StochasticSoilProfile(0.2, soilProfile2D); var soilProfile1D = new SoilProfile1D(0, soilProfileName, 0, new[] { new SoilLayer1D(1) }); + var stochasticSoilProfile1D = new StochasticSoilProfile(0.7, soilProfile1D); - var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer(); var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Stability) { StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, soilProfile2D), - new StochasticSoilProfile(0.7, soilProfile1D) + stochasticSoilProfile2D, + stochasticSoilProfile1D } }; + var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer(); + // 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); + Assert.AreEqual(stochasticSoilProfile2D.Probability, transformedStochasticSoilProfiles[0].Probability, 1e-6); + Assert.AreEqual(stochasticSoilProfile1D.Probability, transformedStochasticSoilProfiles[1].Probability, 1e-6); } private static void AssertStochasticSoilProfile(MacroStabilityInwardsStochasticSoilProfile expected, Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs =================================================================== diff -u -r76aba900dac58a4328145a2946b774ebd4a37aa5 -rc71f15ef23debdc4df0719145291de37aea66c97 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (.../PipingStochasticSoilModelTransformer.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (.../PipingStochasticSoilModelTransformer.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) @@ -71,8 +71,9 @@ private IEnumerable TransformStochasticSoilProfiles(IEnumerable stochasticSoilProfiles, string soilModelName) { - List profilesToTransform = StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles, - soilModelName); + IEnumerable profilesToTransform = + StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles, + soilModelName); return profilesToTransform.Select(ssp => PipingStochasticSoilProfileTransformer.Transform( ssp, Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs =================================================================== diff -u -r76aba900dac58a4328145a2946b774ebd4a37aa5 -rc71f15ef23debdc4df0719145291de37aea66c97 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) @@ -25,6 +25,7 @@ using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; +using Rhino.Mocks; using Ringtoets.Common.IO.Exceptions; using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Common.IO.SoilProfile.Schema; @@ -252,17 +253,19 @@ { IntersectionX = intersectionX }; - - var transformer = new PipingStochasticSoilModelTransformer(); + + const double originalProfileOneProbability = 0.2; + const double originalProfileTwoProbability = 0.7; var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Piping) { StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, profile), - new StochasticSoilProfile(0.7, profile) + new StochasticSoilProfile(originalProfileOneProbability, profile), + new StochasticSoilProfile(originalProfileTwoProbability, profile) } }; + var transformer = new PipingStochasticSoilModelTransformer(); PipingStochasticSoilModel transformed = null; // Call @@ -272,12 +275,52 @@ 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); + const double expectedProbability = originalProfileOneProbability + originalProfileTwoProbability; + Assert.AreEqual(expectedProbability, transformedStochasticSoilProfiles[0].Probability, 1e-6); } [Test] + [SetCulture("nl-NL")] + public void Transform_ValidStochasticSoilModelWithSameProfileProbabilitExceedingValidRange_ThrowsImportedDataException() + { + // Setup + const string soilModelName = "name"; + + var mocks = new MockRepository(); + var profile = mocks.Stub(); + mocks.ReplayAll(); + + + var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Stability) + { + StochasticSoilProfiles = + { + new StochasticSoilProfile(0.9, profile), + new StochasticSoilProfile(0.9, profile) + } + }; + + var transformer = new PipingStochasticSoilModelTransformer(); + PipingStochasticSoilModel transformed = null; + + // Call + TestDelegate call = () => transformed = transformer.Transform(soilModel); + + // Assert + var exception = Assert.Throws(call); + const string expectedMessage = "Het aandeel van de ondergrondschematisatie in het stochastische ondergrondmodel " + + "moet in het bereik [0,0, 1,0] liggen."; + Assert.AreEqual(expectedMessage, exception.Message); + + Assert.IsNull(transformed); + + mocks.VerifyAll(); + } + + [Test] public void Transform_ValidStochasticSoilModelWithSimilarProfileInTwoStochasticSoilProfiles_ReturnsExpectedPipingStochasticSoilModel() { // Setup @@ -292,19 +335,21 @@ { IntersectionX = intersectionX }; + var stochasticSoilProfile2D = new StochasticSoilProfile(0.2, soilProfile2D); var soilProfile1D = new SoilProfile1D(0, soilProfileName, 0, new[] { new SoilLayer1D(1) }); + var stochasticSoilProfile1D = new StochasticSoilProfile(0.2, soilProfile1D); var transformer = new PipingStochasticSoilModelTransformer(); var soilModel = new StochasticSoilModel(soilModelName, FailureMechanismType.Piping) { StochasticSoilProfiles = { - new StochasticSoilProfile(0.2, soilProfile2D), - new StochasticSoilProfile(0.7, soilProfile1D) + stochasticSoilProfile2D, + stochasticSoilProfile1D } }; @@ -314,8 +359,8 @@ // 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); + Assert.AreEqual(stochasticSoilProfile2D.Probability, transformedStochasticSoilProfiles[0].Probability, 1e-6); + Assert.AreEqual(stochasticSoilProfile1D.Probability, transformedStochasticSoilProfiles[1].Probability, 1e-6); } private static void AssertPipingStochasticSoilProfiles(IList expected,