Index: Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs =================================================================== diff -u -r320fc1268c48766797d895a8f4ace546f35bf64c -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs (.../StructuresInputBase.cs) (revision 320fc1268c48766797d895a8f4ace546f35bf64c) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Structures/StructuresInputBase.cs (.../StructuresInputBase.cs) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -212,7 +212,7 @@ RoundedDouble newStructureNormalOrientation = value.ToPrecision(structureNormalOrientation.NumberOfDecimalPlaces); if (!double.IsNaN(newStructureNormalOrientation) && !structureNormalOrientationValidityRange.InRange(newStructureNormalOrientation)) { - throw new ArgumentOutOfRangeException(nameof(value), string.Format(Resources.Orientation_Value_needs_to_be_in_Range_0_, + throw new ArgumentOutOfRangeException(null, string.Format(Resources.Orientation_Value_needs_to_be_in_Range_0_, structureNormalOrientationValidityRange)); } structureNormalOrientation = newStructureNormalOrientation; @@ -301,7 +301,7 @@ } set { - ProbabilityHelper.ValidateProbability(value, nameof(value), Resources.FailureProbability_Value_needs_to_be_in_Range_0_); + ProbabilityHelper.ValidateProbability(value, null, Resources.FailureProbability_Value_needs_to_be_in_Range_0_); failureProbabilityStructureWithErosion = value; } } Index: Ringtoets/Common/src/Ringtoets.Common.IO/IDistributionExtensions.cs =================================================================== diff -u -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/Common/src/Ringtoets.Common.IO/IDistributionExtensions.cs (.../IDistributionExtensions.cs) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/IDistributionExtensions.cs (.../IDistributionExtensions.cs) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -23,6 +23,7 @@ using Core.Common.Base.Data; using log4net; using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.FileImporters; using Ringtoets.Common.IO.Properties; @@ -57,6 +58,26 @@ } /// + /// Attempts to set the parameters of an . + /// + /// The to be updated. + /// The configuration containing the new values for + /// and . + /// 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, + MeanStandardDeviationStochastConfiguration configuration, + string stochastName, string calculationName) + { + return distribution.TrySetMean(configuration.Mean, stochastName, calculationName) + && distribution.TrySetStandardDeviation(configuration.StandardDeviation, stochastName, calculationName); + } + + /// /// Attempts to set . /// /// The to be updated. Index: Ringtoets/Common/src/Ringtoets.Common.IO/IVariationCoefficientDistributionExtensions.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.IO/IVariationCoefficientDistributionExtensions.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.IO/IVariationCoefficientDistributionExtensions.cs (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,170 @@ +// 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.Configurations; +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 IVariationCoefficientDistributionExtensions + { + private static readonly ILog log = LogManager.GetLogger(typeof(IVariationCoefficientDistributionExtensions)); + + /// + /// 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 IVariationCoefficientDistribution distribution, + double? mean, double? variationCoefficient, + string stochastName, string calculationName) + { + return distribution.TrySetMean(mean, stochastName, calculationName) + && distribution.TrySetVariationCoefficient(variationCoefficient, stochastName, calculationName); + } + + /// + /// Attempts to set the parameters of an . + /// + /// The to be updated. + /// The configuration containing the new values for + /// and . + /// 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 IVariationCoefficientDistribution distribution, + MeanVariationCoefficientStochastConfiguration configuration, + string stochastName, string calculationName) + { + return distribution.TrySetMean(configuration.Mean, stochastName, calculationName) + && distribution.TrySetVariationCoefficient(configuration.VariationCoefficient, 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 IVariationCoefficientDistribution 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.IVariationCoefficientDistributionExtensions_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 TrySetVariationCoefficient(this IVariationCoefficientDistribution distribution, double? variationCoefficient, + string stochastName, string calculationName) + { + if (distribution == null) + { + throw new ArgumentNullException(nameof(distribution)); + } + + if (variationCoefficient.HasValue) + { + try + { + distribution.CoefficientOfVariation = (RoundedDouble) variationCoefficient.Value; + } + catch (ArgumentOutOfRangeException e) + { + string errorMessage = string.Format( + Resources.IVariationCoefficientDistributionExtensions_TrySetVariationCoefficient_VariationCoefficient_0_is_invalid_for_Stochast_1_, + variationCoefficient, 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 -r43b7d2fe7b1c4209fd2afcd985a5c1f4b7bf14e9 -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 43b7d2fe7b1c4209fd2afcd985a5c1f4b7bf14e9) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -141,6 +141,15 @@ } /// + /// Looks up a localized string similar to Het kunstwerk '{0}' bestaat niet.. + /// + public static string CalculationConfigurationImporter_ReadStructure_Structure_0_does_not_exist { + get { + return ResourceManager.GetString("CalculationConfigurationImporter_ReadStructure_Structure_0_does_not_exist", resourceCulture); + } + } + + /// /// Looks up a localized string similar to {0} Berekening '{1}' is overgeslagen.. /// public static string CalculationConfigurationImporter_ValidateCalculation_ErrorMessage_0_Calculation_1_skipped { @@ -899,6 +908,26 @@ } /// + /// Looks up a localized string similar to Een gemiddelde van '{0}' is ongeldig voor stochast '{1}'.. + /// + public static string IVariationCoefficientDistributionExtensions_TrySetMean_Mean_0_is_invalid_for_Stochast_1_ { + get { + return ResourceManager.GetString("IVariationCoefficientDistributionExtensions_TrySetMean_Mean_0_is_invalid_for_Stoc" + + "hast_1_", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Een variatiecoëfficiënt van '{0}' is ongeldig voor stochast '{1}'.. + /// + public static string IVariationCoefficientDistributionExtensions_TrySetVariationCoefficient_VariationCoefficient_0_is_invalid_for_Stochast_1_ { + get { + return ResourceManager.GetString("IVariationCoefficientDistributionExtensions_TrySetVariationCoefficient_VariationC" + + "oefficient_0_is_invalid_for_Stochast_1_", resourceCulture); + } + } + + /// /// Looks up a localized string similar to <?xml version="1.0" encoding="UTF-8"?> ///<!-- ///Copyright (C) Stichting Deltares 2016. All rights reserved. Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r43b7d2fe7b1c4209fd2afcd985a5c1f4b7bf14e9 -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 43b7d2fe7b1c4209fd2afcd985a5c1f4b7bf14e9) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -553,6 +553,9 @@ De locatie met hydraulische randvoorwaarden '{0}' bestaat niet. + + Het kunstwerk '{0}' bestaat niet. + {0} importeren afgebroken. Geen data ingelezen. @@ -568,6 +571,12 @@ Een standaardafwijking van '{0}' is ongeldig voor stochast '{1}'. + + Een gemiddelde van '{0}' is ongeldig voor stochast '{1}'. + + + Een variatiecoëfficiënt van '{0}' is ongeldig voor stochast '{1}'. + ..\Resources\KunstwerkenBasisSchema.xsd;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -r82db5c5ee21fae9e20fee1412dbb29b1c47b038a -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 82db5c5ee21fae9e20fee1412dbb29b1c47b038a) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -60,6 +60,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestForeshoreProfileTest.cs =================================================================== diff -u -rba715436cd0186ee10a1edc13d547ee27bea4c89 -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestForeshoreProfileTest.cs (.../TestForeshoreProfileTest.cs) (revision ba715436cd0186ee10a1edc13d547ee27bea4c89) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestForeshoreProfileTest.cs (.../TestForeshoreProfileTest.cs) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -83,6 +83,30 @@ } [Test] + public void Constructor_WithNameAndGeometry_ReturnForeshoreProfileWithGivenNameAndGeometry() + { + // Setup + const string name = "test"; + var geometry = new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }; + + // Call + ForeshoreProfile profile = new TestForeshoreProfile(name, geometry); + + // Assert + CollectionAssert.AreEqual(geometry, profile.Geometry); + Assert.AreEqual("id", profile.Id); + Assert.AreEqual(name, profile.Name); + Assert.IsFalse(profile.HasBreakWater); + Assert.AreEqual(0.0, profile.X0); + Assert.AreEqual(0.0, profile.Orientation.Value); + Assert.AreEqual(new Point2D(0, 0), profile.WorldReferencePoint); + } + + [Test] public void Constructor_WithBreakWater_ReturnsForeshoreProfileWithEmptyNameAndOnePointAtOriginAndBreakWater() { // Setup Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestForeshoreProfile.cs =================================================================== diff -u -rba715436cd0186ee10a1edc13d547ee27bea4c89 -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestForeshoreProfile.cs (.../TestForeshoreProfile.cs) (revision ba715436cd0186ee10a1edc13d547ee27bea4c89) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestForeshoreProfile.cs (.../TestForeshoreProfile.cs) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -52,6 +52,13 @@ public TestForeshoreProfile(string profileName) : this("id", profileName, new Point2D(0, 0), null, Enumerable.Empty()) {} /// + /// Creates a new instance of the with a given + /// name and geometry. + /// + /// Name of the profile. + public TestForeshoreProfile(string profileName, IEnumerable geometry) : this("id", profileName, new Point2D(0, 0), null, geometry) {} + + /// /// Creates a new instance of with a specified . /// /// The which needs to be set on the . Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/IVariationCoefficientDistributionExtensionsTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/IVariationCoefficientDistributionExtensionsTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/IVariationCoefficientDistributionExtensionsTest.cs (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -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 IVariationCoefficientDistributionExtensionsTest + { + [Test] + public void TrySetMean_DistributionNull_ThrownArgumentNullException() + { + // Setup + IVariationCoefficientDistribution 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 TrySetVariationCoefficient_DistributionNull_ThrownArgumentNullException() + { + // Setup + IVariationCoefficientDistribution distribution = null; + + const double mean = 1.1; + + // Call + TestDelegate call = () => distribution.TrySetVariationCoefficient(mean, "A", "B"); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("distribution", paramName); + } + + [Test] + public void TrySetVariationCoefficient_VariationCoefficientNull_ReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var distribution = mocks.StrictMock(); + mocks.ReplayAll(); + + // Call + bool result = distribution.TrySetVariationCoefficient(null, "A", "B"); + + // Assert + Assert.IsTrue(result); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetVariationCoefficient_VariationCoefficientValid_SetVariationCoefficientAndReturnTrue() + { + // Setup + var mocks = new MockRepository(); + var distribution = mocks.Stub(); + mocks.ReplayAll(); + + const double variationCoefficient = 1.1; + + // Call + bool result = distribution.TrySetVariationCoefficient(variationCoefficient, "A", "B"); + + // Assert + Assert.AreEqual(variationCoefficient, distribution.CoefficientOfVariation); + Assert.IsTrue(result); + + mocks.VerifyAll(); + } + + [Test] + public void TrySetVariationCoefficient_SettingVariationCoefficientThrowArgumentOutOfRangeException_LogErrorAndReturnFalse() + { + // Setup + const string exceptionMessage = "A"; + var mocks = new MockRepository(); + var distribution = mocks.StrictMock(); + distribution.Expect(d => d.CoefficientOfVariation) + .SetPropertyAndIgnoreArgument() + .Throw(new ArgumentOutOfRangeException(null, exceptionMessage)); + mocks.ReplayAll(); + + const int variationCoefficient = 5; + const string stochastName = "B"; + const string calculationName = "C"; + + // Call + bool result = true; + Action call = () => result = distribution.TrySetVariationCoefficient(variationCoefficient, "B", "C"); + + // Assert + var expectedMessage = Tuple.Create($"Een variatiecoëfficiënt van '{variationCoefficient}' 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 + IVariationCoefficientDistribution distribution = null; + + const double mean = 1.1; + const double variationCoefficient = 2.2; + + // Call + TestDelegate call = () => distribution.TrySetDistributionProperties(mean, variationCoefficient, "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? variationCoefficient) + { + // Setup + var defaultMean = new RoundedDouble(2, -1.0); + var defaultVariationCoefficient = new RoundedDouble(2, -2.0); + + var mocks = new MockRepository(); + var distribution = mocks.Stub(); + mocks.ReplayAll(); + + distribution.Mean = defaultMean; + distribution.CoefficientOfVariation = defaultVariationCoefficient; + + // Call + bool result = distribution.TrySetDistributionProperties(mean, variationCoefficient, "A", "B"); + + // Assert + Assert.IsTrue(result); + + Assert.AreEqual(mean ?? defaultMean.Value, distribution.Mean.Value); + Assert.AreEqual(variationCoefficient ?? defaultVariationCoefficient.Value, distribution.CoefficientOfVariation.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.CoefficientOfVariation) + .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_SettingVariationCoefficientThrowArgumentOutOfRangeException_LogErrorAndReturnFalse() + { + // Setup + const string exceptionMessage = "A"; + var mocks = new MockRepository(); + var distribution = mocks.StrictMock(); + distribution.Expect(d => d.CoefficientOfVariation) + .SetPropertyAndIgnoreArgument() + .Throw(new ArgumentOutOfRangeException(null, exceptionMessage)); + distribution.Stub(d => d.Mean) + .SetPropertyAndIgnoreArgument() + .Repeat.Any(); + mocks.ReplayAll(); + + const int variationCoefficient = 5; + const string stochastName = "B"; + const string calculationName = "C"; + + // Call + bool result = true; + Action call = () => result = distribution.TrySetDistributionProperties(1.1, variationCoefficient, "B", "C"); + + // Assert + var expectedMessage = Tuple.Create($"Een variatiecoëfficiënt van '{variationCoefficient}' 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 -r82db5c5ee21fae9e20fee1412dbb29b1c47b038a -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 82db5c5ee21fae9e20fee1412dbb29b1c47b038a) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -65,6 +65,7 @@ + Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs =================================================================== diff -u -rad17f1b8f41d6b4b75c9f39b427dddf31b47cef0 -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision ad17f1b8f41d6b4b75c9f39b427dddf31b47cef0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -129,7 +129,7 @@ } /// - /// Reads the foreshore profile. + /// Reads the dike profile. /// /// The calculation read from the imported file. /// The calculation to configure. Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationImporter.cs =================================================================== diff -u --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationImporter.cs (revision 0) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/HeightStructuresCalculationConfigurationImporter.cs (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,501 @@ +// 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 System.Collections.Generic; +using System.Linq; +using Core.Common.Base.Data; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.IO; +using Ringtoets.Common.IO.Configurations; +using Ringtoets.Common.IO.Configurations.Helpers; +using Ringtoets.Common.IO.FileImporters; +using Ringtoets.Common.IO.Schema; +using Ringtoets.HeightStructures.Data; +using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources; + +namespace Ringtoets.HeightStructures.IO +{ + public class HeightStructuresCalculationConfigurationImporter + : CalculationConfigurationImporter + { + private readonly IEnumerable availableHydraulicBoundaryLocations; + private readonly IEnumerable availableForeshoreProfiles; + private readonly IEnumerable availableStructures; + + /// + /// Create new instance of + /// + /// The path to the XML file to import from. + /// The calculation group to update. + /// The hydraulic boundary locations + /// used to check if the imported objects contain the right location. + /// The foreshore profiles used to check if + /// the imported objects contain the right foreshore profile. + /// The dike profiles used to check if + /// the imported objects contain the right profile. + public HeightStructuresCalculationConfigurationImporter( + string xmlFilePath, + CalculationGroup importTarget, + IEnumerable hydraulicBoundaryLocations, + IEnumerable foreshoreProfiles, + IEnumerable structures) + : base(xmlFilePath, importTarget) + { + if (hydraulicBoundaryLocations == null) + { + throw new ArgumentNullException(nameof(hydraulicBoundaryLocations)); + } + if (foreshoreProfiles == null) + { + throw new ArgumentNullException(nameof(foreshoreProfiles)); + } + if (structures == null) + { + throw new ArgumentNullException(nameof(structures)); + } + availableHydraulicBoundaryLocations = hydraulicBoundaryLocations; + availableForeshoreProfiles = foreshoreProfiles; + availableStructures = structures; + } + + protected override HeightStructuresCalculationConfigurationReader CreateCalculationConfigurationReader(string xmlFilePath) + { + return new HeightStructuresCalculationConfigurationReader(xmlFilePath); + } + + protected override ICalculation ParseReadCalculation(HeightStructuresCalculationConfiguration readCalculation) + { + var calculation = new StructuresCalculation() + { + Name = readCalculation.Name + }; + + if (TryReadStructure(readCalculation, calculation) + && TryReadStochasts(readCalculation, calculation) + && TryReadHydraulicBoundaryLocation(readCalculation, calculation) + && TryReadDikeProfile(readCalculation, calculation) + && TryReadOrientation(readCalculation, calculation) + && TryReadFailureProbabilityStructureWithErosion(readCalculation, calculation) + && TryReadWaveReduction(readCalculation, calculation)) + { + return calculation; + } + return null; + } + + private bool TryReadStochasts(HeightStructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + { + if (!ValidateStochasts(readCalculation)) + { + return false; + } + + return TryReadStandardDeviationStochast( + calculation, + HeightStructuresConfigurationSchemaIdentifiers.LevelCrestStructureStochastName, + readCalculation.LevelCrestStructure, + i => i.LevelCrestStructure, + (i, d) => i.LevelCrestStructure = d) + && TryReadStandardDeviationStochast( + calculation, + ConfigurationSchemaIdentifiers.AllowedLevelIncreaseStorageStochastName, + readCalculation.AllowedLevelIncreaseStorage, + i => i.AllowedLevelIncreaseStorage, + (i, d) => i.AllowedLevelIncreaseStorage = d) + && TryReadStandardDeviationStochast( + calculation, + ConfigurationSchemaIdentifiers.FlowWidthAtBottomProtectionStochastName, + readCalculation.FlowWidthAtBottomProtection, + i => i.FlowWidthAtBottomProtection, + (i, d) => i.FlowWidthAtBottomProtection = d) + && TryReadStandardDeviationStochast( + calculation, + ConfigurationSchemaIdentifiers.ModelFactorSuperCriticalFlowStochastName, + readCalculation.ModelFactorSuperCriticalFlow, + i => i.ModelFactorSuperCriticalFlow, + (i, d) => i.ModelFactorSuperCriticalFlow = d) + && TryReadStandardDeviationStochast( + calculation, + ConfigurationSchemaIdentifiers.WidthFlowAperturesStochastName, + readCalculation.WidthFlowApertures, + i => i.WidthFlowApertures, + (i, d) => i.WidthFlowApertures = d) + && TryReadVariationCoefficientStochast( + calculation, + ConfigurationSchemaIdentifiers.CriticalOvertoppingDischargeStochastName, + readCalculation.CriticalOvertoppingDischarge, + i => i.CriticalOvertoppingDischarge, + (i, d) => i.CriticalOvertoppingDischarge = d) + && TryReadVariationCoefficientStochast( + calculation, + ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName, + readCalculation.StorageStructureArea, + i => i.StorageStructureArea, + (i, d) => i.StorageStructureArea = d) + && TryReadVariationCoefficientStochast( + calculation, + ConfigurationSchemaIdentifiers.StormDurationStochastName, + readCalculation.StormDuration, + i => i.StormDuration, + (i, d) => i.StormDuration = d); + } + + private bool ValidateStochasts(HeightStructuresCalculationConfiguration readCalculation) + { + if (readCalculation.StormDuration?.VariationCoefficient != null) + { + LogReadCalculationConversionError("Er kan geen variatiecoëfficiënt voor stochast 'stormduur' opgegeven worden.", readCalculation.Name); + return false; + } + if (readCalculation.ModelFactorSuperCriticalFlow?.StandardDeviation != null) + { + LogReadCalculationConversionError("Er kan geen standaardafwijking voor stochast 'modelfactoroverloopdebiet' opgegeven worden.", readCalculation.Name); + return false; + } + return true; + } + + /// + /// Reads the stochast parameters. + /// + /// The calculation to configure. + /// The stochast's name. + /// The configuration of the stochast. + /// The function for obtaining the stochast to read. + /// The function to set the stochast with the read parameters. + /// true if reading all required wave reduction parameters was successful, + /// false otherwise. + private bool TryReadStandardDeviationStochast( + StructuresCalculation calculation, + string stochastName, + MeanStandardDeviationStochastConfiguration stochastConfiguration, + Func getStochast, + Action setStochast) + where T : class, IDistribution + { + if (stochastConfiguration == null) + { + return true; + } + var distribution = (T) getStochast(calculation.InputParameters).Clone(); + + if (!distribution.TrySetDistributionProperties(stochastConfiguration, + stochastName, + calculation.Name)) + { + return false; + } + setStochast(calculation.InputParameters, distribution); + return true; + } + + /// + /// Reads the stochast parameters. + /// + /// The calculation to configure. + /// The stochast's name. + /// The configuration of the stochast. + /// The function for obtaining the stochast to read. + /// The function to set the stochast with the read parameters. + /// true if reading all required wave reduction parameters was successful, + /// false otherwise. + private bool TryReadVariationCoefficientStochast( + StructuresCalculation calculation, + string stochastName, + MeanVariationCoefficientStochastConfiguration stochastConfiguration, + Func getStochast, + Action setStochast) + where T : class, IVariationCoefficientDistribution + { + if (stochastConfiguration == null) + { + return true; + } + var distribution = (T) getStochast(calculation.InputParameters).Clone(); + + if (!distribution.TrySetDistributionProperties(stochastConfiguration, + stochastName, + calculation.Name)) + { + return false; + } + setStochast(calculation.InputParameters, distribution); + return true; + } + + /// + /// Reads the orientation. + /// + /// The calculation read from the imported file. + /// The calculation to configure. + /// false when the orientation is invalid or when there is an orientation but + /// no structure defined, true otherwise. + private bool TryReadOrientation(StructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + { + if (readCalculation.StructureNormalOrientation.HasValue) + { + if (calculation.InputParameters.Structure == null) + { + LogReadCalculationConversionError( + "Er is geen kunstwerk opgegeven om de oriëntatie aan toe te voegen.", + calculation.Name); + + return false; + } + + double orientation = readCalculation.StructureNormalOrientation.Value; + + try + { + calculation.InputParameters.StructureNormalOrientation = (RoundedDouble) orientation; + } + catch (ArgumentOutOfRangeException e) + { + LogOutOfRangeException( + string.Format("Een waarde van '{0}' als oriëntatie is ongeldig.", orientation), + calculation.Name, + e); + + return false; + } + } + + return true; + } + + /// + /// Reads the failure probability structure with erosion. + /// + /// The calculation read from the imported file. + /// The calculation to configure. + /// false when the orientation is invalid or when there is a failure probability + /// structure with erosion but no structure defined, true otherwise. + private bool TryReadFailureProbabilityStructureWithErosion(StructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + { + if (readCalculation.FailureProbabilityStructureWithErosion.HasValue) + { + if (calculation.InputParameters.Structure == null) + { + LogReadCalculationConversionError( + "Er is geen kunstwerk opgegeven om de faalkans gegeven erosie bodem aan toe te voegen.", + calculation.Name); + + return false; + } + + double failureProbability = readCalculation.FailureProbabilityStructureWithErosion.Value; + + try + { + calculation.InputParameters.FailureProbabilityStructureWithErosion = (RoundedDouble) failureProbability; + } + catch (ArgumentOutOfRangeException e) + { + LogOutOfRangeException( + string.Format("Een waarde van '{0}' als faalkans gegeven erosie bodem is ongeldig.", failureProbability), + calculation.Name, + e); + + return false; + } + } + + return true; + } + + /// + /// Reads the hydraulic boundary location. + /// + /// The calculation read from the imported file. + /// The calculation to configure. + /// false when the has a + /// set which is not available in , true otherwise. + private bool TryReadHydraulicBoundaryLocation(StructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + { + if (readCalculation.HydraulicBoundaryLocationName != null) + { + HydraulicBoundaryLocation location = availableHydraulicBoundaryLocations + .FirstOrDefault(l => l.Name == readCalculation.HydraulicBoundaryLocationName); + + if (location == null) + { + LogReadCalculationConversionError( + string.Format( + RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadHydraulicBoundaryLocation_HydraulicBoundaryLocation_0_does_not_exist, + readCalculation.HydraulicBoundaryLocationName), + calculation.Name); + + return false; + } + + calculation.InputParameters.HydraulicBoundaryLocation = location; + } + + return true; + } + + /// + /// Reads the hydraulic boundary location. + /// + /// The calculation read from the imported file. + /// The calculation to configure. + /// false when the has a + /// set which is not available in , true otherwise. + private bool TryReadStructure(StructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + { + if (readCalculation.StructureName != null) + { + HeightStructure structure = availableStructures + .FirstOrDefault(l => l.Name == readCalculation.StructureName); + + if (structure == null) + { + LogReadCalculationConversionError( + string.Format( + RingtoetsCommonIOResources.CalculationConfigurationImporter_ReadStructure_Structure_0_does_not_exist, + readCalculation.StructureName), + calculation.Name); + + return false; + } + + calculation.InputParameters.Structure = structure; + } + + return true; + } + + /// + /// Reads the dike profile. + /// + /// The calculation read from the imported file. + /// The calculation to configure. + /// false when the has a + /// set which is not available in , true otherwise. + private bool TryReadDikeProfile(StructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + { + if (readCalculation.ForeshoreProfileName != null) + { + ForeshoreProfile foreshoreProfile = availableForeshoreProfiles.FirstOrDefault(fp => fp.Name == readCalculation.ForeshoreProfileName); + + if (foreshoreProfile == null) + { + LogReadCalculationConversionError( + string.Format( + "Het voorlandprofiel '{0}' bestaat niet.", + readCalculation.ForeshoreProfileName), + calculation.Name); + + return false; + } + + calculation.InputParameters.ForeshoreProfile = foreshoreProfile; + } + + return true; + } + + /// + /// Reads the wave reduction parameters. + /// + /// The calculation read from the imported file. + /// The calculation to configure. + /// false when there is an invalid wave reduction parameter defined, true otherwise. + private bool TryReadWaveReduction(StructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + { + if (!ValidateWaveReduction(readCalculation, calculation)) + { + return false; + } + + WaveReductionConfiguration waveReduction = readCalculation.WaveReduction; + if (waveReduction == null) + { + return true; + } + + if (waveReduction.UseForeshoreProfile.HasValue) + { + calculation.InputParameters.UseForeshore = waveReduction.UseForeshoreProfile.Value; + } + + if (waveReduction.UseBreakWater.HasValue) + { + calculation.InputParameters.UseBreakWater = waveReduction.UseBreakWater.Value; + } + + if (waveReduction.BreakWaterType.HasValue) + { + calculation.InputParameters.BreakWater.Type = (BreakWaterType) new SchemaBreakWaterTypeConverter().ConvertTo(waveReduction.BreakWaterType.Value, typeof(BreakWaterType)); + } + + if (waveReduction.BreakWaterHeight.HasValue) + { + calculation.InputParameters.BreakWater.Height = (RoundedDouble) waveReduction.BreakWaterHeight.Value; + } + + return true; + } + + /// + /// Validation to check if the defined wave reduction parameters are valid. + /// + /// The calculation read from the imported file. + /// The calculation to configure. + /// false when there is an invalid wave reduction parameter defined, true otherwise. + private bool ValidateWaveReduction(StructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + { + if (calculation.InputParameters.ForeshoreProfile == null) + { + if (readCalculation.WaveReduction != null + && (readCalculation.WaveReduction.UseBreakWater.HasValue + || readCalculation.WaveReduction.UseForeshoreProfile.HasValue + || readCalculation.WaveReduction.BreakWaterHeight.HasValue + || readCalculation.WaveReduction.BreakWaterType.HasValue)) + { + LogReadCalculationConversionError( + "Er is geen voorlandprofiel opgegeven om golfreductie parameters aan toe te voegen.", + calculation.Name); + + return false; + } + } + else if (!calculation.InputParameters.ForeshoreGeometry.Any()) + { + if (readCalculation.WaveReduction.UseForeshoreProfile.HasValue && readCalculation.WaveReduction.UseForeshoreProfile.Value) + { + LogReadCalculationConversionError( + string.Format( + "Het opgegeven voorlandprofiel '{0}' heeft geen geometrie en kan daarom niet gebruikt worden.", + readCalculation.ForeshoreProfileName), + calculation.Name); + return false; + } + } + return true; + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Ringtoets.HeightStructures.IO.csproj =================================================================== diff -u -rd393a6e22ba176f0ce9731629a37ce3272b1f433 -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Ringtoets.HeightStructures.IO.csproj (.../Ringtoets.HeightStructures.IO.csproj) (revision d393a6e22ba176f0ce9731629a37ce3272b1f433) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.IO/Ringtoets.HeightStructures.IO.csproj (.../Ringtoets.HeightStructures.IO.csproj) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -46,6 +46,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationImporterTest.cs =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationImporterTest.cs (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/HeightStructuresCalculationConfigurationImporterTest.cs (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,516 @@ +// 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 System.Collections.Generic; +using System.IO; +using System.Linq; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.IO.FileImporters; +using Ringtoets.HeightStructures.Data; +using Ringtoets.HeightStructures.Data.TestUtil; + +namespace Ringtoets.HeightStructures.IO.Test +{ + [TestFixture] + public class HeightStructuresCalculationConfigurationImporterTest + { + private readonly string importerPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HeightStructures.IO, nameof(HeightStructuresCalculationConfigurationImporter)); + + [Test] + public void Constructor_ExpectedValues() + { + // Call + var importer = new HeightStructuresCalculationConfigurationImporter("", + new CalculationGroup(), + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + + // Assert + Assert.IsInstanceOf>(importer); + } + + [Test] + public void Constructor_HydraulicBoundaryLocationsNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => new HeightStructuresCalculationConfigurationImporter("", + new CalculationGroup(), + null, + Enumerable.Empty(), + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("hydraulicBoundaryLocations", exception.ParamName); + } + + [Test] + public void Constructor_ForeshoreProfilesNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => new HeightStructuresCalculationConfigurationImporter("", + new CalculationGroup(), + Enumerable.Empty(), + null, + Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("foreshoreProfiles", exception.ParamName); + } + + [Test] + public void Constructor_StructuresNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => new HeightStructuresCalculationConfigurationImporter("", + new CalculationGroup(), + Enumerable.Empty(), + Enumerable.Empty(), + null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("structures", exception.ParamName); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase("validConfigurationModelFactorSuperCriticalFlowStandardDeviation.xml", + "Er kan geen standaardafwijking voor stochast 'modelfactoroverloopdebiet' opgegeven worden.")] + [TestCase("validConfigurationStormDurationVariationCoefficient.xml", + "Er kan geen variatiecoëfficiënt voor stochast 'stormduur' opgegeven worden.")] + [TestCase("validConfigurationFailureProbabilityStructureErosionWithoutStructure.xml", + "Er is geen kunstwerk opgegeven om de faalkans gegeven erosie bodem aan toe te voegen.")] + [TestCase("validConfigurationOrientationWithoutStructure.xml", + "Er is geen kunstwerk opgegeven om de oriëntatie aan toe te voegen.")] + [TestCase("validConfigurationInvalidFailureProbabilityStructureErosion.xml", + "Een waarde van '1,1' als faalkans gegeven erosie bodem is ongeldig. De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen.")] + [TestCase("validConfigurationInvalidOrientation.xml", + "Een waarde van '-12' als oriëntatie is ongeldig. De waarde voor de oriëntatie moet in het bereik [0,00, 360,00] liggen.")] + [TestCase("validConfigurationWaveReductionWithoutForeshoreProfile.xml", + "Er is geen voorlandprofiel opgegeven om golfreductie parameters aan toe te voegen.")] + [TestCase("validConfigurationInvalidAllowedLevelIncreaseStorageMean.xml", + "Een gemiddelde van '-0,2' is ongeldig voor stochast 'peilverhogingkomberging'. Gemiddelde moet groter zijn dan 0.")] + [TestCase("validConfigurationInvalidAllowedLevelIncreaseStorageStandardDeviation.xml", + "Een standaardafwijking van '-0,01' is ongeldig voor stochast 'peilverhogingkomberging'. Standaardafwijking (σ) moet groter zijn dan of gelijk zijn aan 0.")] + [TestCase("validConfigurationInvalidCriticalOvertoppingDischargeMean.xml", + "Een gemiddelde van '-2' is ongeldig voor stochast 'kritiekinstromenddebiet'. Gemiddelde moet groter zijn dan 0.")] + [TestCase("validConfigurationInvalidCriticalOvertoppingDischargeVariationCoefficient.xml", + "Een variatiecoëfficiënt van '-0,1' is ongeldig voor stochast 'kritiekinstromenddebiet'. Variatiecoëfficiënt (CV) moet groter zijn dan of gelijk zijn aan 0.")] + [TestCase("validConfigurationInvalidFlowWidthAtBottomProtectionMean.xml", + "Een gemiddelde van '-15,2' is ongeldig voor stochast 'breedtebodembescherming'. Gemiddelde moet groter zijn dan 0.")] + [TestCase("validConfigurationInvalidFlowWidthAtBottomProtectionStandardDeviation.xml", + "Een standaardafwijking van '-0,1' is ongeldig voor stochast 'breedtebodembescherming'. Standaardafwijking (σ) moet groter zijn dan of gelijk zijn aan 0.")] + [TestCase("validConfigurationInvalidLevelCrestStructureStandardDeviation.xml", + "Een standaardafwijking van '-0,1' is ongeldig voor stochast 'kerendehoogte'. Standaardafwijking (σ) moet groter zijn dan of gelijk zijn aan 0.")] + [TestCase("validConfigurationInvalidStorageStructureAreaMean.xml", + "Een gemiddelde van '-15000' is ongeldig voor stochast 'kombergendoppervlak'. Gemiddelde moet groter zijn dan 0.")] + [TestCase("validConfigurationInvalidStorageStructureAreaVariationCoefficient.xml", + "Een variatiecoëfficiënt van '-0,01' is ongeldig voor stochast 'kombergendoppervlak'. Variatiecoëfficiënt (CV) moet groter zijn dan of gelijk zijn aan 0.")] + [TestCase("validConfigurationInvalidStormDurationMean.xml", + "Een gemiddelde van '-6' is ongeldig voor stochast 'stormduur'. Gemiddelde moet groter zijn dan 0.")] + [TestCase("validConfigurationInvalidWidthFlowAperturesStandardDeviation.xml", + "Een standaardafwijking van '-0,1' is ongeldig voor stochast 'breedtedoorstroomopening'. Standaardafwijking (σ) moet groter zijn dan of gelijk zijn aan 0.")] + public void Import_ValidConfigurationInvalidData_LogMessageAndContinueImport(string file, string expectedErrorMessage) + { + // Setup + string filePath = Path.Combine(importerPath, file); + + var calculationGroup = new CalculationGroup(); + var structure = new TestHeightStructure("kunstwerk1"); + var foreshoreProfile = new TestForeshoreProfile("profiel 1"); + + var importer = new HeightStructuresCalculationConfigurationImporter(filePath, + calculationGroup, + Enumerable.Empty(), + new ForeshoreProfile[] + { + foreshoreProfile + }, + new HeightStructure[] + { + structure + }); + var successful = false; + + // Call + Action call = () => successful = importer.Import(); + + // Assert + string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; + TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); + Assert.IsTrue(successful); + CollectionAssert.IsEmpty(calculationGroup.Children); + } + + [TestCase("validConfigurationUnknownForeshoreProfile.xml", + "Het voorlandprofiel 'unknown' bestaat niet.")] + [TestCase("validConfigurationUnknownHydraulicBoundaryLocation.xml", + "De locatie met hydraulische randvoorwaarden 'unknown' bestaat niet.")] + [TestCase("validConfigurationUnknownStructure.xml", + "Het kunstwerk 'unknown' bestaat niet.")] + public void Import_ValidConfigurationUnknownData_LogMessageAndContinueImport(string file, string expectedErrorMessage) + { + // Setup + string filePath = Path.Combine(importerPath, file); + + var calculationGroup = new CalculationGroup(); + + var importer = new HeightStructuresCalculationConfigurationImporter(filePath, + calculationGroup, + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + var successful = false; + + // Call + Action call = () => successful = importer.Import(); + + // Assert + string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; + TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); + Assert.IsTrue(successful); + CollectionAssert.IsEmpty(calculationGroup.Children); + } + + [Test] + public void Import_UseForeshoreButForshoreProfileWithoutGeometry_LogMessageAndContinueImport() + { + // Setup + string filePath = Path.Combine(importerPath, "validConfigurationCalculationUseForeshoreWithoutGeometry.xml"); + + var calculationGroup = new CalculationGroup(); + var foreshoreProfile = new TestForeshoreProfile("Voorlandprofiel"); + var importer = new HeightStructuresCalculationConfigurationImporter( + filePath, + calculationGroup, + Enumerable.Empty(), + new[] + { + foreshoreProfile + }, + Enumerable.Empty()); + + var successful = false; + + // Call + Action call = () => successful = importer.Import(); + + // Assert + const string expectedMessage = "Het opgegeven voorlandprofiel 'Voorlandprofiel' heeft geen geometrie en kan daarom niet gebruikt worden. Berekening 'Berekening 1' is overgeslagen."; + TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); + Assert.IsTrue(successful); + CollectionAssert.IsEmpty(calculationGroup.Children); + } + + [Test] + public void Import_FullCalculationConfigruation_DataAddedToModel() + { + // Setup + string filePath = Path.Combine(importerPath, "validFullConfiguration.xml"); + + var calculationGroup = new CalculationGroup(); + var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation("Locatie1"); + var foreshoreProfile = new TestForeshoreProfile("profiel1", new List + { + new Point2D(0,3) + }); + var structure = new TestHeightStructure("kunstwerk1"); + var importer = new HeightStructuresCalculationConfigurationImporter( + filePath, + calculationGroup, + new[] + { + hydraulicBoundaryLocation + }, + new[] + { + foreshoreProfile + }, + new[] + { + structure + }); + + // Call + var successful = importer.Import(); + + // Assert + Assert.IsTrue(successful); + var expectedCalculation = new StructuresCalculation + { + Name = "Berekening 1", + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + Structure = structure, + ForeshoreProfile = foreshoreProfile, + StructureNormalOrientation = (RoundedDouble) 67.1, + FailureProbabilityStructureWithErosion = 1e-6, + UseBreakWater = true, + UseForeshore = true, + BreakWater = + { + Height = (RoundedDouble) 1.23, + Type = BreakWaterType.Dam + }, + StormDuration = + { + Mean = (RoundedDouble) 6.0 + }, + ModelFactorSuperCriticalFlow = + { + Mean = (RoundedDouble) 1.10 + }, + FlowWidthAtBottomProtection = + { + Mean = (RoundedDouble) 15.2, + StandardDeviation = (RoundedDouble) 0.1 + }, + WidthFlowApertures = + { + Mean = (RoundedDouble) 15.2, + StandardDeviation = (RoundedDouble) 0.1 + }, + StorageStructureArea = + { + Mean = (RoundedDouble) 15000, + CoefficientOfVariation = (RoundedDouble) 0.01 + }, + AllowedLevelIncreaseStorage = + { + Mean = (RoundedDouble) 0.2, + StandardDeviation = (RoundedDouble) 0.01 + }, + LevelCrestStructure = + { + Mean = (RoundedDouble) 4.3, + StandardDeviation = (RoundedDouble) 0.1 + }, + CriticalOvertoppingDischarge = + { + Mean = (RoundedDouble) 2, + CoefficientOfVariation = (RoundedDouble) 0.1 + } + } + }; + + Assert.AreEqual(1, calculationGroup.Children.Count); + AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + } + + [Test] + public void Import_StochastWithMeanOnly_DataAddedToModel() + { + // Setup + string filePath = Path.Combine(importerPath, "validConfigurationStochastMeansOnly.xml"); + + var calculationGroup = new CalculationGroup(); + var structure = new TestHeightStructure("kunstwerk1"); + var importer = new HeightStructuresCalculationConfigurationImporter( + filePath, + calculationGroup, + Enumerable.Empty(), + Enumerable.Empty(), + new[] + { + structure + }); + + var expectedCalculation = new StructuresCalculation + { + Name = "Berekening 1", + InputParameters = + { + Structure = structure, + StormDuration = + { + Mean = (RoundedDouble) 6.0 + }, + ModelFactorSuperCriticalFlow = + { + Mean = (RoundedDouble) 1.10 + }, + FlowWidthAtBottomProtection = + { + Mean = (RoundedDouble) 15.2, + }, + WidthFlowApertures = + { + Mean = (RoundedDouble) 15.2, + }, + StorageStructureArea = + { + Mean = (RoundedDouble) 15000, + }, + AllowedLevelIncreaseStorage = + { + Mean = (RoundedDouble) 0.2, + }, + LevelCrestStructure = + { + Mean = (RoundedDouble) 4.3, + }, + CriticalOvertoppingDischarge = + { + Mean = (RoundedDouble) 2, + } + } + }; + + // Call + var successful = importer.Import(); + + // Assert + Assert.IsTrue(successful); + Assert.AreEqual(1, calculationGroup.Children.Count); + AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + } + + [Test] + public void Import_StochastWithStandardDeviationOrVariationCoefficientOnly_DataAddedToModel() + { + // Setup + string filePath = Path.Combine(importerPath, "validConfigurationStochastStandardDeviationVariationCoefficientOnly.xml"); + + var calculationGroup = new CalculationGroup(); + var structure = new TestHeightStructure("kunstwerk1"); + var importer = new HeightStructuresCalculationConfigurationImporter( + filePath, + calculationGroup, + Enumerable.Empty(), + Enumerable.Empty(), + new[] + { + structure + }); + + var expectedCalculation = new StructuresCalculation + { + Name = "Berekening 1", + InputParameters = + { + Structure = structure, + FlowWidthAtBottomProtection = + { + StandardDeviation = (RoundedDouble) 0.1 + }, + WidthFlowApertures = + { + StandardDeviation = (RoundedDouble) 0.1 + }, + StorageStructureArea = + { + CoefficientOfVariation = (RoundedDouble) 0.01 + }, + AllowedLevelIncreaseStorage = + { + StandardDeviation = (RoundedDouble) 0.01 + }, + LevelCrestStructure = + { + StandardDeviation = (RoundedDouble) 0.1 + }, + CriticalOvertoppingDischarge = + { + CoefficientOfVariation = (RoundedDouble) 0.1 + } + } + }; + + // Call + var successful = importer.Import(); + + // Assert + Assert.IsTrue(successful); + Assert.AreEqual(1, calculationGroup.Children.Count); + AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + } + + [Test] + [TestCase("validConfigurationEmptyCalculation.xml")] + [TestCase("validConfigurationEmptyStochasts.xml")] + [TestCase("validConfigurationEmptyStochastsElement.xml")] + [TestCase("validConfigurationEmptyWaveReduction.xml")] + public void Import_EmptyConfigurations_DataAddedToModel(string file) + { + // Setup + string filePath = Path.Combine(importerPath, file); + + var calculationGroup = new CalculationGroup(); + var structure = new TestHeightStructure("kunstwerk1"); + var importer = new HeightStructuresCalculationConfigurationImporter( + filePath, + calculationGroup, + Enumerable.Empty(), + Enumerable.Empty(), + new[] + { + structure + }); + + var expectedCalculation = new StructuresCalculation + { + Name = "Berekening 1" + }; + + // Call + var successful = importer.Import(); + + // Assert + Assert.IsTrue(successful); + Assert.AreEqual(1, calculationGroup.Children.Count); + AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + } + + private void AssertCalculation(StructuresCalculation expectedCalculation, StructuresCalculation actualCalculation) + { + Assert.AreEqual(expectedCalculation.Name, actualCalculation.Name); + Assert.AreSame(expectedCalculation.InputParameters.HydraulicBoundaryLocation, actualCalculation.InputParameters.HydraulicBoundaryLocation); + Assert.AreEqual(expectedCalculation.InputParameters.StructureNormalOrientation, actualCalculation.InputParameters.StructureNormalOrientation); + Assert.AreSame(expectedCalculation.InputParameters.ForeshoreProfile, actualCalculation.InputParameters.ForeshoreProfile); + Assert.AreSame(expectedCalculation.InputParameters.Structure, actualCalculation.InputParameters.Structure); + Assert.AreEqual(expectedCalculation.InputParameters.UseForeshore, actualCalculation.InputParameters.UseForeshore); + Assert.AreEqual(expectedCalculation.InputParameters.UseBreakWater, actualCalculation.InputParameters.UseBreakWater); + Assert.AreEqual(expectedCalculation.InputParameters.BreakWater.Height, actualCalculation.InputParameters.BreakWater.Height); + Assert.AreEqual(expectedCalculation.InputParameters.BreakWater.Type, actualCalculation.InputParameters.BreakWater.Type); + DistributionAssert.AreEqual(expectedCalculation.InputParameters.LevelCrestStructure, actualCalculation.InputParameters.LevelCrestStructure); + DistributionAssert.AreEqual(expectedCalculation.InputParameters.AllowedLevelIncreaseStorage, actualCalculation.InputParameters.AllowedLevelIncreaseStorage); + DistributionAssert.AreEqual(expectedCalculation.InputParameters.FlowWidthAtBottomProtection, actualCalculation.InputParameters.FlowWidthAtBottomProtection); + DistributionAssert.AreEqual(expectedCalculation.InputParameters.ModelFactorSuperCriticalFlow, actualCalculation.InputParameters.ModelFactorSuperCriticalFlow); + DistributionAssert.AreEqual(expectedCalculation.InputParameters.CriticalOvertoppingDischarge, actualCalculation.InputParameters.CriticalOvertoppingDischarge); + DistributionAssert.AreEqual(expectedCalculation.InputParameters.StorageStructureArea, actualCalculation.InputParameters.StorageStructureArea); + DistributionAssert.AreEqual(expectedCalculation.InputParameters.StormDuration, actualCalculation.InputParameters.StormDuration); + DistributionAssert.AreEqual(expectedCalculation.InputParameters.WidthFlowApertures, actualCalculation.InputParameters.WidthFlowApertures); + } + } +} \ No newline at end of file Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/Ringtoets.HeightStructures.IO.Test.csproj =================================================================== diff -u -rd393a6e22ba176f0ce9731629a37ce3272b1f433 -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/Ringtoets.HeightStructures.IO.Test.csproj (.../Ringtoets.HeightStructures.IO.Test.csproj) (revision d393a6e22ba176f0ce9731629a37ce3272b1f433) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/Ringtoets.HeightStructures.IO.Test.csproj (.../Ringtoets.HeightStructures.IO.Test.csproj) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -50,6 +50,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationCalculationUseForeshoreWithoutGeometry.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationCalculationUseForeshoreWithoutGeometry.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationCalculationUseForeshoreWithoutGeometry.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,9 @@ + + + + Voorlandprofiel + + true + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyCalculation.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyCalculation.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyCalculation.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,4 @@ + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyStochasts.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyStochasts.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyStochasts.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,15 @@ + + + + + + + + + + + + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyStochastsElement.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyStochastsElement.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyStochastsElement.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,6 @@ + + + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyWaveReduction.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyWaveReduction.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationEmptyWaveReduction.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,6 @@ + + + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationFailureProbabilityStructureErosionWithoutStructure.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationFailureProbabilityStructureErosionWithoutStructure.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationFailureProbabilityStructureErosionWithoutStructure.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,6 @@ + + + + 1E-6 + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidAllowedLevelIncreaseStorageMean.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidAllowedLevelIncreaseStorageMean.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidAllowedLevelIncreaseStorageMean.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + -0.2 + 0.01 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidAllowedLevelIncreaseStorageStandardDeviation.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidAllowedLevelIncreaseStorageStandardDeviation.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidAllowedLevelIncreaseStorageStandardDeviation.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + 0.2 + -0.01 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidCriticalOvertoppingDischargeMean.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidCriticalOvertoppingDischargeMean.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidCriticalOvertoppingDischargeMean.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + -2 + 0.1 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidCriticalOvertoppingDischargeVariationCoefficient.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidCriticalOvertoppingDischargeVariationCoefficient.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidCriticalOvertoppingDischargeVariationCoefficient.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + 2 + -0.1 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidFailureProbabilityStructureErosion.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidFailureProbabilityStructureErosion.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidFailureProbabilityStructureErosion.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,7 @@ + + + + kunstwerk1 + 1.1 + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidFlowWidthAtBottomProtectionMean.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidFlowWidthAtBottomProtectionMean.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidFlowWidthAtBottomProtectionMean.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + -15.2 + 0.1 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidFlowWidthAtBottomProtectionStandardDeviation.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidFlowWidthAtBottomProtectionStandardDeviation.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidFlowWidthAtBottomProtectionStandardDeviation.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + 15.2 + -0.1 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidLevelCrestStructureStandardDeviation.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidLevelCrestStructureStandardDeviation.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidLevelCrestStructureStandardDeviation.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + 4.3 + -0.1 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidOrientation.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidOrientation.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidOrientation.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,7 @@ + + + + kunstwerk1 + -12 + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidStorageStructureAreaMean.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidStorageStructureAreaMean.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidStorageStructureAreaMean.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + -15000 + 0.01 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidStorageStructureAreaVariationCoefficient.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidStorageStructureAreaVariationCoefficient.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidStorageStructureAreaVariationCoefficient.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + 15000 + -0.01 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidStormDurationMean.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidStormDurationMean.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidStormDurationMean.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,11 @@ + + + + kunstwerk1 + + + -6.0 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidWidthFlowAperturesStandardDeviation.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidWidthFlowAperturesStandardDeviation.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationInvalidWidthFlowAperturesStandardDeviation.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,12 @@ + + + + kunstwerk1 + + + 15.2 + -0.1 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationModelFactorSuperCriticalFlowStandardDeviation.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationModelFactorSuperCriticalFlowStandardDeviation.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationModelFactorSuperCriticalFlowStandardDeviation.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,11 @@ + + + + kunstwerk1 + + + 0.1 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationOrientationWithoutStructure.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationOrientationWithoutStructure.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationOrientationWithoutStructure.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,6 @@ + + + + 67.1 + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStochastMeansOnly.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStochastMeansOnly.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStochastMeansOnly.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,32 @@ + + + + kunstwerk1 + + + 6.0 + + + 1.10 + + + 15.2 + + + 15.2 + + + 15000 + + + 0.2 + + + 4.3 + + + 2 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStochastStandardDeviationVariationCoefficientOnly.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStochastStandardDeviationVariationCoefficientOnly.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStochastStandardDeviationVariationCoefficientOnly.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,30 @@ + + + + kunstwerk1 + + + + + + + 0.1 + + + 0.1 + + + 0.01 + + + 0.01 + + + 0.1 + + + 0.1 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStochastsWithoutStructure.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStochastsWithoutStructure.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStochastsWithoutStructure.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,32 @@ + + + + kunstwerk1 + + + 6.0 + + + 1.10 + + + 15.2 + + + 15.2 + + + 15000 + + + 0.2 + + + 4.3 + + + 2 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStormDurationVariationCoefficient.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStormDurationVariationCoefficient.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationStormDurationVariationCoefficient.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,11 @@ + + + + kunstwerk1 + + + 0.01 + + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationUnknownForeshoreProfile.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationUnknownForeshoreProfile.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationUnknownForeshoreProfile.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,6 @@ + + + + unknown + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationUnknownHydraulicBoundaryLocation.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationUnknownHydraulicBoundaryLocation.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationUnknownHydraulicBoundaryLocation.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,6 @@ + + + + unknown + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationUnknownStructure.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationUnknownStructure.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationUnknownStructure.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,6 @@ + + + + unknown + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationWaveReductionWithoutForeshoreProfile.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationWaveReductionWithoutForeshoreProfile.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validConfigurationWaveReductionWithoutForeshoreProfile.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,8 @@ + + + + + false + + + Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validFullConfiguration.xml =================================================================== diff -u --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validFullConfiguration.xml (revision 0) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/test-data/HeightStructuresCalculationConfigurationImporter/validFullConfiguration.xml (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -0,0 +1,48 @@ + + + + Locatie1 + kunstwerk1 + 67.1 + 1E-6 + profiel1 + + true + havendam + 1.234 + true + + + + 6.0 + + + 1.10 + + + 15.2 + 0.1 + + + 15.2 + 0.1 + + + 15000 + 0.01 + + + 0.2 + 0.01 + + + 4.3 + 0.1 + + + 2 + 0.1 + + + + Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingCalculationConfigurationImporterTest.cs =================================================================== diff -u -r332fd224ce5cd9c737e72f945271c52ae6d64c0d -r5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingCalculationConfigurationImporterTest.cs (.../PipingCalculationConfigurationImporterTest.cs) (revision 332fd224ce5cd9c737e72f945271c52ae6d64c0d) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingCalculationConfigurationImporterTest.cs (.../PipingCalculationConfigurationImporterTest.cs) (revision 5b07686bb3f89f1fa1017c4bf2cf8964ae9bd95c) @@ -39,8 +39,8 @@ [TestFixture] public class PipingCalculationConfigurationImporterTest { - private readonly string readerPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, "PipingCalculationConfigurationReader"); - private readonly string importerPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, "PipingCalculationConfigurationImporter"); + private readonly string readerPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, nameof(PipingCalculationConfigurationReader)); + private readonly string importerPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Piping.IO, nameof(PipingCalculationConfigurationImporter)); [Test] public void Constructor_ExpectedValues() @@ -128,9 +128,9 @@ calculationGroup, new HydraulicBoundaryLocation[0], pipingFailureMechanism); + var successful = false; // Call - var successful = false; Action call = () => successful = importer.Import(); // Assert