Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -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 @@ -1545,14 +1524,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 { @@ -1696,9 +1675,9 @@ /// /// Looks up a localized string similar to Is aquifer. /// - public static string SoilLayerProperties_IsAquifer_Description { + public static string SoilLayerProperties_IsAquifer_Name { get { - return ResourceManager.GetString("SoilLayerProperties_IsAquifer_Description", resourceCulture); + return ResourceManager.GetString("SoilLayerProperties_IsAquifer_Name", resourceCulture); } } Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -892,7 +892,7 @@ Parameter '{0}' is niet verschoven lognormaal verdeeld. - + Is aquifer Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayerDistributionHelper.cs =================================================================== diff -u -r613d5197233c721a6cf95c4f722f1c1941f3081d -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayerDistributionHelper.cs (.../SoilLayerDistributionHelper.cs) (revision 613d5197233c721a6cf95c4f722f1c1941f3081d) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayerDistributionHelper.cs (.../SoilLayerDistributionHelper.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -34,23 +34,23 @@ private const double tolerance = 1e-6; /// - /// Validates if the distribution is a non-shifted log normal distribution. + /// Validates that the distribution is a non-shifted log normal distribution. /// - /// The distribution type. + /// The distribution type. /// The value of the shift. /// The name of the parameter to be validated. /// Thrown when /// is null. /// Thrown when the parameter is not a - /// non-shifted log normal distribution. - public static void ValidateIsNonShiftedLogNormal(long? distribution, double shift, string parameterName) + /// log normal distribution with a zero shifty. + public static void ValidateIsNonShiftedLogNormal(long? distributionType, double shift, string parameterName) { if (parameterName == null) { throw new ArgumentNullException(nameof(parameterName)); } - if (distribution.HasValue && (distribution.Value != SoilLayerConstants.LogNormalDistributionValue + if (distributionType.HasValue && (distributionType.Value != SoilLayerConstants.LogNormalDistributionValue || Math.Abs(shift) > tolerance)) { throw new ImportedDataTransformException(string.Format( @@ -60,22 +60,22 @@ } /// - /// Validates if the distribution is a log normal distribution. + /// Validates that the distribution is a log normal distribution. /// - /// The distribution type. + /// The distribution type. /// The name of the parameter to be validated. /// Thrown when /// is null. /// Thrown when the parameter is not a /// log-normal distribution. - public static void ValidateIsLogNormal(long? distribution, string parameterName) + public static void ValidateIsLogNormal(long? distributionType, string parameterName) { if (parameterName == null) { throw new ArgumentNullException(nameof(parameterName)); } - if (distribution.HasValue && distribution != SoilLayerConstants.LogNormalDistributionValue) + if (distributionType.HasValue && distributionType != SoilLayerConstants.LogNormalDistributionValue) { throw new ImportedDataTransformException(string.Format( Resources.SoilLayer_Stochastic_parameter_0_has_no_shifted_lognormal_distribution, Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayerIsAquiferConverter.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayerIsAquiferConverter.cs (.../SoilLayerIsAquiferConverter.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/SoilLayerIsAquiferConverter.cs (.../SoilLayerIsAquiferConverter.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -19,41 +19,42 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using Ringtoets.Common.IO.Exceptions; -using Ringtoets.Common.IO.Properties; +using System; namespace Ringtoets.Common.IO.SoilProfile { /// - /// This class provides helpers for converting values from DSoil Model database + /// This class provides helpers for converting values from D-Soil Model database /// into valid valued of the 'is aquifer' of soil layers. /// public static class SoilLayerIsAquiferConverter { + private const double tolerance = 1e-6; + /// /// Converts a nullable to a . /// /// The value to convert. - /// A based on the . - /// - /// Thrown when + /// A based on the . + /// Thrown when /// cannot be converted. public static bool Convert(double? isAquifer) { if (isAquifer.HasValue) { - if (isAquifer.Equals(0.0)) + if (isAquifer < 0.0 + tolerance + && isAquifer > 0.0 - tolerance) { return false; } - if (isAquifer.Equals(1.0)) + if (isAquifer < 1.0 + tolerance + && isAquifer > 1.0 - tolerance) { return true; } } - throw new ImportedDataTransformException(string.Format(Resources.Convert_Invalid_value_ParameterName_0, - Resources.SoilLayerProperties_IsAquifer_Description)); + throw new NotSupportedException($"A value of {isAquifer} for {nameof(isAquifer)} cannot be converted to a valid boolean."); } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfileHelper.cs =================================================================== diff -u -rc71f15ef23debdc4df0719145291de37aea66c97 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfileHelper.cs (.../StochasticSoilProfileHelper.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) +++ Ringtoets/Common/src/Ringtoets.Common.IO/SoilProfile/StochasticSoilProfileHelper.cs (.../StochasticSoilProfileHelper.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using System.Collections; using System.Collections.Generic; using System.Linq; using Core.Common.Base.Properties; @@ -47,7 +46,8 @@ /// Thrown when any parameter is null. /// Thrown when a /// is invalid. - public static IEnumerable GetValidatedStochasticProfilesToTransform(IEnumerable stochasticSoilProfiles, string soilModelName) + public static IEnumerable GetValidatedStochasticSoilProfilesToTransform(IEnumerable stochasticSoilProfiles, + string soilModelName) { if (stochasticSoilProfiles == null) { Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/UpdateDataStrategies/ReplaceDataStrategyBaseTest.cs =================================================================== diff -u -r42357a100d1a75baca233aa44b866a5009f48e00 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/UpdateDataStrategies/ReplaceDataStrategyBaseTest.cs (.../ReplaceDataStrategyBaseTest.cs) (revision 42357a100d1a75baca233aa44b866a5009f48e00) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/UpdateDataStrategies/ReplaceDataStrategyBaseTest.cs (.../ReplaceDataStrategyBaseTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -33,8 +33,6 @@ [TestFixture] public class ReplaceDataStrategyBaseTest { - - [Test] public void Constructor_FailureMechanismNull_ThrowsArgumentNullException() { Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayerIsAquiferConverterTest.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayerIsAquiferConverterTest.cs (.../SoilLayerIsAquiferConverterTest.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/SoilLayerIsAquiferConverterTest.cs (.../SoilLayerIsAquiferConverterTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -19,8 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using NUnit.Framework; -using Ringtoets.Common.IO.Exceptions; using Ringtoets.Common.IO.SoilProfile; namespace Ringtoets.Common.IO.Test.SoilProfile @@ -29,8 +29,12 @@ public class SoilLayerIsAquiferConverterTest { [Test] - [TestCase(1, true)] + [TestCase(1.0, true)] + [TestCase(1 + 1e-7, true)] + [TestCase(1 - 1e-7, true)] [TestCase(0, false)] + [TestCase(0.0 + 1e-7, false)] + [TestCase(0.0 - 1e-7, false)] public void Convert_ValidValues_ReturnsExpectedValues(double isAquifer, bool expectedResult) { @@ -45,15 +49,21 @@ [TestCase(null)] [TestCase(0.5)] [TestCase(1.1)] + [TestCase(1 - 1e-6)] + [TestCase(1 + 1e-6)] [TestCase(0.1)] + [TestCase(0 - 1e-6)] + [TestCase(0 + 1e-6)] + [TestCase(double.NaN)] public void Convert_InvalidValues_ThrowsImportedDataTransformException(double? isAquifer) { // Call - TestDelegate call = ()=> SoilLayerIsAquiferConverter.Convert(isAquifer); + TestDelegate call = () => SoilLayerIsAquiferConverter.Convert(isAquifer); // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("Ongeldige waarde voor parameter 'Is aquifer'.", exception.Message); + var exception = Assert.Throws(call); + string expectedMessage = $"A value of {isAquifer} for isAquifer cannot be converted to a valid boolean."; + Assert.AreEqual(expectedMessage, exception.Message); } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileHelperTest.cs =================================================================== diff -u -rc71f15ef23debdc4df0719145291de37aea66c97 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileHelperTest.cs (.../StochasticSoilProfileHelperTest.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileHelperTest.cs (.../StochasticSoilProfileHelperTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -37,7 +37,7 @@ public void GetValidatedSoilProfilesToTransform_StochasticSoilProfilesNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(null, + TestDelegate call = () => StochasticSoilProfileHelper.GetValidatedStochasticSoilProfilesToTransform(null, string.Empty); // Assert @@ -50,7 +50,7 @@ { // Call TestDelegate call = () => - StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(Enumerable.Empty(), + StochasticSoilProfileHelper.GetValidatedStochasticSoilProfilesToTransform(Enumerable.Empty(), null); // Assert @@ -77,7 +77,7 @@ // Call IEnumerable profilesToTransform = - StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles, + StochasticSoilProfileHelper.GetValidatedStochasticSoilProfilesToTransform(stochasticSoilProfiles, string.Empty); // Assert @@ -112,7 +112,7 @@ // Call Action call = () => profilesToTransform = - StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles, + StochasticSoilProfileHelper.GetValidatedStochasticSoilProfilesToTransform(stochasticSoilProfiles, soilModelName); // Assert @@ -121,8 +121,9 @@ TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Warn)); Assert.IsNotNull(profilesToTransform); + StochasticSoilProfile profileToTransform = profilesToTransform.Single(); - Assert.AreEqual(profileOne, profileToTransform); + Assert.AreSame(profile, profileToTransform.SoilProfile); const double expectedProbability = probabilityOne + probabilityTwo; Assert.AreEqual(expectedProbability, profileToTransform.Probability, 1e-6); @@ -134,12 +135,10 @@ 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); + profile.Stub(p => p.Name).Return("A profile name"); mocks.ReplayAll(); var profileOne = new StochasticSoilProfile(0.9, profile); @@ -152,23 +151,19 @@ // Precondition double totalProbabilitySum = profileOne.Probability + profileTwo.Probability; - Assert.GreaterOrEqual(totalProbabilitySum, 1); + Assert.Greater(totalProbabilitySum, 1); - IEnumerable profilesToTransform = null; // Call - TestDelegate call = () => profilesToTransform = - StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles, - soilModelName); + TestDelegate call = () => StochasticSoilProfileHelper.GetValidatedStochasticSoilProfilesToTransform(stochasticSoilProfiles, + string.Empty); // 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 -r76aba900dac58a4328145a2946b774ebd4a37aa5 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision 76aba900dac58a4328145a2946b774ebd4a37aa5) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/SoilProfile/StochasticSoilProfileTest.cs (.../StochasticSoilProfileTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -60,7 +60,8 @@ [TestCase(1)] [TestCase(-0.51)] [TestCase(0.51)] - public void AddProbability_ProbabilityToAddResultsInInvalidProbability_ThrowsArgumentOutOfrangeException(double probabilityToAdd) + [TestCase(double.NaN)] + public void AddProbability_ProbabilityToAddResultsInInvalidProbability_ThrowsArgumentOutOfRangeException(double probabilityToAdd) { // Setup const double probability = 0.5; Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/SoilLayer1DTestFactoryTest.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/SoilLayer1DTestFactoryTest.cs (.../SoilLayer1DTestFactoryTest.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/SoilLayer1DTestFactoryTest.cs (.../SoilLayer1DTestFactoryTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -28,25 +28,25 @@ public class SoilLayer1DTestFactoryTest { [Test] - public void CreateSoilLayer1DForTransforming_ParameterLess_ReturnsExpectedProperties() + public void CreateSoilLayer1DWithValidAquifer_ParameterLess_ReturnsExpectedProperties() { // Call - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); // Assert Assert.AreEqual(3.14, layer.Top); Assert.AreEqual(0.0, layer.IsAquifer); } [Test] - public void CreateSoilLayer1DForTransforming_WithTop_ReturnsExpectedProperties() + public void CreateSoilLayer1DWithValidAquifer_WithTop_ReturnsExpectedProperties() { // Setup var random = new Random(21); double top = random.NextDouble(); // Call - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(top); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top); // Assert Assert.AreEqual(top, layer.Top); Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/SoilLayer2DTestFactoryTest.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/SoilLayer2DTestFactoryTest.cs (.../SoilLayer2DTestFactoryTest.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil.Test/SoilLayer2DTestFactoryTest.cs (.../SoilLayer2DTestFactoryTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -140,16 +140,15 @@ [Test] public void CreateSoilLayer2D_Parameterless_ExpectedProperties() { - // Setup + // Call + SoilLayer2D soilLayer = SoilLayer2DTestFactory.CreateSoilLayer2D(); + + // Assert var pointA = new Point2D(0.0, 0.0); var pointB = new Point2D(1.0, 0.0); var pointC = new Point2D(1.0, 1.0); var pointD = new Point2D(2.0, 1.0); - // Call - SoilLayer2D soilLayer = SoilLayer2DTestFactory.CreateSoilLayer2D(); - - // Assert Assert.AreEqual(new Segment2D(pointA, pointB), soilLayer.OuterLoop.ElementAt(0)); Assert.AreEqual(new Segment2D(pointB, pointA), soilLayer.OuterLoop.ElementAt(1)); @@ -159,18 +158,17 @@ } [Test] - public void CreateSoilLayer2DForTransforming_ParameterLess_ExpectedProperties() + public void CreateSoilLayer2DWithValidAquifer_ParameterLess_ExpectedProperties() { - // Setup + // Call + SoilLayer2D soilLayer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); + + // Assert var pointA = new Point2D(0.0, 0.0); var pointB = new Point2D(1.0, 0.0); var pointC = new Point2D(1.0, 1.0); var pointD = new Point2D(2.0, 1.0); - // Call - SoilLayer2D soilLayer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); - - // Assert Assert.AreEqual(0.0, soilLayer.IsAquifer); Assert.AreEqual(new Segment2D(pointA, pointB), soilLayer.OuterLoop.ElementAt(0)); Assert.AreEqual(new Segment2D(pointB, pointA), soilLayer.OuterLoop.ElementAt(1)); @@ -181,10 +179,10 @@ } [Test] - public void CreateSoilLayer2DForTransforming_InnerLoopNull_ThrowsArgumentNullException() + public void CreateSoilLayer2DWithValidAquifer_InnerLoopNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + TestDelegate call = () => SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( null, Enumerable.Empty()); @@ -194,10 +192,10 @@ } [Test] - public void CreateSoilLayer2DForTransforming_OuterLoopNull_ThrowsArgumentNullException() + public void CreateSoilLayer2DWithValidAquifer_OuterLoopNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + TestDelegate call = () => SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( Enumerable.Empty(), null); @@ -207,15 +205,15 @@ } [Test] - public void CreateSoilLayer2DValidForTransforming_InvalidInnerLoop_ThrowsArgumentException() + public void CreateSoilLayer2DWithValidAquifer_InvalidInnerLoop_ThrowsArgumentException() { // Setup var pointA = new Point2D(0.0, 0.0); var pointB = new Point2D(1.0, 0.0); var pointC = new Point2D(1.0, 1.0); // Call - TestDelegate test = () => SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + TestDelegate test = () => SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( new[] { new[] @@ -231,15 +229,15 @@ } [Test] - public void CreateSoilLayer2DForTransforming_InvalidOuterLoop_ThrowsArgumentException() + public void CreateSoilLayer2DWithValidAquifer_InvalidOuterLoop_ThrowsArgumentException() { // Setup var pointA = new Point2D(0.0, 0.0); var pointB = new Point2D(1.0, 0.0); var pointC = new Point2D(1.0, 1.0); // Call - TestDelegate test = () => SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + TestDelegate test = () => SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( Enumerable.Empty(), new[] { @@ -253,7 +251,7 @@ } [Test] - public void CreateSoilLayer2DForTransforming_ValidArguments_ExpectedProperties() + public void CreateSoilLayer2DWithValidAquifer_ValidArguments_ExpectedProperties() { // Setup var pointA = new Point2D(0.0, 0.0); @@ -262,7 +260,7 @@ var pointD = new Point2D(2.0, 1.0); // Call - SoilLayer2D soilLayer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + SoilLayer2D soilLayer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( new[] { new[] Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/SoilLayer1DTestFactory.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/SoilLayer1DTestFactory.cs (.../SoilLayer1DTestFactory.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/SoilLayer1DTestFactory.cs (.../SoilLayer1DTestFactory.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -30,12 +30,12 @@ public static class SoilLayer1DTestFactory { /// - /// Creates a new instance of which can be used - /// for testing transformer implementations. + /// Creates a new instance of with a valid value for the + /// . /// - /// The value of the + /// The value of the . /// The created . - public static SoilLayer1D CreateSoilLayer1DForTransforming(double top = 3.14) + public static SoilLayer1D CreateSoilLayer1DWithValidAquifer(double top = 3.14) { return new SoilLayer1D(top) { Index: Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/SoilLayer2DTestFactory.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/SoilLayer2DTestFactory.cs (.../SoilLayer2DTestFactory.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Common/test/Ringtoets.Common.IO.TestUtil/SoilLayer2DTestFactory.cs (.../SoilLayer2DTestFactory.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -96,10 +96,10 @@ /// /// Creates a new instance of - /// which can be used for testing transformer implementations. + /// with a valid value for . /// /// The created . - public static SoilLayer2D CreateSoilLayer2DForTransforming() + public static SoilLayer2D CreateSoilLayer2DWithValidAquifer() { SoilLayer2D layer = CreateSoilLayer2D(); layer.IsAquifer = 0.0; @@ -108,8 +108,8 @@ } /// - /// Creates a new instance of which can be - /// used for testing transformer implementations. + /// Creates a new instance of with a valid value + /// for . /// /// The inner loops of the , /// for which each of the segments are connected to the next. @@ -119,8 +119,8 @@ /// Thrown when any input parameter is null. /// Thrown when the in /// or do not form a loop. - public static SoilLayer2D CreateSoilLayer2DForTransforming(IEnumerable> innerLoops, - IEnumerable outerLoop) + public static SoilLayer2D CreateSoilLayer2DWithValidAquifer(IEnumerable> innerLoops, + IEnumerable outerLoop) { SoilLayer2D layer = CreateSoilLayer2D(innerLoops, outerLoop); layer.IsAquifer = 0.0; Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs =================================================================== diff -u -rc875fba42a23b742e55f8798f93fddf2f872e282 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs (.../MacroStabilityInwardsSoilLayerTransformer.cs) (revision c875fba42a23b742e55f8798f93fddf2f872e282) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilLayerTransformer.cs (.../MacroStabilityInwardsSoilLayerTransformer.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -110,7 +110,7 @@ properties.UsePop = TransformUsePop(soilLayer.UsePop); properties.MaterialName = soilLayer.MaterialName; - properties.IsAquifer = SoilLayerIsAquiferConverter.Convert(soilLayer.IsAquifer); + properties.IsAquifer = TransformIsAquifer(soilLayer.IsAquifer); properties.Color = SoilLayerColorConverter.Convert(soilLayer.Color); properties.AbovePhreaticLevelMean = soilLayer.AbovePhreaticLevelMean; properties.AbovePhreaticLevelCoefficientOfVariation = soilLayer.AbovePhreaticLevelCoefficientOfVariation; @@ -130,6 +130,35 @@ properties.PopCoefficientOfVariation = soilLayer.PopCoefficientOfVariation; } + /// + /// Transforms a to a for the + /// is aquifer property of soil layers. + /// + /// The value to transform. + /// A based on . + /// Thrown when + /// could not be transformed. + private static bool TransformIsAquifer(double? isAquifer) + { + try + { + return SoilLayerIsAquiferConverter.Convert(isAquifer); + } + catch (NotSupportedException) + { + throw new ImportedDataTransformException(string.Format(Resources.MacroStabilityInwardsSoilLayerTransformer_Invalid_value_ParameterName_0, + RingtoetsCommonIOResources.SoilLayerProperties_IsAquifer_Name)); + } + } + + /// + /// Transforms a to a for the + /// use POP property of soil layers. + /// + /// The value to transform. + /// A based on . + /// Thrown when + /// could not be transformed. private static bool TransformUsePop(double? usePop) { if (!usePop.HasValue) @@ -146,6 +175,15 @@ Resources.SoilLayerProperties_UsePop_Description)); } + /// + /// Transforms a to a for the + /// shear strength model of soil layers. + /// + /// The value to transform. + /// A based + /// on . + /// Thrown when + /// could not be transformed. private static MacroStabilityInwardsShearStrengthModel TransformShearStrengthModel(double? shearStrengthModel) { if (!shearStrengthModel.HasValue) Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs =================================================================== diff -u -rc71f15ef23debdc4df0719145291de37aea66c97 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs (.../MacroStabilityInwardsStochasticSoilModelTransformer.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformer.cs (.../MacroStabilityInwardsStochasticSoilModelTransformer.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -73,7 +73,7 @@ string soilModelName) { IEnumerable profilesToTransform = - StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles, + StochasticSoilProfileHelper.GetValidatedStochasticSoilProfilesToTransform(stochasticSoilProfiles, soilModelName); return profilesToTransform.Select( Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilProfileTransformer.cs =================================================================== diff -u -r9622873faf35255d36a4543501d4788baa399af7 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilProfileTransformer.cs (.../MacroStabilityInwardsStochasticSoilProfileTransformer.cs) (revision 9622873faf35255d36a4543501d4788baa399af7) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsStochasticSoilProfileTransformer.cs (.../MacroStabilityInwardsStochasticSoilProfileTransformer.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -28,7 +28,7 @@ { /// /// Transforms generic into - /// + /// . /// internal static class MacroStabilityInwardsStochasticSoilProfileTransformer { Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs =================================================================== diff -u -rc875fba42a23b742e55f8798f93fddf2f872e282 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs (.../MacroStabilityInwardsSoilLayerTransformerTest.cs) (revision c875fba42a23b742e55f8798f93fddf2f872e282) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilLayerTransformerTest.cs (.../MacroStabilityInwardsSoilLayerTransformerTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -136,7 +136,7 @@ public void SoilLayer1DTransform_ValidUsePopValue_ReturnMacroStabilityInwardSoilLayer1D(double? usePop, bool transformedUsePopValue) { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.UsePop = usePop; // Call @@ -150,7 +150,7 @@ public void SoilLayer1DTransform_InvalidUsePopValue_ThrowsImportedDataTransformationException() { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.UsePop = 1; // Call @@ -170,7 +170,7 @@ MacroStabilityInwardsShearStrengthModel transformedShearStrengthModel) { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.ShearStrengthModel = sheartStrengthModel; // Call @@ -184,7 +184,7 @@ public void SoilLayer1DTransform_InvalidShearStrengthModelValue_ThrowsImportedDataTransformException() { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.ShearStrengthModel = 2; // Call @@ -201,7 +201,7 @@ public void SoilLayer1DTransform_ValidIsAquifer_ReturnsMacroStabilityInwardsSoilLayer1D(double isAquifer, bool transformedIsAquifer) { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.IsAquifer = isAquifer; // Call @@ -218,7 +218,7 @@ public void SoilLayer1DTransform_InvalidIsAquifer_ThrowsImportedDataException(double? isAquifer) { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.IsAquifer = isAquifer; // Call @@ -234,7 +234,7 @@ public void SoilLayer1DTransform_ValidColors_ReturnsMacroStabilityInwardsSoilLayer1D(double? color, Color transformedColor) { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.Color = color; // Call @@ -365,7 +365,7 @@ public void SoilLayer2DTransform_ValidUsePopValue_ReturnMacroStabilityInwardSoilLayer2D(double? usePop, bool transformedUsePopValue) { // Setup - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); layer.UsePop = usePop; // Call @@ -379,7 +379,7 @@ public void SoilLayer2DTransform_InvalidUsePopValue_ReturnMacroStabilityInwardSoilLayer2D() { // Setup - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); layer.UsePop = 1; // Call @@ -399,7 +399,7 @@ MacroStabilityInwardsShearStrengthModel transformedShearStrengthModel) { // Setup - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); layer.ShearStrengthModel = sheartStrengthModel; // Call @@ -430,7 +430,7 @@ public void SoilLayer2DTransform_ValidIsAquifer_ReturnsMacroStabilityInwardsSoilLayer2D(double isAquifer, bool transformedIsAquifer) { // Setup - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); layer.IsAquifer = isAquifer; // Call @@ -447,7 +447,7 @@ public void SoilLayer2DTransform_InvalidIsAquifer_ThrowsImportedDataException(double? isAquifer) { // Setup - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); layer.IsAquifer = isAquifer; // Call @@ -463,7 +463,7 @@ public void SoilLayer2DTransform_ValidColors_ReturnsMacroStabilityInwardsSoilLayer2D(double? color, Color transformedColor) { // Setup - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); layer.Color = color; // Call Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilProfileTransformerTest.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilProfileTransformerTest.cs (.../MacroStabilityInwardsSoilProfileTransformerTest.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilProfileTransformerTest.cs (.../MacroStabilityInwardsSoilProfileTransformerTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -70,7 +70,7 @@ // Setup var profile = new SoilProfile1D(1, "test", 3, new[] { - SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming() + SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer() }); // Call @@ -89,7 +89,7 @@ // Setup var profile = new SoilProfile2D(1, "test", new[] { - SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming() + SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer() }); // Call Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformerTest.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformerTest.cs (.../MacroStabilityInwardsStochasticSoilModelTransformerTest.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsStochasticSoilModelTransformerTest.cs (.../MacroStabilityInwardsStochasticSoilModelTransformerTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -93,7 +93,7 @@ { new StochasticSoilProfile(1, new SoilProfile1D(2, "test", 3, new[] { - SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(top) + SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top) })) } }; @@ -132,7 +132,7 @@ { new StochasticSoilProfile(1, new SoilProfile2D(2, "test", new[] { - SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming() + SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer() })) } }; @@ -174,7 +174,7 @@ public void Transform_TwoStochasticSoilModelsWithSameProfile_ReturnExpectedMacroStabilityInwardsStochasticSoilModel() { // Setup - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); var profile = new SoilProfile2D(2, "test", new[] { layer @@ -221,7 +221,7 @@ const string soilProfileName = "SoilProfile"; const double intersectionX = 1.0; - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); var profile = new SoilProfile2D(0, soilProfileName, new[] { layer @@ -279,19 +279,16 @@ }; var transformer = new MacroStabilityInwardsStochasticSoilModelTransformer(); - MacroStabilityInwardsStochasticSoilModel transformed = null; // Call - TestDelegate call = () => transformed = transformer.Transform(soilModel); + TestDelegate call = () => 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(); } @@ -305,7 +302,7 @@ var soilProfile2D = new SoilProfile2D(0, soilProfileName, new[] { - SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming() + SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer() }) { IntersectionX = intersectionX @@ -314,7 +311,7 @@ var soilProfile1D = new SoilProfile1D(0, soilProfileName, 0, new[] { - SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming() + SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer() }); var stochasticSoilProfile1D = new StochasticSoilProfile(0.7, soilProfile1D); Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilLayerTransformer.cs (.../PipingSoilLayerTransformer.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -28,6 +28,7 @@ using Ringtoets.Common.IO.SoilProfile; using Ringtoets.Piping.IO.Properties; using Ringtoets.Piping.Primitives; +using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources; namespace Ringtoets.Piping.IO.SoilProfiles { @@ -55,7 +56,7 @@ var pipingSoilLayer = new PipingSoilLayer(soilLayer.Top) { - IsAquifer = SoilLayerIsAquiferConverter.Convert(soilLayer.IsAquifer), + IsAquifer = TransformIsAquifer(soilLayer.IsAquifer), MaterialName = soilLayer.MaterialName, Color = SoilLayerColorConverter.Convert(soilLayer.Color) }; @@ -102,7 +103,7 @@ { var pipingSoilLayer = new PipingSoilLayer(height) { - IsAquifer = SoilLayerIsAquiferConverter.Convert(soilLayer.IsAquifer), + IsAquifer = TransformIsAquifer(soilLayer.IsAquifer), MaterialName = soilLayer.MaterialName, Color = SoilLayerColorConverter.Convert(soilLayer.Color) }; @@ -229,5 +230,26 @@ { return segment.FirstPoint.X.Equals(atX) && segment.IsVertical(); } + + /// + /// Transforms a to a for the + /// . + /// + /// The value to transform. + /// A based on . + /// Thrown when + /// could not be transformed. + private static bool TransformIsAquifer(double? isAquifer) + { + try + { + return SoilLayerIsAquiferConverter.Convert(isAquifer); + } + catch (NotSupportedException) + { + throw new ImportedDataTransformException(string.Format(RingtoetsCommonIOResources.Convert_Invalid_value_ParameterName_0, + RingtoetsCommonIOResources.SoilLayerProperties_IsAquifer_Name)); + } + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs =================================================================== diff -u -rc71f15ef23debdc4df0719145291de37aea66c97 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (.../PipingStochasticSoilModelTransformer.cs) (revision c71f15ef23debdc4df0719145291de37aea66c97) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingStochasticSoilModelTransformer.cs (.../PipingStochasticSoilModelTransformer.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -72,7 +72,7 @@ string soilModelName) { IEnumerable profilesToTransform = - StochasticSoilProfileHelper.GetValidatedStochasticProfilesToTransform(stochasticSoilProfiles, + StochasticSoilProfileHelper.GetValidatedStochasticSoilProfilesToTransform(stochasticSoilProfiles, soilModelName); return profilesToTransform.Select(ssp => PipingStochasticSoilProfileTransformer.Transform( Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs (.../PipingSoilLayerTransformerTest.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilLayerTransformerTest.cs (.../PipingSoilLayerTransformerTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -70,7 +70,7 @@ public void SoilLayer1DTransform_ValidIsAquifer_ReturnsPipingSoilLayer1D(double isAquifer, bool transformedIsAquifer) { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.IsAquifer = isAquifer; // Call @@ -87,7 +87,7 @@ public void SoilLayer1DTransform_InvalidIsAquifer_ThrowsImportedDataException(double? isAquifer) { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.IsAquifer = isAquifer; // Call @@ -103,7 +103,7 @@ public void SoilLayer1DTransform_ValidColors_ReturnsMacroStabilityInwardsSoilLayer1D(double? color, Color transformedColor) { // Setup - SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(); + SoilLayer1D layer = SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(); layer.Color = color; // Call @@ -433,7 +433,7 @@ { // Setup double expectedZ = new Random(22).NextDouble(); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new List(), new List + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new List(), new List { new Segment2D(new Point2D(-0.1, expectedZ), new Point2D(0.1, expectedZ)), @@ -467,7 +467,7 @@ "..4..3..", "........")); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new List(), outerLoop); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new List(), outerLoop); double bottom; @@ -502,7 +502,7 @@ "...43...", "........")); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new[] + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new[] { innerLoop }, outerLoop); @@ -540,7 +540,7 @@ "...4.3..", "........")); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new[] + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new[] { innerLoop }, outerLoop); @@ -589,7 +589,7 @@ "...12...", "........")); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new[] + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new[] { innerLoop, innerLoop2 @@ -629,7 +629,7 @@ "........", "...43...")); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new[] + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new[] { innerLoop }, outerLoop); @@ -676,7 +676,7 @@ "........", "...43...")); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new[] + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new[] { innerLoop, innerLoop2 @@ -714,7 +714,7 @@ "...43...", "........")); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new[] + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new[] { innerLoop }, outerLoop); @@ -752,7 +752,7 @@ List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( innerLoopWide); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new[] + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new[] { innerLoop }, outerLoop); @@ -782,7 +782,7 @@ List innerLoop = Segment2DLoopCollectionHelper.CreateFromString( innerLoopWide); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new[] + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new[] { innerLoop }, outerLoop); @@ -907,8 +907,7 @@ new Point2D(x1, y2)) }; - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(Enumerable.Empty>(), outerLoop); - return layer; + return SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(Enumerable.Empty>(), outerLoop); } private static IEnumerable IncorrectLogNormalDistributionsSoilLayer1D() Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilProfileTransformerTest.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilProfileTransformerTest.cs (.../PipingSoilProfileTransformerTest.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingSoilProfileTransformerTest.cs (.../PipingSoilProfileTransformerTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -90,7 +90,7 @@ const double bottom = 0.5; const double intersectionX = 1.0; - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(new List(), + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(new List(), new List { new Segment2D(new Point2D(1.0, bottom), @@ -185,7 +185,7 @@ var thirdPoint = new Point2D(0.5, -1.0); var fourthPoint = new Point2D(-0.5, -1.0); - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( new List(), new List { @@ -224,7 +224,7 @@ var profile = new SoilProfile2D(pipingSoilProfileId, profileName, new List { - SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( new List(), Segment2DLoopCollectionHelper.CreateFromString( string.Join(Environment.NewLine, @@ -239,7 +239,7 @@ "1.2", "4.3", "..."))), - SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( new List(), Segment2DLoopCollectionHelper.CreateFromString( string.Join(Environment.NewLine, @@ -254,7 +254,7 @@ "1.2", "...", "..."))), - SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( new List(), Segment2DLoopCollectionHelper.CreateFromString( string.Join(Environment.NewLine, @@ -305,7 +305,7 @@ ".....", ".....")); - SoilLayer2D soilLayer2D = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + SoilLayer2D soilLayer2D = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( new[] { loopHole @@ -323,7 +323,7 @@ new List { soilLayer2D, - SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming( + SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer( new List(), loopHole) } @@ -363,7 +363,7 @@ bottom, new[] { - SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(top) + SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top) } ); @@ -396,8 +396,8 @@ bottom, new[] { - SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(top), - SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming(top2) + SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top), + SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer(top2) } ); Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs =================================================================== diff -u -r86320df646dfe8564940e686a98d6199b9c3b470 -rec201316303aa676976655dcdfd9285dcc3ec4f1 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.cs) (revision 86320df646dfe8564940e686a98d6199b9c3b470) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfiles/PipingStochasticSoilModelTransformerTest.cs (.../PipingStochasticSoilModelTransformerTest.cs) (revision ec201316303aa676976655dcdfd9285dcc3ec4f1) @@ -135,7 +135,7 @@ const string name = "name"; const double intersectionX = 1.0; - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); var profile = new SoilProfile2D(0, "SoilProfile2D", new[] { layer @@ -180,7 +180,7 @@ const string name = "name"; const double intersectionX = 1.0; - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); var profile = new SoilProfile2D(0, "SoilProfile2D", new[] { layer @@ -229,7 +229,7 @@ const string soilProfileName = "SoilProfile"; const double intersectionX = 1.0; - SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming(); + SoilLayer2D layer = SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer(); var profile = new SoilProfile2D(0, soilProfileName, new[] { layer @@ -268,7 +268,7 @@ [Test] [SetCulture("nl-NL")] - public void Transform_ValidStochasticSoilModelWithSameProfileProbabilitExceedingValidRange_ThrowsImportedDataException() + public void Transform_ValidStochasticSoilModelWithSameProfileProbabilityExceedingValidRange_ThrowsImportedDataException() { // Setup const string soilModelName = "name"; @@ -287,19 +287,16 @@ }; var transformer = new PipingStochasticSoilModelTransformer(); - PipingStochasticSoilModel transformed = null; // Call - TestDelegate call = () => transformed = transformer.Transform(soilModel); + TestDelegate call = () => 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(); } @@ -313,7 +310,7 @@ var soilProfile2D = new SoilProfile2D(0, soilProfileName, new[] { - SoilLayer2DTestFactory.CreateSoilLayer2DForTransforming() + SoilLayer2DTestFactory.CreateSoilLayer2DWithValidAquifer() }) { IntersectionX = intersectionX @@ -322,7 +319,7 @@ var soilProfile1D = new SoilProfile1D(0, soilProfileName, 0, new[] { - SoilLayer1DTestFactory.CreateSoilLayer1DForTransforming() + SoilLayer1DTestFactory.CreateSoilLayer1DWithValidAquifer() }); var stochasticSoilProfile1D = new StochasticSoilProfile(0.2, soilProfile1D);