Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs =================================================================== diff -u -rf37230ff653580eb90dd878e6ecc4f15511a11d6 -r619e1c9f14861454e4cbe0109445de3bce0d7a75 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision f37230ff653580eb90dd878e6ecc4f15511a11d6) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Data.Test/WaveConditionsInputTest.cs (.../WaveConditionsInputTest.cs) (revision 619e1c9f14861454e4cbe0109445de3bce0d7a75) @@ -20,10 +20,13 @@ // All rights reserved. using System.Collections.Generic; +using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using NUnit.Framework; +using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.HydraRing.Data; namespace Ringtoets.Revetment.Data.Test @@ -38,15 +41,19 @@ var input = new WaveConditionsInput(); // Assert + Assert.IsInstanceOf(input); + Assert.IsInstanceOf(input); Assert.IsNull(input.HydraulicBoundaryLocation); Assert.IsNull(input.DikeProfile); Assert.IsFalse(input.UseBreakWater); Assert.AreEqual(BreakWaterType.Dam, input.BreakWater.Type); Assert.AreEqual(new RoundedDouble(2), input.BreakWater.Height); Assert.IsFalse(input.UseForeshore); CollectionAssert.IsEmpty(input.ForeshoreGeometry); - Assert.AreEqual(new RoundedDouble(2), input.UpperLevel); - Assert.AreEqual(new RoundedDouble(2), input.LowerLevel); + Assert.AreEqual(new RoundedDouble(2), input.UpperRevetmentLevel); + Assert.AreEqual(new RoundedDouble(2), input.LowerRevetmentLevel); + Assert.AreEqual(new RoundedDouble(2), input.LowerWaterLevel); + Assert.AreEqual(new RoundedDouble(2), input.UpperWaterLevel); Assert.AreEqual(new RoundedDouble(1), input.StepSize); } @@ -158,38 +165,54 @@ } [Test] - public void UpperLevel_SetNewValue_ValueIsRounded() + public void UpperRevetmentLevel_SetNewValue_ValueIsRounded() { // Setup var input = new WaveConditionsInput(); - int originalNumberOfDecimalPlaces = input.UpperLevel.NumberOfDecimalPlaces; + int originalNumberOfDecimalPlaces = input.UpperRevetmentLevel.NumberOfDecimalPlaces; // Call - input.UpperLevel = new RoundedDouble(5, 1.23456); + input.UpperRevetmentLevel = new RoundedDouble(5, 1.23456); // Assert - Assert.AreEqual(originalNumberOfDecimalPlaces, input.UpperLevel.NumberOfDecimalPlaces); - Assert.AreEqual(1.23, input.UpperLevel.Value); + Assert.AreEqual(originalNumberOfDecimalPlaces, input.UpperRevetmentLevel.NumberOfDecimalPlaces); + Assert.AreEqual(1.23, input.UpperRevetmentLevel.Value); } [Test] - public void LowerLevel_SetNewValue_ValueIsRounded() + public void LowerRevetmentLevel_SetNewValue_ValueIsRounded() { // Setup var input = new WaveConditionsInput(); - int originalNumberOfDecimalPlaces = input.LowerLevel.NumberOfDecimalPlaces; + int originalNumberOfDecimalPlaces = input.LowerRevetmentLevel.NumberOfDecimalPlaces; // Call - input.LowerLevel = new RoundedDouble(5, 1.23456); + input.LowerRevetmentLevel = new RoundedDouble(5, 1.23456); // Assert - Assert.AreEqual(originalNumberOfDecimalPlaces, input.LowerLevel.NumberOfDecimalPlaces); - Assert.AreEqual(1.23, input.LowerLevel.Value); + Assert.AreEqual(originalNumberOfDecimalPlaces, input.LowerRevetmentLevel.NumberOfDecimalPlaces); + Assert.AreEqual(1.23, input.LowerRevetmentLevel.Value); } [Test] + public void LowerWaterLevel_SetNewValue_ValueIsRounded() + { + // Setup + var input = new WaveConditionsInput(); + + int originalNumberOfDecimalPlaces = input.LowerWaterLevel.NumberOfDecimalPlaces; + + // Call + input.LowerWaterLevel = new RoundedDouble(5, 1.23456); + + // Assert + Assert.AreEqual(originalNumberOfDecimalPlaces, input.LowerWaterLevel.NumberOfDecimalPlaces); + Assert.AreEqual(1.23, input.LowerWaterLevel.Value); + } + + [Test] public void StepSize_SetNewValue_ValueIsRounded() { // Setup @@ -204,5 +227,81 @@ Assert.AreEqual(originalNumberOfDecimalPlaces, input.StepSize.NumberOfDecimalPlaces); Assert.AreEqual(1.2, input.StepSize.Value); } + + [Test] + public void HydraulicBoundaryLocation_SetNewValue_UpperWaterLevelUpdated() + { + // Setup + var input = new WaveConditionsInput(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = new RoundedDouble(2, 6.34) + }; + + // Call + input.HydraulicBoundaryLocation = hydraulicBoundaryLocation; + + // Assert + Assert.AreEqual(6.33, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy()); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void HydraulicBoundaryLocation_WithoutDesignWaterLevel_UpperWaterLevelSetToDefault(bool withDesignWaterLevel) + { + // Setup + var input = new WaveConditionsInput(); + + if (withDesignWaterLevel) + { + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = new RoundedDouble(2, 6.34) + }; + + input.HydraulicBoundaryLocation = hydraulicBoundaryLocation; + + // Precondition + Assert.AreEqual(6.33, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy()); + } + + var newHydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0); + + // Call + input.HydraulicBoundaryLocation = newHydraulicBoundaryLocation; + + // Assert + Assert.AreEqual(new RoundedDouble(2), input.UpperWaterLevel); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void HydraulicBoundaryLocation_HydraulicBoundaryLocationNull_UpperWaterLevelSetToDefault(bool withDesignWaterLevel) + { + // Setup + var input = new WaveConditionsInput(); + + if (withDesignWaterLevel) + { + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = new RoundedDouble(2, 6.34) + }; + + input.HydraulicBoundaryLocation = hydraulicBoundaryLocation; + + // Precondition + Assert.AreEqual(6.33, input.UpperWaterLevel, input.UpperWaterLevel.GetAccuracy()); + } + + + // Call + input.HydraulicBoundaryLocation = null; + + // Assert + Assert.AreEqual(new RoundedDouble(2), input.UpperWaterLevel); + } } } \ No newline at end of file