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();