Index: Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs
===================================================================
diff -u -r03ee61e8df1f1512fe8a4f29f4b53b08e553145f -r7d4fdb527410c89577828ea5d84896945341bae8
--- Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 03ee61e8df1f1512fe8a4f29f4b53b08e553145f)
+++ Core/Common/src/Core.Common.Base/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -118,15 +118,6 @@
}
///
- /// Looks up a localized string similar to De waarde voor '{0}' moet een geldig getal zijn..
- ///
- public static string CalculationService_ValidateInput_Value_for_0_must_be_a_valid_number {
- get {
- return ResourceManager.GetString("CalculationService_ValidateInput_Value_for_0_must_be_a_valid_number", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Bevestigen.
///
public static string Confirm {
Index: Core/Common/src/Core.Common.Base/Properties/Resources.resx
===================================================================
diff -u -r03ee61e8df1f1512fe8a4f29f4b53b08e553145f -r7d4fdb527410c89577828ea5d84896945341bae8
--- Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision 03ee61e8df1f1512fe8a4f29f4b53b08e553145f)
+++ Core/Common/src/Core.Common.Base/Properties/Resources.resx (.../Resources.resx) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -174,7 +174,4 @@
Fout
-
- De waarde voor '{0}' moet een geldig getal zijn.
-
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs
===================================================================
diff -u -r03ee61e8df1f1512fe8a4f29f4b53b08e553145f -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 03ee61e8df1f1512fe8a4f29f4b53b08e553145f)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -127,6 +127,15 @@
}
///
+ /// Looks up a localized string similar to De waarde voor '{0}' moet een geldig getal zijn..
+ ///
+ public static string CalculationService_ValidateInput_Value_for_0_must_be_a_valid_number {
+ get {
+ return ResourceManager.GetString("CalculationService_ValidateInput_Value_for_0_must_be_a_valid_number", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Toetspeil berekening voor locatie {0} is niet geconvergeerd..
///
public static string DesignWaterLevelCalculationActivity_DesignWaterLevel_calculation_for_location_0_not_converged {
@@ -251,6 +260,15 @@
}
///
+ /// Looks up a localized string similar to Er is geen concreet getal ingevoerd voor '{0}'..
+ ///
+ public static string Validation_ValidateInput_No_value_entered_for_0_ {
+ get {
+ return ResourceManager.GetString("Validation_ValidateInput_No_value_entered_for_0_", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Golfhoogte berekening voor locatie {0} is niet geconvergeerd..
///
public static string WaveHeightCalculationActivity_WaveHeight_calculation_for_location_0_not_converged {
Index: Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx
===================================================================
diff -u -r03ee61e8df1f1512fe8a4f29f4b53b08e553145f -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision 03ee61e8df1f1512fe8a4f29f4b53b08e553145f)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/Properties/Resources.resx (.../Resources.resx) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -180,4 +180,10 @@
Er is geen kunstwerk geselecteerd.
+
+ De waarde voor '{0}' moet een geldig getal zijn.
+
+
+ Er is geen concreet getal ingevoerd voor '{0}'.
+
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsInput.cs
===================================================================
diff -u -rbcaf65d1f53f270fba046eaa396d3be77bd08c0f -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsInput.cs (.../GrassCoverErosionInwardsInput.cs) (revision bcaf65d1f53f270fba046eaa396d3be77bd08c0f)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsInput.cs (.../GrassCoverErosionInwardsInput.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.Linq;
using Core.Common.Base;
using Core.Common.Base.Data;
@@ -27,6 +28,7 @@
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.Probabilistics;
using Ringtoets.HydraRing.Data;
+using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
namespace Ringtoets.GrassCoverErosionInwards.Data
{
@@ -46,7 +48,7 @@
///
public GrassCoverErosionInwardsInput()
{
- orientation = new RoundedDouble(2);
+ orientation = new RoundedDouble(2, double.NaN);
dikeHeight = new RoundedDouble(2);
UpdateProfileParameters();
@@ -86,7 +88,12 @@
}
set
{
- orientation = value.ToPrecision(orientation.NumberOfDecimalPlaces);
+ RoundedDouble newOrientation = value.ToPrecision(orientation.NumberOfDecimalPlaces);
+ if (!double.IsNaN(newOrientation) && (newOrientation < 0 || newOrientation > 360))
+ {
+ throw new ArgumentOutOfRangeException("value", RingtoetsCommonDataResources.Orientation_Value_needs_to_be_between_0_and_360);
+ }
+ orientation = newOrientation;
}
}
@@ -170,7 +177,7 @@
{
if (dikeProfile == null)
{
- Orientation = (RoundedDouble) 0.0;
+ Orientation = (RoundedDouble) double.NaN;
UseForeshore = false;
UseBreakWater = false;
BreakWater = GetDefaultBreakWater();
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs
===================================================================
diff -u -rd50c59f03bb0dda390a20e79b402fd91f884234a -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision d50c59f03bb0dda390a20e79b402fd91f884234a)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -37,6 +37,7 @@
using Ringtoets.HydraRing.Calculation.Parsers;
using Ringtoets.HydraRing.IO;
using RingtoetsCommonServiceResources = Ringtoets.Common.Service.Properties.Resources;
+using RingtoetsCommonForms = Ringtoets.Common.Forms.Properties.Resources;
namespace Ringtoets.GrassCoverErosionInwards.Service
{
@@ -310,9 +311,22 @@
validationResult.Add(RingtoetsCommonServiceResources.Validation_Invalid_BreakWaterHeight_value);
}
}
+
+ if (double.IsNaN(inputParameters.Orientation))
+ {
+ string message = string.Format(RingtoetsCommonServiceResources.Validation_ValidateInput_No_value_entered_for_0_,
+ GenerateParameterNameWithoutUnits(RingtoetsCommonForms.Orientation_DisplayName));
+ validationResult.Add(message);
+ }
}
return validationResult.ToArray();
}
+
+ private static string GenerateParameterNameWithoutUnits(string parameterDescription)
+ {
+ string[] splitString = parameterDescription.Split('[');
+ return splitString.Length != 0 ? splitString[0].ToLower().Trim() : string.Empty;
+ }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Ringtoets.GrassCoverErosionInwards.Service.csproj
===================================================================
diff -u -r02670d8c9fceeaea5f829937a2eb269f3488c6b1 -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Ringtoets.GrassCoverErosionInwards.Service.csproj (.../Ringtoets.GrassCoverErosionInwards.Service.csproj) (revision 02670d8c9fceeaea5f829937a2eb269f3488c6b1)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/Ringtoets.GrassCoverErosionInwards.Service.csproj (.../Ringtoets.GrassCoverErosionInwards.Service.csproj) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -69,6 +69,11 @@
Ringtoets.Common.Data
False
+
+ {4d840673-3812-4338-a352-84854e32b8a0}
+ Ringtoets.Common.Forms
+ False
+
{D951D6DA-FE83-4920-9FDB-63BF96480B54}
Ringtoets.Common.Service
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs
===================================================================
diff -u -rd859a8308857ce1bf82ff94356a30363213c6ff6 -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision d859a8308857ce1bf82ff94356a30363213c6ff6)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -24,6 +24,7 @@
using Core.Common.Base;
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;
@@ -56,7 +57,8 @@
Assert.IsInstanceOf(input);
Assert.IsNull(input.DikeProfile);
- Assert.AreEqual(new RoundedDouble(2), input.Orientation);
+ Assert.AreEqual(2, input.Orientation.NumberOfDecimalPlaces);
+ Assert.IsNaN(input.Orientation);
Assert.IsFalse(input.UseBreakWater);
Assert.AreEqual(BreakWaterType.Dam, input.BreakWater.Type);
Assert.AreEqual(new RoundedDouble(2), input.BreakWater.Height);
@@ -178,7 +180,8 @@
input.DikeProfile = null;
// Assert
- Assert.AreEqual(new RoundedDouble(0), input.Orientation);
+ Assert.AreEqual(2, input.Orientation.NumberOfDecimalPlaces);
+ Assert.IsNaN(input.Orientation);
Assert.IsFalse(input.UseBreakWater);
Assert.AreEqual(originalBreakWaterType, input.BreakWater.Type);
Assert.AreEqual(originalBreakWaterHeight, input.BreakWater.Height);
@@ -191,22 +194,46 @@
}
[Test]
- public void Orientation_SetNewValue_ValueIsRounded()
+ [TestCase(360.004)]
+ [TestCase(300)]
+ [TestCase(0)]
+ [TestCase(-0.004)]
+ [TestCase(double.NaN)]
+ public void Orientation_SetNewValue_ValueIsRounded(double validOrientation)
{
// Setup
var input = new GrassCoverErosionInwardsInput();
int originalNumberOfDecimalPlaces = input.Orientation.NumberOfDecimalPlaces;
// Call
- input.Orientation = new RoundedDouble(5, 1.23456);
+ input.Orientation = new RoundedDouble(5, validOrientation);
// Assert
Assert.AreEqual(originalNumberOfDecimalPlaces, input.Orientation.NumberOfDecimalPlaces);
- Assert.AreEqual(1.23, input.Orientation.Value);
+ Assert.AreEqual(validOrientation, input.Orientation.Value, input.Orientation.GetAccuracy());
}
[Test]
+ [TestCase(400)]
+ [TestCase(360.05)]
+ [TestCase(-0.005)]
+ [TestCase(-23)]
+ [TestCase(double.PositiveInfinity)]
+ [TestCase(double.NegativeInfinity)]
+ public void Orientation_SetInvalidValue_ThrowsArgumentOutOfRangeException(double invalidOrientation)
+ {
+ // Setup
+ var input = new GrassCoverErosionInwardsInput();
+
+ // Call
+ TestDelegate call = () => input.Orientation = (RoundedDouble)invalidOrientation;
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "De waarde voor de oriëntatie moet in het bereik [0, 360] liggen.");
+ }
+
+ [Test]
public void DikeHeight_SetNewValue_ValueIsRounded()
{
// Setup
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs
===================================================================
diff -u -rcb4c5e6cd9a0478a8afe7d653bb7467b3c1a2b4e -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision cb4c5e6cd9a0478a8afe7d653bb7467b3c1a2b4e)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -95,7 +95,7 @@
// Assert
Assert.AreEqual(2, properties.Orientation.NumberOfDecimalPlaces);
Assert.IsNull(properties.DikeProfile);
- Assert.AreEqual(0.0, properties.Orientation.Value);
+ Assert.IsNaN(properties.Orientation.Value);
Assert.IsInstanceOf(properties.BreakWater);
Assert.IsInstanceOf(properties.Foreshore);
Assert.AreSame(inputContext, properties.DikeGeometry.Data);
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs
===================================================================
diff -u -r171bef69ca437d9501abcfe0ab858c6e7ce89061 -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision 171bef69ca437d9501abcfe0ab858c6e7ce89061)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -132,7 +132,8 @@
{
InputParameters =
{
- HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001)
+ HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
+ Orientation = (RoundedDouble) 0
}
};
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs
===================================================================
diff -u -raa019c917497b6ef42da091940f29e64fd82fc19 -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs (.../GrassCoverErosionInwardsCalculationServiceTest.cs) (revision aa019c917497b6ef42da091940f29e64fd82fc19)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Service.Test/GrassCoverErosionInwardsCalculationServiceTest.cs (.../GrassCoverErosionInwardsCalculationServiceTest.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -22,6 +22,7 @@
using System;
using System.IO;
using System.Linq;
+using Core.Common.Base.Data;
using Core.Common.Base.Geometry;
using Core.Common.TestUtil;
using NUnit.Framework;
@@ -31,7 +32,6 @@
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.Data.FailureMechanism;
using Ringtoets.GrassCoverErosionInwards.Data;
-using Ringtoets.HydraRing.Calculation.Calculator;
using Ringtoets.HydraRing.Calculation.Calculator.Factory;
using Ringtoets.HydraRing.Calculation.Parsers;
using Ringtoets.HydraRing.Calculation.TestUtil.Calculator;
@@ -186,7 +186,8 @@
Name = name,
InputParameters =
{
- HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "name", 2, 2)
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "name", 2, 2),
+ Orientation = (RoundedDouble) 0
}
};
@@ -245,6 +246,50 @@
}
[Test]
+ public void Validate_ValidInputAndInvalidOrientation_ReturnsFalse()
+ {
+ // Setup
+ var grassCoverErosionInwardsFailureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+
+ var mockRepository = new MockRepository();
+ var assessmentSectionStub = CreateAssessmentSectionStub(grassCoverErosionInwardsFailureMechanism, mockRepository);
+ mockRepository.ReplayAll();
+
+ const string name = "";
+
+ GrassCoverErosionInwardsCalculation calculation = new GrassCoverErosionInwardsCalculation()
+ {
+ Name = name,
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "name", 2, 2),
+ DikeProfile = new DikeProfile(new Point2D(0, 0), new RoughnessPoint[0], new Point2D[0],
+ null, new DikeProfile.ConstructionProperties()
+ {
+ Orientation = (RoundedDouble) double.NaN
+ })
+ }
+ };
+
+ // Call
+ bool isValid = false;
+ Action call = () => isValid = new GrassCoverErosionInwardsCalculationService().Validate(calculation, assessmentSectionStub);
+
+ // Assert
+ TestHelper.AssertLogMessages(call, messages =>
+ {
+ var msgs = messages.ToArray();
+ Assert.AreEqual(3, msgs.Length);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", name), msgs[0]);
+ Assert.AreEqual("Validatie mislukt: Er is geen concreet getal ingevoerd voor 'oriëntatie'.", msgs[1]);
+ StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]);
+ });
+ Assert.IsFalse(isValid);
+
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
[TestCase(true, 10.0)]
[TestCase(false, 10.0)]
[TestCase(false, double.NaN)]
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs
===================================================================
diff -u -r94280a98283d1dbe5381cbc46f59b996f5f43b19 -r7d4fdb527410c89577828ea5d84896945341bae8
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision 94280a98283d1dbe5381cbc46f59b996f5f43b19)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresCalculationService.cs (.../HeightStructuresCalculationService.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8)
@@ -62,7 +62,7 @@
{
CalculationServiceHelper.LogValidationBeginTime(calculation.Name);
- var messages = ValidateInput(calculation.InputParameters, assessmentSection);
+ string[] messages = ValidateInput(calculation.InputParameters, assessmentSection);
CalculationServiceHelper.LogMessagesAsError(RingtoetsCommonServiceResources.Error_in_validation_0, messages);
CalculationServiceHelper.LogValidationEndTime(calculation.Name);
@@ -195,7 +195,7 @@
if (IsInvalidNumber(inputParameters.DeviationWaveDirection))
{
- validationResult.Add(string.Format(Core.Common.Base.Properties.Resources.CalculationService_ValidateInput_Value_for_0_must_be_a_valid_number,
+ validationResult.Add(string.Format(RingtoetsCommonServiceResources.CalculationService_ValidateInput_Value_for_0_must_be_a_valid_number,
GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_DeviationWaveDirection_DisplayName)));
}
@@ -219,7 +219,6 @@
GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_LevelCrestStructure_DisplayName)));
validationResult.AddRange(DistributionValidationService.ValidateDistribution(inputParameters.CriticalOvertoppingDischarge,
GenerateParameterNameWithoutUnits(RingtoetsCommonFormsResources.Structure_CriticalOvertoppingDischarge_DisplayName)));
- // Probability structure given erosion
}
return validationResult.ToArray();