Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs =================================================================== diff -u -rb7563238aa805cb6207e948a97f6fcc9e52c92b2 -rc9bc3ec71edfc189d0d9724627b15f1abdc7fc1d --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision b7563238aa805cb6207e948a97f6fcc9e52c92b2) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision c9bc3ec71edfc189d0d9724627b15f1abdc7fc1d) @@ -389,7 +389,7 @@ } [Test] - public void UseManualAssessmentLevelInputFalse_HydraulicBoundaryCalculationUncalculated_AssessmentLevelNaN() + public void AssessmentLevel_UseAssessmentLevelManualInputIsFalse_ReturnsNaN() { // Setup var input = new PipingInput(new GeneralPipingInput()) @@ -406,31 +406,49 @@ } [Test] - public void UseAssessmentLevelManualInputFalseWithHydraulicBoundaryLocation_LocationUpdated_AssessmentLevelUpdated() + public void AssessmentLevel_UseAssessmentLevelManualInputIsFalseWithHydraulicLocationSetAndDesignWaterLevelOutputSet_ReturnCalculatedAssessmentLevel() { // Setup PipingInput input = new PipingInput(new GeneralPipingInput()); - var random = new Random(21); - double testLevel = random.NextDouble(); - HydraulicBoundaryLocation testHydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(testLevel); + HydraulicBoundaryLocation testHydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); input.HydraulicBoundaryLocation = testHydraulicBoundaryLocation; - double calculatedAssessmentLevel = random.NextDouble(); + double calculatedAssessmentLevel = new Random(21).NextDouble(); + testHydraulicBoundaryLocation.DesignWaterLevelOutput = new TestHydraulicBoundaryLocationOutput(calculatedAssessmentLevel); // Call - testHydraulicBoundaryLocation.DesignWaterLevelOutput = new TestHydraulicBoundaryLocationOutput(calculatedAssessmentLevel); + RoundedDouble newAssessmentLevel = input.AssessmentLevel; // Assert - Assert.AreEqual(calculatedAssessmentLevel, input.AssessmentLevel, input.AssessmentLevel.GetAccuracy()); + Assert.AreEqual(calculatedAssessmentLevel, newAssessmentLevel, input.AssessmentLevel.GetAccuracy()); } [Test] - public void UseAssessmentLevelManualInputTrueNoHydraulicBoundaryLocation_NewLevel_SetsNewAssessmentLevel() + public void AssessmentLevel_UseAssessmentLevelManualInputFalseAndSettingValue_ThrowsInvalidOperationException() { // Setup PipingInput input = new PipingInput(new GeneralPipingInput()) { + UseAssessmentLevelManualInput = false + }; + + RoundedDouble testLevel = (RoundedDouble) new Random(21).NextDouble(); + + // Call + TestDelegate call = () => input.AssessmentLevel = testLevel; + + // Assert + var message = Assert.Throws(call).Message; + Assert.AreEqual("UseAssessmentLevelManualInput is false", message); + } + + [Test] + public void AssessmentLevel_UseAssessmentLevelManualInputTrueAndSettingValue_ReturnSetValue() + { + // Setup + PipingInput input = new PipingInput(new GeneralPipingInput()) + { UseAssessmentLevelManualInput = true }; @@ -448,11 +466,12 @@ public void GivenAssessmentLevelSetByHydraulicBoundaryLocation_WhenManualAssessmentLevelTrueAndNewLevelSet_ThenLevelUpdatedAndLocationRemoved() { // Given - PipingInput input = new PipingInput(new GeneralPipingInput()); - var random = new Random(21); RoundedDouble testLevel = (RoundedDouble) random.NextDouble(); - input.HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(testLevel); + PipingInput input = new PipingInput(new GeneralPipingInput()) + { + HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(testLevel), + }; var newLevel = (RoundedDouble) random.NextDouble(); @@ -470,12 +489,13 @@ public void GivenAssessmentLevelSetByManualInput_WhenWhenManualAssessmentLevelFalseAndHydraulicBoundaryLocationSet_ThenAssessmentLevelUpdatedAndLocationSet() { // Given - PipingInput input = new PipingInput(new GeneralPipingInput()); - var random = new Random(21); var testLevel = (RoundedDouble) random.NextDouble(); - input.UseAssessmentLevelManualInput = true; - input.AssessmentLevel = testLevel; + PipingInput input = new PipingInput(new GeneralPipingInput()) + { + UseAssessmentLevelManualInput = true, + AssessmentLevel = testLevel, + }; var newLevel = (RoundedDouble) random.NextDouble(); var hydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(newLevel);