Index: Ringtoets/Common/src/Ringtoets.Common.IO/IDistributionExtensions.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/IDistributionExtensions.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/IDistributionExtensions.cs (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -0,0 +1,149 @@ +// Copyright (C) Stichting Deltares 2016. 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 Core.Common.Base.Data; +using log4net; +using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.IO.FileImporters; +using Ringtoets.Common.IO.Properties; + +namespace Ringtoets.Common.IO +{ + /// + /// Extension methods for , related to the scope of + /// . + /// + public static class IDistributionExtensions + { + private static readonly ILog log = LogManager.GetLogger(typeof(IDistributionExtensions)); + + /// + /// Attempts to set the parameters of an . + /// + /// The to be updated. + /// The new value for . + /// The new value for . + /// The descriptive name of . + /// The name of the calculation to which + /// is associated. + /// true if setting all properties was successful, false otherwise. + /// Thrown when + /// is null. + public static bool TrySetDistributionProperties(this IDistribution distribution, + double? mean, double? standardDeviation, + string stochastName, string calculationName) + { + return distribution.TrySetMean(mean, stochastName, calculationName) + && distribution.TrySetStandardDeviation(standardDeviation, stochastName, calculationName); + } + + /// + /// Attempts to set . + /// + /// The to be updated. + /// The new value for . + /// The descriptive name of . + /// The name of the calculation to which + /// is associated. + /// true if setting was successful, + /// false otherwise. + /// Thrown when + /// is null. + public static bool TrySetMean(this IDistribution distribution, double? mean, + string stochastName, string calculationName) + { + if (distribution == null) + { + throw new ArgumentNullException(nameof(distribution)); + } + + if (mean.HasValue) + { + try + { + distribution.Mean = (RoundedDouble) mean.Value; + } + catch (ArgumentOutOfRangeException e) + { + string errorMessage = string.Format( + Resources.IDistributionExtensions_TrySetMean_Mean_0_is_invalid_for_Stochast_1_, + mean, stochastName); + + LogOutOfRangeException(errorMessage, + calculationName, + e); + + return false; + } + } + return true; + } + + /// + /// Attempts to set . + /// + /// The to be updated. + /// The new value for . + /// The descriptive name of . + /// The name of the calculation to which + /// is associated. + /// true if setting + /// was successful, false otherwise. + /// Thrown when + /// is null. + public static bool TrySetStandardDeviation(this IDistribution distribution, double? standardDeviation, + string stochastName, string calculationName) + { + if (distribution == null) + { + throw new ArgumentNullException(nameof(distribution)); + } + + if (standardDeviation.HasValue) + { + try + { + distribution.StandardDeviation = (RoundedDouble) standardDeviation.Value; + } + catch (ArgumentOutOfRangeException e) + { + string errorMessage = string.Format( + Resources.IDistributionExtensions_TrySetStandardDeviation_StandardDeviation_0_is_invalid_for_Stochast_1_, + standardDeviation, stochastName); + + LogOutOfRangeException(errorMessage, + calculationName, + e); + + return false; + } + } + return true; + } + + private static void LogOutOfRangeException(string errorMessage, string calculationName, ArgumentOutOfRangeException e) + { + log.ErrorFormat(Resources.CalculationConfigurationImporter_ValidateCalculation_ErrorMessage_0_Calculation_1_skipped, + $"{errorMessage} {e.Message}", calculationName); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r7abe7a22648e3af0a350e60b21e3c61bb5fb6124 -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7abe7a22648e3af0a350e60b21e3c61bb5fb6124) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -762,6 +762,25 @@ } /// + /// Looks up a localized string similar to Een gemiddelde van '{0}' is ongeldig voor stochast '{1}'.. + /// + public static string IDistributionExtensions_TrySetMean_Mean_0_is_invalid_for_Stochast_1_ { + get { + return ResourceManager.GetString("IDistributionExtensions_TrySetMean_Mean_0_is_invalid_for_Stochast_1_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Een standaardafwijking van '{0}' is ongeldig voor stochast '{1}'.. + /// + public static string IDistributionExtensions_TrySetStandardDeviation_StandardDeviation_0_is_invalid_for_Stochast_1_ { + get { + return ResourceManager.GetString("IDistributionExtensions_TrySetStandardDeviation_StandardDeviation_0_is_invalid_fo" + + "r_Stochast_1_", resourceCulture); + } + } + + /// /// Looks up a localized string similar to TRAJECT_ID;N ///1-1;3 ///1-2;2 Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r663cebcf16e17eec70865851a53c3aa521877a65 -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 663cebcf16e17eec70865851a53c3aa521877a65) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -568,4 +568,10 @@ Het XML-document dat de configuratie voor de berekeningen beschrijft is niet geldig. De validatie geeft de volgende melding: {0} + + Een gemiddelde van '{0}' is ongeldig voor stochast '{1}'. + + + Een standaardafwijking van '{0}' is ongeldig voor stochast '{1}'. + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -r5d8bda6e12681d1c019b449b298c464921a06ed7 -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 5d8bda6e12681d1c019b449b298c464921a06ed7) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -57,6 +57,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/IDistributionExtensionsTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/IDistributionExtensionsTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/IDistributionExtensionsTest.cs (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -0,0 +1,317 @@ +// Copyright (C) Stichting Deltares 2016. 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 Core.Common.Base.Data; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.Probabilistics; + +namespace Ringtoets.Common.IO.Test +{ + [TestFixture] + public class IDistributionExtensionsTest + { + [Test] + public void TrySetMean_DistributionNull_ThrownArgumentNullException() + { + // Setup + IDistribution distribution = null; + + const double mean = 1.1; + + // Call + TestDelegate call = () => distribution.TrySetMean(mean, "A", "B"); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("distribution", paramName); + } + + [Test] + public void TrySetMean_MeanNull_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var distribution = mocks.StrictMock(); + mocks.ReplayAll(); + + // Call + bool result = distribution.TrySetMean(null, "A", "B"); + + // Assert + Assert.IsTrue(result); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetMean_MeanValid_SetMeanAndReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var distribution = mocks.Stub(); + mocks.ReplayAll(); + + const double mean = 1.1; + + // Call + bool result = distribution.TrySetMean(mean, "A", "B"); + + // Assert + Assert.AreEqual(mean, distribution.Mean); + Assert.IsTrue(result); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetMean_SettingMeanThrowArgumentOutOfRangeException_LogErrorAndReturnFalse() + { + // Setup + const string exceptionMessage = "A"; + var mocks = new MockRepository(); + var distribution = mocks.StrictMock(); + distribution.Expect(d => d.Mean) + .SetPropertyAndIgnoreArgument() + .Throw(new ArgumentOutOfRangeException(null, exceptionMessage)); + mocks.ReplayAll(); + + const int mean = 5; + const string stochastName = "B"; + const string calculationName = "C"; + + // Call + bool result = true; + Action call = () => result = distribution.TrySetMean(mean, "B", "C"); + + // Assert + var expectedMessage = Tuple.Create($"Een gemiddelde van '{mean}' is ongeldig voor stochast '{stochastName}'. " + + exceptionMessage + + $" Berekening '{calculationName}' is overgeslagen.", + LogLevelConstant.Error); + TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1); + Assert.IsFalse(result); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetStandardDeviation_DistributionNull_ThrownArgumentNullException() + { + // Setup + IDistribution distribution = null; + + const double mean = 1.1; + + // Call + TestDelegate call = () => distribution.TrySetStandardDeviation(mean, "A", "B"); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("distribution", paramName); + } + + [Test] + public void TrySetStandardDeviation_StandardDeviationNull_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var distribution = mocks.StrictMock(); + mocks.ReplayAll(); + + // Call + bool result = distribution.TrySetStandardDeviation(null, "A", "B"); + + // Assert + Assert.IsTrue(result); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetStandardDeviation_StandardDeviationValid_SetStandardDeviationAndReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var distribution = mocks.Stub(); + mocks.ReplayAll(); + + const double standardDeviation = 1.1; + + // Call + bool result = distribution.TrySetStandardDeviation(standardDeviation, "A", "B"); + + // Assert + Assert.AreEqual(standardDeviation, distribution.StandardDeviation); + Assert.IsTrue(result); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetStandardDeviation_SettingStandardDeviationThrowArgumentOutOfRangeException_LogErrorAndReturnFalse() + { + // Setup + const string exceptionMessage = "A"; + var mocks = new MockRepository(); + var distribution = mocks.StrictMock(); + distribution.Expect(d => d.StandardDeviation) + .SetPropertyAndIgnoreArgument() + .Throw(new ArgumentOutOfRangeException(null, exceptionMessage)); + mocks.ReplayAll(); + + const int standardDeviation = 5; + const string stochastName = "B"; + const string calculationName = "C"; + + // Call + bool result = true; + Action call = () => result = distribution.TrySetStandardDeviation(standardDeviation, "B", "C"); + + // Assert + var expectedMessage = Tuple.Create($"Een standaardafwijking van '{standardDeviation}' is ongeldig voor stochast '{stochastName}'. " + + exceptionMessage + + $" Berekening '{calculationName}' is overgeslagen.", + LogLevelConstant.Error); + TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1); + Assert.IsFalse(result); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetDistributionProperties_DistributionNull_ThrownArgumentNullException() + { + // Setup + IDistribution distribution = null; + + const double mean = 1.1; + const double standardDeviation = 2.2; + + // Call + TestDelegate call = () => distribution.TrySetDistributionProperties(mean, standardDeviation, "A", "B"); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("distribution", paramName); + } + + [Test] + [TestCase(null, null)] + [TestCase(1.0, null)] + [TestCase(null, 2.0)] + [TestCase(3.0, 4.0)] + public void TrySetMean_ValidValue_ReturnTrue(double? mean, double? standardDeviation) + { + // Setup + var defaultMean = new RoundedDouble(2, -1.0); + var defaultStandardDeviation = new RoundedDouble(2, -2.0); + + var mocks = new MockRepository(); + var distribution = mocks.Stub(); + mocks.ReplayAll(); + + distribution.Mean = defaultMean; + distribution.StandardDeviation = defaultStandardDeviation; + + // Call + bool result = distribution.TrySetDistributionProperties(mean, standardDeviation, "A", "B"); + + // Assert + Assert.IsTrue(result); + + Assert.AreEqual(mean ?? defaultMean.Value, distribution.Mean.Value); + Assert.AreEqual(standardDeviation ?? defaultStandardDeviation.Value, distribution.StandardDeviation.Value); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetDistributionProperties_SettingMeanThrowArgumentOutOfRangeException_LogErrorAndReturnFalse() + { + // Setup + const string exceptionMessage = "A"; + var mocks = new MockRepository(); + var distribution = mocks.StrictMock(); + distribution.Expect(d => d.Mean) + .SetPropertyAndIgnoreArgument() + .Throw(new ArgumentOutOfRangeException(null, exceptionMessage)); + distribution.Stub(d => d.StandardDeviation) + .SetPropertyAndIgnoreArgument() + .Repeat.Any(); + mocks.ReplayAll(); + + const int mean = 5; + const string stochastName = "B"; + const string calculationName = "C"; + + // Call + bool result = true; + Action call = () => result = distribution.TrySetDistributionProperties(mean, 2.2, "B", "C"); + + // Assert + var expectedMessage = Tuple.Create($"Een gemiddelde van '{mean}' is ongeldig voor stochast '{stochastName}'. " + + exceptionMessage + + $" Berekening '{calculationName}' is overgeslagen.", + LogLevelConstant.Error); + TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1); + Assert.IsFalse(result); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetDistributionProperties_SettingStandardDeviationThrowArgumentOutOfRangeException_LogErrorAndReturnFalse() + { + // Setup + const string exceptionMessage = "A"; + var mocks = new MockRepository(); + var distribution = mocks.StrictMock(); + distribution.Expect(d => d.StandardDeviation) + .SetPropertyAndIgnoreArgument() + .Throw(new ArgumentOutOfRangeException(null, exceptionMessage)); + distribution.Stub(d => d.Mean) + .SetPropertyAndIgnoreArgument() + .Repeat.Any(); + mocks.ReplayAll(); + + const int standardDeviation = 5; + const string stochastName = "B"; + const string calculationName = "C"; + + // Call + bool result = true; + Action call = () => result = distribution.TrySetDistributionProperties(1.1, standardDeviation, "B", "C"); + + // Assert + var expectedMessage = Tuple.Create($"Een standaardafwijking van '{standardDeviation}' is ongeldig voor stochast '{stochastName}'. " + + exceptionMessage + + $" Berekening '{calculationName}' is overgeslagen.", + LogLevelConstant.Error); + TestHelper.AssertLogMessageWithLevelIsGenerated(call, expectedMessage, 1); + Assert.IsFalse(result); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj =================================================================== diff -u -r5d8bda6e12681d1c019b449b298c464921a06ed7 -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 5d8bda6e12681d1c019b449b298c464921a06ed7) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -62,6 +62,7 @@ + Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs =================================================================== diff -u -r133c79b0999dee3f9c2f02c5382687c0a173d2a4 -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision 133c79b0999dee3f9c2f02c5382687c0a173d2a4) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -27,6 +27,7 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.IO; using Ringtoets.Common.IO.FileImporters; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.IO.Properties; @@ -280,73 +281,18 @@ { var distribution = (LogNormalDistribution) calculation.InputParameters.CriticalFlowRate.Clone(); - if (readCalculation.CriticalFlowRateMean.HasValue) + if (!distribution.TrySetDistributionProperties(readCalculation.CriticalFlowRateMean, + readCalculation.CriticalFlowRateStandardDeviation, + GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.CriticalFlowRateStochastName, + calculation.Name)) { - double criticalFlowRateMean = readCalculation.CriticalFlowRateMean.Value; - - if (!SetMean(distribution, criticalFlowRateMean, calculation.Name)) - { - return false; - } + return false; } - if (readCalculation.CriticalFlowRateStandardDeviation.HasValue) - { - double criticalFlowRateStandardDeviation = readCalculation.CriticalFlowRateStandardDeviation.Value; - if (!SetStandardDeviation(distribution, criticalFlowRateStandardDeviation, calculation.Name)) - { - return false; - } - } - calculation.InputParameters.CriticalFlowRate = distribution; return true; } - private bool SetMean(LogNormalDistribution distribution, double criticalFlowRateMean, string calculationName) - { - try - { - distribution.Mean = (RoundedDouble) criticalFlowRateMean; - } - catch (ArgumentOutOfRangeException e) - { - string errorMessage = string.Format( - Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ReadCriticalWaveReduction_ReadCriticalWaveReductionMean_0_invalid, - criticalFlowRateMean); - - LogOutOfRangeException( - errorMessage, - calculationName, - e); - - return false; - } - return true; - } - - private bool SetStandardDeviation(LogNormalDistribution distribution, double criticalFlowRateStandardDeviation, string calculationName) - { - try - { - distribution.StandardDeviation = (RoundedDouble) criticalFlowRateStandardDeviation; - } - catch (ArgumentOutOfRangeException e) - { - string errorMessage = string.Format( - Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ReadCriticalWaveReduction_ReadCriticalWaveReductionStandardDeviation_0_invalid, - criticalFlowRateStandardDeviation); - - LogOutOfRangeException( - errorMessage, - calculationName, - e); - - return false; - } - return true; - } - /// /// Validation to check if the defined wave reduction parameters are valid. /// Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r60b9c5761bd42da110cf85a03e3e2db34109325e -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 60b9c5761bd42da110cf85a03e3e2db34109325e) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -1,25 +1,4 @@ -// Copyright (C) Stichting Deltares 2016. 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 @@ -104,26 +83,6 @@ } /// - /// Looks up a localized string similar to Een waarde van '{0}' als gemiddelde voor het kritisch overslagdebiet is ongeldig.. - /// - internal static string GrassCoverErosionInwardsCalculationConfigurationImporter_ReadCriticalWaveReduction_ReadCriticalWaveReductionMean_0_invalid { - get { - return ResourceManager.GetString("GrassCoverErosionInwardsCalculationConfigurationImporter_ReadCriticalWaveReductio" + - "n_ReadCriticalWaveReductionMean_0_invalid", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Een waarde van '{0}' als standaardafwijking voor het kritisch overslagdebiet is ongeldig.. - /// - internal static string GrassCoverErosionInwardsCalculationConfigurationImporter_ReadCriticalWaveReduction_ReadCriticalWaveReductionStandardDeviation_0_invalid { - get { - return ResourceManager.GetString("GrassCoverErosionInwardsCalculationConfigurationImporter_ReadCriticalWaveReductio" + - "n_ReadCriticalWaveReductionStandardDeviation_0_invalid", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Het dijkprofiel '{0}' bestaat niet.. /// internal static string GrassCoverErosionInwardsCalculationConfigurationImporter_ReadDikeProfile_DikeProfile_0_does_not_exist { Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx =================================================================== diff -u -r60b9c5761bd42da110cf85a03e3e2db34109325e -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision 60b9c5761bd42da110cf85a03e3e2db34109325e) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -148,10 +148,4 @@ Er is geen dijkprofiel opgegeven om de oriëntatie aan toe te voegen. - - Een waarde van '{0}' als gemiddelde voor het kritisch overslagdebiet is ongeldig. - - - Een waarde van '{0}' als standaardafwijking voor het kritisch overslagdebiet is ongeldig. - \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Importers/GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs =================================================================== diff -u -r332fd224ce5cd9c737e72f945271c52ae6d64c0d -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Importers/GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs) (revision 332fd224ce5cd9c737e72f945271c52ae6d64c0d) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Importers/GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporterTest.cs) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -96,7 +96,7 @@ public void Import_ValidConfigurationInvalidOrientation_LogMessageAndContinueImport() { // Setup - string filePath = Path.Combine(path, "validConfigurationInvalidOrientation.xml"); + string filePath = Path.Combine(path, "validConfigurationOrientationOutOfRange.xml"); var calculationGroup = new CalculationGroup(); var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter( @@ -125,7 +125,7 @@ public void Import_ValidConfigurationInvalidCriticalWaveReductionMean_LogMessageAndContinueImport() { // Setup - string filePath = Path.Combine(path, "validConfigurationInvalidCriticalWaveReductionMean.xml"); + string filePath = Path.Combine(path, "validConfigurationNegativeCriticalWaveReductionMean.xml"); var calculationGroup = new CalculationGroup(); var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter( @@ -139,7 +139,8 @@ Action call = () => successful = importer.Import(); // Assert - string expectedMessage = "Een waarde van '-1' als gemiddelde voor het kritisch overslagdebiet is ongeldig. Gemiddelde moet groter zijn dan 0. " + + string expectedMessage = "Een gemiddelde van '-1' is ongeldig voor stochast 'overslagdebiet'. " + + "Gemiddelde moet groter zijn dan 0. " + "Berekening 'Berekening 1' is overgeslagen."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsTrue(successful); @@ -151,7 +152,7 @@ public void Import_ValidConfigurationInvalidCriticalWaveReductionStandardDeviation_LogMessageAndContinueImport() { // Setup - string filePath = Path.Combine(path, "validConfigurationInvalidCriticalWaveReductionStandardDeviation.xml"); + string filePath = Path.Combine(path, "validConfigurationNegativeCriticalWaveReductionStandardDeviation.xml"); var calculationGroup = new CalculationGroup(); var importer = new GrassCoverErosionInwardsCalculationConfigurationImporter( @@ -165,7 +166,8 @@ Action call = () => successful = importer.Import(); // Assert - string expectedMessage = "Een waarde van '-2,1' als standaardafwijking voor het kritisch overslagdebiet is ongeldig. Standaardafwijking (σ) moet groter zijn dan of gelijk zijn aan 0. " + + string expectedMessage = "Een standaardafwijking van '-2,1' is ongeldig voor stochast 'overslagdebiet'. " + + "Standaardafwijking (σ) moet groter zijn dan of gelijk zijn aan 0. " + "Berekening 'Berekening 1' is overgeslagen."; TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); Assert.IsTrue(successful); Fisheye: Tag ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationInvalidCriticalWaveReductionMean.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationInvalidCriticalWaveReductionStandardDeviation.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationInvalidOrientation.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationNegativeCriticalWaveReductionMean.xml =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationNegativeCriticalWaveReductionMean.xml (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationNegativeCriticalWaveReductionMean.xml (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -0,0 +1,11 @@ + + + + + + -1.0 + 1.1 + + + + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationNegativeCriticalWaveReductionStandardDeviation.xml =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationNegativeCriticalWaveReductionStandardDeviation.xml (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationNegativeCriticalWaveReductionStandardDeviation.xml (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -0,0 +1,11 @@ + + + + + + 2.0 + -2.1 + + + + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationOrientationOutOfRange.xml =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationOrientationOutOfRange.xml (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/test-data/GrassCoverErosionInwardsCalculationConfigurationImporter/validConfigurationOrientationOutOfRange.xml (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -0,0 +1,7 @@ + + + + Dijkprofiel + 380 + + Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs =================================================================== diff -u -r332fd224ce5cd9c737e72f945271c52ae6d64c0d -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs (.../PipingCalculationConfigurationImporter.cs) (revision 332fd224ce5cd9c737e72f945271c52ae6d64c0d) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs (.../PipingCalculationConfigurationImporter.cs) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -26,6 +26,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.IO; using Ringtoets.Common.IO.FileImporters; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Properties; @@ -317,12 +318,10 @@ { var distribution = (LogNormalDistribution) pipingCalculation.InputParameters.DampingFactorExit.Clone(); - if (!TrySetDistributionParameters( - distribution, - readCalculation.DampingFactorExitMean, - readCalculation.DampingFactorExitStandardDeviation, - PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName, - pipingCalculation.Name)) + if (!distribution.TrySetDistributionProperties(readCalculation.DampingFactorExitMean, + readCalculation.DampingFactorExitStandardDeviation, + PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName, + pipingCalculation.Name)) { return false; } @@ -335,55 +334,16 @@ { var distribution = (NormalDistribution) pipingCalculation.InputParameters.PhreaticLevelExit.Clone(); - if (!TrySetDistributionParameters( - distribution, - readCalculation.PhreaticLevelExitMean, - readCalculation.PhreaticLevelExitStandardDeviation, - PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName, - pipingCalculation.Name)) + if (!distribution.TrySetDistributionProperties(readCalculation.PhreaticLevelExitMean, + readCalculation.PhreaticLevelExitStandardDeviation, + PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName, + pipingCalculation.Name)) { return false; } pipingCalculation.InputParameters.PhreaticLevelExit = distribution; return true; } - - private bool TrySetDistributionParameters(IDistribution distribution, double? mean, double? standardDeviation, string stochastName, string calculationName) - { - if (mean.HasValue) - { - try - { - distribution.Mean = (RoundedDouble) mean; - } - catch (ArgumentOutOfRangeException e) - { - LogOutOfRangeException(string.Format( - Resources.PipingCalculationConfigurationImporter_ReadStochasts_Invalid_Mean_0_for_stochast_with_StochastName_1_, - mean, stochastName), - calculationName, e); - return false; - } - } - - if (standardDeviation.HasValue) - { - try - { - distribution.StandardDeviation = (RoundedDouble) standardDeviation; - } - catch (ArgumentOutOfRangeException e) - { - LogOutOfRangeException(string.Format( - Resources.PipingCalculationConfigurationImporter_ReadStochasts_Invalid_StandardDeviation_0_for_stochast_with_StochastName_1_, - standardDeviation, stochastName), - calculationName, e); - return false; - } - } - - return true; - } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs =================================================================== diff -u -rd347acb3d57c61fd3baa1e883551807417db6698 -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -251,26 +251,6 @@ } /// - /// Looks up a localized string similar to Een gemiddelde van '{0}' is ongeldig voor stochast '{1}'.. - /// - public static string PipingCalculationConfigurationImporter_ReadStochasts_Invalid_Mean_0_for_stochast_with_StochastName_1_ { - get { - return ResourceManager.GetString("PipingCalculationConfigurationImporter_ReadStochasts_Invalid_Mean_0_for_stochast_" + - "with_StochastName_1_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Een standaardafwijking van '{0}' is ongeldig voor stochast '{1}'.. - /// - public static string PipingCalculationConfigurationImporter_ReadStochasts_Invalid_StandardDeviation_0_for_stochast_with_StochastName_1_ { - get { - return ResourceManager.GetString("PipingCalculationConfigurationImporter_ReadStochasts_Invalid_StandardDeviation_0_" + - "for_stochast_with_StochastName_1_", resourceCulture); - } - } - - /// /// Looks up a localized string similar to Er is geen profielschematisatie, maar wel een intrede- of uittredepunt opgegeven.. /// public static string PipingCalculationConfigurationImporter_ReadSurfaceLine_EntryPointL_or_ExitPointL_defined_without_SurfaceLine { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx =================================================================== diff -u -rd347acb3d57c61fd3baa1e883551807417db6698 -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision d347acb3d57c61fd3baa1e883551807417db6698) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -297,12 +297,6 @@ Een waarde van '{0}' als uittredepunt is ongeldig. - - Een gemiddelde van '{0}' is ongeldig voor stochast '{1}'. - - - Een standaardafwijking van '{0}' is ongeldig voor stochast '{1}'. - Er is geen stochastisch ondergrondmodel opgegeven bij ondergrondschematisatie '{0}'. Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Importers/WaveConditionsCalculationConfigurationImporterTest.cs =================================================================== diff -u -re4e7097f70b4e933b65f1ced9a57f3b9613c45c5 -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Importers/WaveConditionsCalculationConfigurationImporterTest.cs (.../WaveConditionsCalculationConfigurationImporterTest.cs) (revision e4e7097f70b4e933b65f1ced9a57f3b9613c45c5) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Importers/WaveConditionsCalculationConfigurationImporterTest.cs (.../WaveConditionsCalculationConfigurationImporterTest.cs) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -90,11 +90,11 @@ [Test] [SetCulture("nl-NL")] - [TestCase("validConfigurationInvalidRevetmentBoundaries.xml", + [TestCase("validConfigurationUpperRevetmentBoundBelowLowerRevetmentBound.xml", "Een waarde van '2,2' als ondergrens bekledingen is ongeldig. De bovengrens van de bekleding moet boven de ondergrens liggen.")] - [TestCase("validConfigurationInvalidWaterLevelBoundaries.xml", + [TestCase("validConfigurationUpperWaterLevelBoundBelowLowerWaterLevelBound.xml", "Een waarde van '2,2' als ondergrens van de rekenreeks is ongeldig. De bovengrens van de rekenreeks moet boven de ondergrens liggen.")] - [TestCase("validConfigurationInvalidOrientation.xml", + [TestCase("validConfigurationOrientationOutOfRange.xml", "Een waarde van '380' als oriëntatie is ongeldig. De waarde voor de oriëntatie moet in het bereik [0,00, 360,00] liggen.")] public void Import_ValidConfigurationInvalidData_LogMessageAndContinueImport(string file, string expectedErrorMessage) { Fisheye: Tag ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationInvalidOrientation.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationInvalidRevetmentBoundaries.xml'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationInvalidWaterLevelBoundaries.xml'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationOrientationOutOfRange.xml =================================================================== diff -u --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationOrientationOutOfRange.xml (revision 0) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationOrientationOutOfRange.xml (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -0,0 +1,6 @@ + + + + 380 + + Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationUpperRevetmentBoundBelowLowerRevetmentBound.xml =================================================================== diff -u --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationUpperRevetmentBoundBelowLowerRevetmentBound.xml (revision 0) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationUpperRevetmentBoundBelowLowerRevetmentBound.xml (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -0,0 +1,7 @@ + + + + 1.1 + 2.2 + + Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationUpperWaterLevelBoundBelowLowerWaterLevelBound.xml =================================================================== diff -u --- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationUpperWaterLevelBoundBelowLowerWaterLevelBound.xml (revision 0) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/test-data/WaveConditionsCalculationConfigurationImporter/validConfigurationUpperWaterLevelBoundBelowLowerWaterLevelBound.xml (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) @@ -0,0 +1,7 @@ + + + + bovengrenswaterstanden>1.1 + 2.2 + +