Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -rdd84b844a388b0dc3f721bd40674c4ed513b3231 -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs) (revision dd84b844a388b0dc3f721bd40674c4ed513b3231) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -62,7 +62,7 @@ ForeshoreProfile = CreateForeshoreProfile(), UseForeshore = true, UseBreakWater = true, - StepSize = (RoundedDouble) 0.5, + StepSize = WaveConditionsInputStepSize.Half, LowerBoundaryRevetment = (RoundedDouble) 5.3, UpperBoundaryRevetment = (RoundedDouble) 10, UpperBoundaryWaterLevels = (RoundedDouble) 5.4, @@ -310,7 +310,7 @@ ForeshoreProfile = CreateForeshoreProfile(), UseForeshore = true, UseBreakWater = true, - StepSize = (RoundedDouble) 0.5, + StepSize = WaveConditionsInputStepSize.Half, LowerBoundaryRevetment = (RoundedDouble) 4, UpperBoundaryRevetment = (RoundedDouble) 10, UpperBoundaryWaterLevels = (RoundedDouble) 8, Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/Properties/Resources.Designer.cs =================================================================== diff -u -r14c7697f5bec8544f673df9a0205abffa0c145b9 -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 14c7697f5bec8544f673df9a0205abffa0c145b9) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -109,5 +109,32 @@ "_be_above_lower_boundary_water_levels", resourceCulture); } } + + /// + /// Looks up a localized string similar to 0.5. + /// + internal static string WaveConditionsInputStepSize_Half { + get { + return ResourceManager.GetString("WaveConditionsInputStepSize_Half", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 1.0. + /// + internal static string WaveConditionsInputStepSize_One { + get { + return ResourceManager.GetString("WaveConditionsInputStepSize_One", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to 2.0. + /// + internal static string WaveConditionsInputStepSize_Two { + get { + return ResourceManager.GetString("WaveConditionsInputStepSize_Two", resourceCulture); + } + } } } Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/Properties/Resources.resx =================================================================== diff -u -r14c7697f5bec8544f673df9a0205abffa0c145b9 -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/Properties/Resources.resx (.../Resources.resx) (revision 14c7697f5bec8544f673df9a0205abffa0c145b9) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/Properties/Resources.resx (.../Resources.resx) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -1,103 +1,122 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + De bovengrens van de rekenreeks moet boven de ondergrens liggen. @@ -107,4 +126,13 @@ Stapgrootte moet groter zijn dan 0. + + 0.5 + + + 1.0 + + + 2.0 + \ No newline at end of file Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/Ringtoets.Revetment.Data.csproj =================================================================== diff -u -rbea6e87ff7f6b40ff9fcce4d46ccb55bb3b47535 -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/Ringtoets.Revetment.Data.csproj (.../Ringtoets.Revetment.Data.csproj) (revision bea6e87ff7f6b40ff9fcce4d46ccb55bb3b47535) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/Ringtoets.Revetment.Data.csproj (.../Ringtoets.Revetment.Data.csproj) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -47,6 +47,8 @@ Resources.resx + + @@ -60,6 +62,10 @@ Core.Common.Base False + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Utils + {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs =================================================================== diff -u -re4313e642aa3af2d1f1ced4c397c421579cfb36d -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision e4313e642aa3af2d1f1ced4c397c421579cfb36d) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInput.cs (.../WaveConditionsInput.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -42,7 +42,7 @@ private ForeshoreProfile foreshoreProfile; private RoundedDouble upperBoundaryRevetment; private RoundedDouble lowerBoundaryRevetment; - private RoundedDouble stepSize; + private WaveConditionsInputStepSize stepSize; private RoundedDouble upperBoundaryWaterLevels; private RoundedDouble lowerBoundaryWaterLevels; @@ -53,7 +53,7 @@ { upperBoundaryRevetment = new RoundedDouble(2, double.NaN); lowerBoundaryRevetment = new RoundedDouble(2, double.NaN); - stepSize = new RoundedDouble(1, double.NaN); + stepSize = WaveConditionsInputStepSize.Half; upperBoundaryWaterLevels = new RoundedDouble(2, double.NaN); lowerBoundaryWaterLevels = new RoundedDouble(2, double.NaN); @@ -176,22 +176,15 @@ /// Gets or sets the step size used for determining . /// /// Thrown when value is smaller than or equal to 0. - public RoundedDouble StepSize + public WaveConditionsInputStepSize StepSize { get { return stepSize; } set { - var newStepSize = value.ToPrecision(stepSize.NumberOfDecimalPlaces); - - if (!double.IsNaN(newStepSize) && newStepSize <= 0) - { - throw new ArgumentOutOfRangeException(null, Resources.WaveConditionsInput_StepSize_Should_be_greater_than_zero); - } - - stepSize = newStepSize; + stepSize = value; } } @@ -291,20 +284,20 @@ : double.MinValue)); if (double.IsNaN(upperBoundary) - || double.IsNaN(lowerBoundary) - || double.IsNaN(stepSize)) + || double.IsNaN(lowerBoundary)) { return waterLevels; } waterLevels.Add(lowerBoundary); - RoundedDouble currentWaterLevel = new RoundedDouble(2, Math.Floor(lowerBoundary/stepSize)*stepSize + stepSize); + double stepSizeValue = stepSize.AsValue(); + RoundedDouble currentWaterLevel = new RoundedDouble(2, Math.Floor(lowerBoundary/stepSizeValue)*stepSizeValue + stepSizeValue); while (currentWaterLevel < upperBoundary) { waterLevels.Add(currentWaterLevel); - currentWaterLevel = (currentWaterLevel + stepSize).ToPrecision(currentWaterLevel.NumberOfDecimalPlaces); + currentWaterLevel = new RoundedDouble(currentWaterLevel.NumberOfDecimalPlaces, currentWaterLevel + stepSizeValue); } waterLevels.Add(upperBoundary); Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInputStepSize.cs =================================================================== diff -u --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInputStepSize.cs (revision 0) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInputStepSize.cs (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -0,0 +1,50 @@ +// 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 Core.Common.Utils.Attributes; +using Ringtoets.Revetment.Data.Properties; + +namespace Ringtoets.Revetment.Data +{ + /// + /// Enum defining the possible step size for a wave conditions calculation. + /// + public enum WaveConditionsInputStepSize + { + /// + /// A step size of 0.5 + /// + [ResourcesDisplayName(typeof(Resources), "WaveConditionsInputStepSize_Half")] + Half, + + /// + /// A step size of 1.0 + /// + [ResourcesDisplayName(typeof(Resources), "WaveConditionsInputStepSize_One")] + One, + + /// + /// A step size of 2.0 + /// + [ResourcesDisplayName(typeof(Resources), "WaveConditionsInputStepSize_Two")] + Two, + } +} \ No newline at end of file Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInputStepSizeExtensions.cs =================================================================== diff -u --- Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInputStepSizeExtensions.cs (revision 0) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Data/WaveConditionsInputStepSizeExtensions.cs (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -0,0 +1,51 @@ +// 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.ComponentModel; + +namespace Ringtoets.Revetment.Data +{ + /// + /// Extension methods for the enum. + /// + public static class WaveConditionsInputStepSizeExtensions + { + /// + /// Gets the real value associated with the given . + /// + /// The step size to get a real value for. + /// The real value of . + public static double AsValue(this WaveConditionsInputStepSize stepSize) + { + switch (stepSize) + { + case WaveConditionsInputStepSize.Half: + return 0.5; + case WaveConditionsInputStepSize.One: + return 1.0; + case WaveConditionsInputStepSize.Two: + return 2.0; + default: + throw new InvalidEnumArgumentException("stepSize", (int) stepSize, typeof(WaveConditionsInputStepSize)); + } + } + } +} \ No newline at end of file Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/Ringtoets.Revetment.Data.Test.csproj =================================================================== diff -u -rbea6e87ff7f6b40ff9fcce4d46ccb55bb3b47535 -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/Ringtoets.Revetment.Data.Test.csproj (.../Ringtoets.Revetment.Data.Test.csproj) (revision bea6e87ff7f6b40ff9fcce4d46ccb55bb3b47535) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/Ringtoets.Revetment.Data.Test.csproj (.../Ringtoets.Revetment.Data.Test.csproj) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -50,6 +50,8 @@ + + @@ -64,6 +66,10 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Utils + {D749EE4C-CE50-4C17-BF01-9A953028C126} Core.Common.TestUtil Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputStepSizeExtensionsTest.cs =================================================================== diff -u --- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputStepSizeExtensionsTest.cs (revision 0) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputStepSizeExtensionsTest.cs (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -0,0 +1,54 @@ +// 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.ComponentModel; +using NUnit.Framework; + +namespace Ringtoets.Revetment.Data.Test +{ + [TestFixture] + public class WaveConditionsInputStepSizeExtensionsTest + { + [Test] + [TestCase(WaveConditionsInputStepSize.Half, 0.5)] + [TestCase(WaveConditionsInputStepSize.One, 1.0)] + [TestCase(WaveConditionsInputStepSize.Two, 2.0)] + public void AsValue_Half_ReturnHalfValue(WaveConditionsInputStepSize stepSize, double expectedValue) + { + // Call + var result = stepSize.AsValue(); + + // Assert + Assert.AreEqual(expectedValue, result); + } + + [Test] + public void AsValue_InvalidValue_Throws() + { + // Call + TestDelegate test = () => ((WaveConditionsInputStepSize)4).AsValue(); + + // Assert + var parameter = Assert.Throws(test).ParamName; + Assert.AreEqual("stepSize", parameter); + } + } +} \ No newline at end of file Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputStepSizeTest.cs =================================================================== diff -u --- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputStepSizeTest.cs (revision 0) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputStepSizeTest.cs (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -0,0 +1,49 @@ +// 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.Utils.Attributes; +using Core.Common.Utils.Reflection; +using NUnit.Framework; + +namespace Ringtoets.Revetment.Data.Test +{ + [TestFixture] + public class WaveConditionsInputStepSizeTest + { + [Test] + public void DisplayName_Always_ReturnExpectedValues() + { + // Assert + Assert.AreEqual("0.5", GetDisplayName(WaveConditionsInputStepSize.Half)); + Assert.AreEqual("1.0", GetDisplayName(WaveConditionsInputStepSize.One)); + Assert.AreEqual("2.0", GetDisplayName(WaveConditionsInputStepSize.Two)); + } + + private string GetDisplayName(WaveConditionsInputStepSize value) + { + var type = typeof(WaveConditionsInputStepSize); + var memInfo = type.GetMember(value.ToString()); + var attributes = memInfo[0].GetCustomAttributes(typeof(ResourcesDisplayNameAttribute), false); + return ((ResourcesDisplayNameAttribute)attributes[0]).DisplayName; + } + } +} \ No newline at end of file Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs =================================================================== diff -u -re4313e642aa3af2d1f1ced4c397c421579cfb36d -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision e4313e642aa3af2d1f1ced4c397c421579cfb36d) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -41,13 +41,13 @@ { get { - yield return new TestCaseData(10, 3.58, 6.10, 3.40, 5.88, 5.99, new[] + yield return new TestCaseData(WaveConditionsInputStepSize.Two, 2.58, 6.10, 2.40, 3.89, 5.99, new[] { - new RoundedDouble(2, 3.58), - new RoundedDouble(2, 5.88) + new RoundedDouble(2, 2.58), + new RoundedDouble(2, 3.89) }); - yield return new TestCaseData(0.5, 3.58, 6.10, 3.40, 5.88, 5.99, new[] + yield return new TestCaseData(WaveConditionsInputStepSize.Half, 3.58, 6.10, 3.40, 5.88, 5.99, new[] { new RoundedDouble(2, 3.58), new RoundedDouble(2, 4), @@ -57,7 +57,7 @@ new RoundedDouble(2, 5.88) }); - yield return new TestCaseData(1, -1.30, 5.80, -1.20, 6.01, 6.10, new[] + yield return new TestCaseData(WaveConditionsInputStepSize.One, -1.30, 5.80, -1.20, 6.01, 6.10, new[] { new RoundedDouble(2, -1.20), new RoundedDouble(2, -1), @@ -70,7 +70,7 @@ new RoundedDouble(2, 5.80) }); - yield return new TestCaseData(2, -4.29, 8.67, -4.29, 8.58, 8.58, new[] + yield return new TestCaseData(WaveConditionsInputStepSize.Two, -4.29, 8.67, -4.29, 8.58, 8.58, new[] { new RoundedDouble(2, -4.29), new RoundedDouble(2, -4), @@ -83,7 +83,7 @@ new RoundedDouble(2, 8.57) }); - yield return new TestCaseData(2, -4.29, 8.67, double.NaN, double.NaN, 8.58, new[] + yield return new TestCaseData(WaveConditionsInputStepSize.Two, -4.29, 8.67, double.NaN, double.NaN, 8.58, new[] { new RoundedDouble(2, -4.29), new RoundedDouble(2, -4), @@ -118,7 +118,7 @@ Assert.AreEqual(new RoundedDouble(2, double.NaN), input.UpperBoundaryDesignWaterLevel); Assert.AreEqual(new RoundedDouble(2, double.NaN), input.LowerBoundaryRevetment); Assert.AreEqual(new RoundedDouble(2, double.NaN), input.UpperBoundaryRevetment); - Assert.AreEqual(new RoundedDouble(1, double.NaN), input.StepSize); + Assert.AreEqual(WaveConditionsInputStepSize.Half, input.StepSize); Assert.AreEqual(new RoundedDouble(2, double.NaN), input.LowerBoundaryWaterLevels); Assert.AreEqual(new RoundedDouble(2, double.NaN), input.UpperBoundaryWaterLevels); CollectionAssert.IsEmpty(input.WaterLevels); @@ -414,54 +414,6 @@ } [Test] - public void StepSize_SetNewValue_ValueIsRounded() - { - // Setup - var input = new WaveConditionsInput(); - - int originalNumberOfDecimalPlaces = input.StepSize.NumberOfDecimalPlaces; - - // Call - input.StepSize = new RoundedDouble(5, 1.23456); - - // Assert - Assert.AreEqual(originalNumberOfDecimalPlaces, input.StepSize.NumberOfDecimalPlaces); - Assert.AreEqual(1.2, input.StepSize.Value); - } - - [Test] - [TestCase(1.0)] - [TestCase(0.05)] - public void StepSize_ValidValue_ValueIsSet(double stepSize) - { - // Setup - var input = new WaveConditionsInput(); - - // Call - input.StepSize = (RoundedDouble) stepSize; - - // Assert - Assert.AreEqual(stepSize, input.StepSize, input.StepSize.GetAccuracy()); - } - - [Test] - [TestCase(-1.0)] - [TestCase(0.0)] - [TestCase(0.004)] - public void StepSize_InvalidValue_ThrowsArgumentOutOfRangeException(double stepSize) - { - // Setup - var input = new WaveConditionsInput(); - - // Call - TestDelegate test = () => input.StepSize = (RoundedDouble) stepSize; - - // Assert - string expectedMessage = Resources.WaveConditionsInput_StepSize_Should_be_greater_than_zero; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); - } - - [Test] public void LowerBoundaryWaterLevels_SetNewValue_ValueIsRounded() { // Setup @@ -576,11 +528,10 @@ } [Test] - [TestCase(double.NaN, 1.0, 10.0, 12.0)] - [TestCase(1.0, double.NaN, 10.0, 12.0)] - [TestCase(1.0, 1.0, double.NaN, 12.0)] - [TestCase(1.0, 1.0, 10.0, double.NaN)] - public void WaterLevels_InvalidInput_NoWaterLevels(double stepSize, double lowerBoundaryRevetments, double upperBoundaryRevetments, double designWaterLevel) + [TestCase(double.NaN, 10.0, 12.0)] + [TestCase(1.0, double.NaN, 12.0)] + [TestCase(1.0, 10.0, double.NaN)] + public void WaterLevels_InvalidInput_NoWaterLevels(double lowerBoundaryRevetments, double upperBoundaryRevetments, double designWaterLevel) { // Setup var input = new WaveConditionsInput @@ -591,7 +542,7 @@ }, LowerBoundaryRevetment = (RoundedDouble) lowerBoundaryRevetments, UpperBoundaryRevetment = (RoundedDouble) upperBoundaryRevetments, - StepSize = (RoundedDouble) stepSize, + StepSize = WaveConditionsInputStepSize.One, LowerBoundaryWaterLevels = (RoundedDouble) 1.0, UpperBoundaryWaterLevels = (RoundedDouble) 10.0 }; @@ -610,8 +561,8 @@ var input = new WaveConditionsInput { LowerBoundaryRevetment = (RoundedDouble) 1.0, - UpperBoundaryRevetment = (RoundedDouble) 10.0, - StepSize = (RoundedDouble) 1.0, + UpperBoundaryRevetment = (RoundedDouble)10.0, + StepSize = WaveConditionsInputStepSize.One, LowerBoundaryWaterLevels = (RoundedDouble) 1.0, UpperBoundaryWaterLevels = (RoundedDouble) 10.0 }; @@ -625,7 +576,7 @@ [Test] [TestCaseSource("WaterLevels")] - public void WaterLevels_ValidInput_ReturnsWaterLevels(double stepSize, double lowerBoundaryRevetment, double upperBoundaryRevetment, + public void WaterLevels_ValidInput_ReturnsWaterLevels(WaveConditionsInputStepSize stepSize, double lowerBoundaryRevetment, double upperBoundaryRevetment, double lowerBoundaryWaterLevels, double upperBoundaryWaterLevels, double designWaterLevel, IEnumerable expectedWaterLevels) { @@ -638,7 +589,7 @@ }, LowerBoundaryRevetment = (RoundedDouble) lowerBoundaryRevetment, UpperBoundaryRevetment = (RoundedDouble) upperBoundaryRevetment, - StepSize = (RoundedDouble) stepSize, + StepSize = stepSize, LowerBoundaryWaterLevels = (RoundedDouble) lowerBoundaryWaterLevels, UpperBoundaryWaterLevels = (RoundedDouble) upperBoundaryWaterLevels }; Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverWaveConditionsCalculationInputContextProperties.cs =================================================================== diff -u -re4313e642aa3af2d1f1ced4c397c421579cfb36d -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverWaveConditionsCalculationInputContextProperties.cs (.../StabilityStoneCoverWaveConditionsCalculationInputContextProperties.cs) (revision e4313e642aa3af2d1f1ced4c397c421579cfb36d) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverWaveConditionsCalculationInputContextProperties.cs (.../StabilityStoneCoverWaveConditionsCalculationInputContextProperties.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -29,10 +29,12 @@ using Core.Common.Gui.Attributes; using Core.Common.Gui.Converters; using Core.Common.Gui.PropertyBag; +using Core.Common.Utils; using Core.Common.Utils.Attributes; using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.HydraRing.Data; +using Ringtoets.Revetment.Data; using Ringtoets.Revetment.Forms.PropertyClasses; using Ringtoets.StabilityStoneCover.Forms.PresentationObjects; using Ringtoets.StabilityStoneCover.Forms.UITypeEditors; @@ -171,10 +173,11 @@ } [PropertyOrder(stepSizePropertyIndex)] + [TypeConverter(typeof(EnumTypeConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_HydraulicData")] [ResourcesDisplayName(typeof(Resources), "StabilityStoneCoverWaveConditionsCalculationInput_StepSize_DisplayName")] [ResourcesDescription(typeof(Resources), "StabilityStoneCoverWaveConditionsCalculationInput_StepSize_Description")] - public RoundedDouble StepSize + public WaveConditionsInputStepSize StepSize { get { Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverWaveConditionsCalculationInputContextPropertiesTest.cs =================================================================== diff -u -re4313e642aa3af2d1f1ced4c397c421579cfb36d -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverWaveConditionsCalculationInputContextPropertiesTest.cs (.../StabilityStoneCoverWaveConditionsCalculationInputContextPropertiesTest.cs) (revision e4313e642aa3af2d1f1ced4c397c421579cfb36d) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverWaveConditionsCalculationInputContextPropertiesTest.cs (.../StabilityStoneCoverWaveConditionsCalculationInputContextPropertiesTest.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -27,6 +27,7 @@ using Core.Common.Base.Geometry; using Core.Common.Gui.Converters; using Core.Common.Gui.PropertyBag; +using Core.Common.Utils; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; @@ -109,8 +110,7 @@ Assert.AreEqual(2, properties.UpperBoundaryWaterLevels.NumberOfDecimalPlaces); Assert.IsNaN(properties.LowerBoundaryWaterLevels.Value); Assert.AreEqual(2, properties.LowerBoundaryWaterLevels.NumberOfDecimalPlaces); - Assert.AreEqual(1, properties.StepSize.NumberOfDecimalPlaces); - Assert.IsNaN(properties.StepSize.Value); + Assert.AreEqual(0.5, properties.StepSize.AsValue()); CollectionAssert.AreEqual(input.WaterLevels, properties.WaterLevels); Assert.IsNull(properties.ForeshoreProfile); @@ -139,7 +139,7 @@ var lowerBoundaryWaterLevels = (RoundedDouble)random.NextDouble(); var upperBoundaryRevetment = lowerBoundaryRevetment + (RoundedDouble)random.NextDouble(); var upperBoundaryWaterLevels = lowerBoundaryWaterLevels + (RoundedDouble)random.NextDouble(); - var stepSize = (RoundedDouble)0.5; + var stepSize = WaveConditionsInputStepSize.Half; var worldX = (RoundedDouble) random.NextDouble(); var worldY = (RoundedDouble) random.NextDouble(); @@ -210,7 +210,7 @@ var newLowerBoundaryWaterLevels = (RoundedDouble)random.NextDouble(); var newUpperBoundaryRevetment = newLowerBoundaryRevetment + (RoundedDouble)random.NextDouble(); var newUpperBoundaryWaterLevels = newLowerBoundaryWaterLevels + (RoundedDouble)random.NextDouble(); - var newStepSize = (RoundedDouble)0.5; + var newStepSize = WaveConditionsInputStepSize.Half; var newHydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "name", 0.0, 1.1) { @@ -256,8 +256,7 @@ Assert.AreEqual(2, properties.UpperBoundaryWaterLevels.NumberOfDecimalPlaces); Assert.AreEqual(newLowerBoundaryWaterLevels.Value, properties.LowerBoundaryWaterLevels.Value, properties.LowerBoundaryWaterLevels.GetAccuracy()); Assert.AreEqual(2, properties.LowerBoundaryWaterLevels.NumberOfDecimalPlaces); - Assert.AreEqual(1, properties.StepSize.NumberOfDecimalPlaces); - Assert.AreEqual(newStepSize.Value, properties.StepSize.Value); + Assert.AreEqual(newStepSize, properties.StepSize); mockRepository.VerifyAll(); } @@ -349,6 +348,7 @@ PropertyDescriptor stepSizeProperty = dynamicProperties[stepSizePropertyIndex]; Assert.IsNotNull(stepSizeProperty); + Assert.IsInstanceOf(stepSizeProperty.Converter); Assert.IsFalse(stepSizeProperty.IsReadOnly); Assert.AreEqual(hydraulicParametersCategory, stepSizeProperty.Category); Assert.AreEqual("Stapgrootte [m]", stepSizeProperty.DisplayName); Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs =================================================================== diff -u -r8d2afa5656fac63e26e3bee8573fdffabca8d768 -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 8d2afa5656fac63e26e3bee8573fdffabca8d768) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationContextTreeNodeInfoTest.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -1001,7 +1001,7 @@ ForeshoreProfile = CreateForeshoreProfile(), UseForeshore = true, UseBreakWater = true, - StepSize = (RoundedDouble)0.5, + StepSize = WaveConditionsInputStepSize.Half, LowerBoundaryRevetment = (RoundedDouble)4, UpperBoundaryRevetment = (RoundedDouble)10, UpperBoundaryWaterLevels = (RoundedDouble)8, Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs =================================================================== diff -u -rd4f6782b27a8e239562812f1482c1e8cb4843e64 -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision d4f6782b27a8e239562812f1482c1e8cb4843e64) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Forms.Test/TreeNodeInfos/StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs (.../StabilityStoneCoverWaveConditionsCalculationGroupContextTreeNodeInfoTest.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -1586,11 +1586,11 @@ ForeshoreProfile = CreateForeshoreProfile(), UseForeshore = true, UseBreakWater = true, - StepSize = (RoundedDouble) 0.5, - LowerBoundaryRevetment = (RoundedDouble) 4, - UpperBoundaryRevetment = (RoundedDouble) 10, - UpperBoundaryWaterLevels = (RoundedDouble) 8, - LowerBoundaryWaterLevels = (RoundedDouble) 7.1 + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble)4, + UpperBoundaryRevetment = (RoundedDouble)10, + UpperBoundaryWaterLevels = (RoundedDouble)8, + LowerBoundaryWaterLevels = (RoundedDouble)7.1 } }; calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 9.3; Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -rdd84b844a388b0dc3f721bd40674c4ed513b3231 -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision dd84b844a388b0dc3f721bd40674c4ed513b3231) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -62,7 +62,7 @@ ForeshoreProfile = CreateForeshoreProfile(), UseForeshore = true, UseBreakWater = true, - StepSize = (RoundedDouble) 0.5, + StepSize = WaveConditionsInputStepSize.Half, LowerBoundaryRevetment = (RoundedDouble) 5.3, UpperBoundaryRevetment = (RoundedDouble) 10, UpperBoundaryWaterLevels = (RoundedDouble) 5.4, @@ -318,7 +318,7 @@ ForeshoreProfile = CreateForeshoreProfile(), UseForeshore = true, UseBreakWater = true, - StepSize = (RoundedDouble) 0.5, + StepSize = WaveConditionsInputStepSize.Half, LowerBoundaryRevetment = (RoundedDouble) 4, UpperBoundaryRevetment = (RoundedDouble) 10, UpperBoundaryWaterLevels = (RoundedDouble) 8, Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Integration.Test/WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -rdd84b844a388b0dc3f721bd40674c4ed513b3231 -r8efe4bdfd7e47208edb8585a8ac32ebcd56635c0 --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Integration.Test/WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision dd84b844a388b0dc3f721bd40674c4ed513b3231) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Integration.Test/WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision 8efe4bdfd7e47208edb8585a8ac32ebcd56635c0) @@ -63,7 +63,7 @@ ForeshoreProfile = CreateForeshoreProfile(), UseForeshore = true, UseBreakWater = true, - StepSize = (RoundedDouble) 0.5, + StepSize = WaveConditionsInputStepSize.Half, LowerBoundaryRevetment = (RoundedDouble) 5.3, UpperBoundaryRevetment = (RoundedDouble) 10, UpperBoundaryWaterLevels = (RoundedDouble) 5.4, @@ -311,7 +311,7 @@ ForeshoreProfile = CreateForeshoreProfile(), UseForeshore = true, UseBreakWater = true, - StepSize = (RoundedDouble) 0.5, + StepSize = WaveConditionsInputStepSize.Half, LowerBoundaryRevetment = (RoundedDouble) 4, UpperBoundaryRevetment = (RoundedDouble) 10, UpperBoundaryWaterLevels = (RoundedDouble) 8,