Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r428346aca4810ed68d8778943246f581cb1a4386 -rbe8c50b3fa0529fda1fe17ddeae50055f958a0bd
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 428346aca4810ed68d8778943246f581cb1a4386)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision be8c50b3fa0529fda1fe17ddeae50055f958a0bd)
@@ -1031,6 +1031,16 @@
}
///
+ /// Looks up a localized string similar to Voor locatie '{0}' is geen toetspeil berekend..
+ ///
+ public static string PipingInputContextProperties_HydraulicBoundaryLocation_No_design_water_level_calculated {
+ get {
+ return ResourceManager.GetString("PipingInputContextProperties_HydraulicBoundaryLocation_No_design_water_level_calc" +
+ "ulated", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
public static System.Drawing.Bitmap PipingInputIcon {
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx
===================================================================
diff -u -r428346aca4810ed68d8778943246f581cb1a4386 -rbe8c50b3fa0529fda1fe17ddeae50055f958a0bd
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision 428346aca4810ed68d8778943246f581cb1a4386)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Properties/Resources.resx (.../Resources.resx) (revision be8c50b3fa0529fda1fe17ddeae50055f958a0bd)
@@ -577,4 +577,7 @@
Locatie met hydraulische randvoorwaarden
+
+ Voor locatie '{0}' is geen toetspeil berekend.
+
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs
===================================================================
diff -u -r428346aca4810ed68d8778943246f581cb1a4386 -rbe8c50b3fa0529fda1fe17ddeae50055f958a0bd
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 428346aca4810ed68d8778943246f581cb1a4386)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision be8c50b3fa0529fda1fe17ddeae50055f958a0bd)
@@ -201,7 +201,13 @@
}
set
{
+ if (double.IsNaN(value.DesignWaterLevel))
+ {
+ string message = string.Format(Resources.PipingInputContextProperties_HydraulicBoundaryLocation_No_design_water_level_calculated, value.Name);
+ throw new ArgumentException(message);
+ }
data.WrappedData.HydraulicBoundaryLocation = value;
+ data.WrappedData.AssessmentLevel = value.DesignWaterLevel;
data.WrappedData.NotifyObservers();
}
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs
===================================================================
diff -u -r428346aca4810ed68d8778943246f581cb1a4386 -rbe8c50b3fa0529fda1fe17ddeae50055f958a0bd
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 428346aca4810ed68d8778943246f581cb1a4386)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision be8c50b3fa0529fda1fe17ddeae50055f958a0bd)
@@ -478,6 +478,82 @@
mocks.ReplayAll();
}
+ [Test]
+ public void HydraulicBoundaryLocation_DesignWaterLevelIsNaN_ThrowsArgumentException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSectionMock = mocks.StrictMock();
+ var projectObserver = mocks.StrictMock();
+ mocks.ReplayAll();
+
+ var inputParameters = new PipingInput();
+ inputParameters.Attach(projectObserver);
+
+ var properties = new PipingInputContextProperties
+ {
+ Data = new PipingInputContext(inputParameters,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ assessmentSectionMock)
+ };
+
+ string testName = "TestName";
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, testName, 0, 0)
+ {
+ DesignWaterLevel = double.NaN
+ };
+
+ // Call
+ TestDelegate test = () => properties.HydraulicBoundaryLocation = hydraulicBoundaryLocation;
+
+ // Assert
+ var message = string.Format("Voor locatie '{0}' is geen toetspeil berekend.", testName);
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, message);
+
+ Assert.AreEqual(0, properties.AssessmentLevelSellmeijer);
+ Assert.AreEqual(0, properties.AssessmentLevelUplift);
+
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void HydraulicBoundaryLocation_DesignWaterLevelSet_SetsAssessmentLevelToDesignWaterLevelAndNotifiesOnce()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var assessmentSectionMock = mocks.StrictMock();
+ var projectObserver = mocks.StrictMock();
+ projectObserver.Expect(o => o.UpdateObserver()).Repeat.Times(1);
+ mocks.ReplayAll();
+
+ var inputParameters = new PipingInput();
+ inputParameters.Attach(projectObserver);
+
+ var properties = new PipingInputContextProperties
+ {
+ Data = new PipingInputContext(inputParameters,
+ Enumerable.Empty(),
+ Enumerable.Empty(),
+ assessmentSectionMock)
+ };
+
+ double testLevel = new Random(21).NextDouble();
+ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0, 0)
+ {
+ DesignWaterLevel = testLevel
+ };
+
+ // Call
+ properties.HydraulicBoundaryLocation = hydraulicBoundaryLocation;
+
+ // Assert
+ Assert.AreEqual(testLevel, properties.AssessmentLevelSellmeijer);
+ Assert.AreEqual(testLevel, properties.AssessmentLevelUplift);
+
+ mocks.VerifyAll();
+ }
+
private static RingtoetsPipingSurfaceLine ValidSurfaceLine(double xMin, double xMax)
{
var surfaceLine = new RingtoetsPipingSurfaceLine();