Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs =================================================================== diff -u -rd858f30eadf831082d4398223675bc458d298c42 -r7927641f2d9d74e77740f88c794fbcfd03a250dc --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision d858f30eadf831082d4398223675bc458d298c42) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision 7927641f2d9d74e77740f88c794fbcfd03a250dc) @@ -28,7 +28,6 @@ using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; -using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Piping.Data.TestUtil; @@ -100,14 +99,13 @@ Assert.IsNaN(inputParameters.EntryPointL); Assert.AreEqual(2, inputParameters.EntryPointL.NumberOfDecimalPlaces); - Assert.IsInstanceOf(inputParameters.AssessmentLevel); Assert.IsNaN(inputParameters.AssessmentLevel); - + Assert.AreEqual(2, inputParameters.AssessmentLevel.NumberOfDecimalPlaces); Assert.IsFalse(inputParameters.UseAssessmentLevelManualInput); } [Test] - public void Constructor_GeneralPipingInputIsNull_ArgumentNullException() + public void Constructor_GeneralPipingInputNull_ThrowsArgumentNullException() { // Call TestDelegate call = () => new PipingInput(null); @@ -117,38 +115,38 @@ } [Test] - [TestCase(1.23456)] - [TestCase(3.5)] - public void ExitPointL_ExitPointEqualSmallerThanEntryPoint_ThrowsArgumentOutOfRangeException(double value) + public void ExitPointL_Always_SameNumberOfDecimalsAsSurfaceLineLocalGeometry() { // Setup var pipingInput = new PipingInput(new GeneralPipingInput()) { - EntryPointL = (RoundedDouble) 3.5 + SurfaceLine = CreateSurfaceLine() }; // Call - TestDelegate call = () => pipingInput.ExitPointL = (RoundedDouble) value; + RoundedPoint2DCollection localGeometry = pipingInput.SurfaceLine.LocalGeometry; // Assert - const string expectedMessage = "Het uittredepunt moet landwaarts van het intredepunt liggen."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); + Assert.AreEqual(localGeometry.NumberOfDecimalPlaces, pipingInput.ExitPointL.NumberOfDecimalPlaces); } [Test] - public void ExitPointL_Always_SameNumberOfDecimalsAsSurfaceLineLocalGeometry() + [TestCase(1.23456)] + [TestCase(3.5)] + public void ExitPointL_ExitPointEqualSmallerThanEntryPoint_ThrowsArgumentOutOfRangeException(double value) { // Setup var pipingInput = new PipingInput(new GeneralPipingInput()) { - SurfaceLine = CreateSurfaceLine() + EntryPointL = (RoundedDouble) 3.5 }; // Call - RoundedPoint2DCollection localGeometry = pipingInput.SurfaceLine.LocalGeometry; + TestDelegate call = () => pipingInput.ExitPointL = (RoundedDouble) value; // Assert - Assert.AreEqual(localGeometry.NumberOfDecimalPlaces, pipingInput.ExitPointL.NumberOfDecimalPlaces); + const string expectedMessage = "Het uittredepunt moet landwaarts van het intredepunt liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); } [Test] @@ -193,6 +191,20 @@ } [Test] + public void EntryPointL_Always_SameNumberOfDecimalsAsSurfaceLineLocalGeometry() + { + // Setup + PipingSurfaceLine surfaceLine = CreateSurfaceLine(); + var pipingInput = new PipingInput(new GeneralPipingInput()); + + // Call + RoundedPoint2DCollection localGeometry = surfaceLine.LocalGeometry; + + // Assert + Assert.AreEqual(localGeometry.NumberOfDecimalPlaces, pipingInput.EntryPointL.NumberOfDecimalPlaces); + } + + [Test] [TestCase(5.0)] [TestCase(3.5)] public void EntryPointL_EntryPointEqualOrGreaterThanExitPoint_ThrowsArgumentOutOfRangeException(double value) @@ -253,20 +265,6 @@ } [Test] - public void EntryPointL_Always_SameNumberOfDecimalsAsSurfaceLineLocalGeometry() - { - // Setup - PipingSurfaceLine surfaceLine = CreateSurfaceLine(); - var pipingInput = new PipingInput(new GeneralPipingInput()); - - // Call - RoundedPoint2DCollection localGeometry = surfaceLine.LocalGeometry; - - // Assert - Assert.AreEqual(localGeometry.NumberOfDecimalPlaces, pipingInput.EntryPointL.NumberOfDecimalPlaces); - } - - [Test] public void SurfaceLine_WithDikeToes_ExitPointLAndEntryPointLUpdated() { // Setup @@ -588,128 +586,23 @@ } [Test] - public void AssessmentLevel_UseAssessmentLevelManualInputIsFalse_ReturnsNaN() + public void AssessmentLevel_SetToNew_ValueIsRounded() { // Setup - var input = new PipingInput(new GeneralPipingInput()) - { - UseAssessmentLevelManualInput = false, - HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation() - }; - - // Call - RoundedDouble calculatedAssessmentLevel = input.AssessmentLevel; - - // Assert - Assert.IsNaN(calculatedAssessmentLevel); - } - - [Test] - public void AssessmentLevel_UseAssessmentLevelManualInputIsFalseWithHydraulicLocationSetAndDesignWaterLevelOutputSet_ReturnCalculatedAssessmentLevel() - { - // Setup + const double assessmentLevel = 1.111111; var input = new PipingInput(new GeneralPipingInput()); - HydraulicBoundaryLocation testHydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); - input.HydraulicBoundaryLocation = testHydraulicBoundaryLocation; + int originalNumberOfDecimalPlaces = input.AssessmentLevel.NumberOfDecimalPlaces; - double calculatedAssessmentLevel = new Random(21).NextDouble(); - testHydraulicBoundaryLocation.DesignWaterLevelCalculation1.Output = new TestHydraulicBoundaryLocationOutput(calculatedAssessmentLevel); - // Call - RoundedDouble newAssessmentLevel = input.AssessmentLevel; + input.AssessmentLevel = (RoundedDouble) assessmentLevel; // Assert - Assert.AreEqual(calculatedAssessmentLevel, newAssessmentLevel, input.AssessmentLevel.GetAccuracy()); + Assert.AreEqual(originalNumberOfDecimalPlaces, input.AssessmentLevel.NumberOfDecimalPlaces); + Assert.AreEqual(new RoundedDouble(originalNumberOfDecimalPlaces, assessmentLevel), input.AssessmentLevel); } [Test] - public void AssessmentLevel_UseAssessmentLevelManualInputFalseAndSettingValue_ThrowsInvalidOperationException() - { - // Setup - var input = new PipingInput(new GeneralPipingInput()) - { - UseAssessmentLevelManualInput = false - }; - - var testLevel = (RoundedDouble) new Random(21).NextDouble(); - - // Call - TestDelegate call = () => input.AssessmentLevel = testLevel; - - // Assert - string message = Assert.Throws(call).Message; - Assert.AreEqual("UseAssessmentLevelManualInput is false", message); - } - - [Test] - public void AssessmentLevel_UseAssessmentLevelManualInputTrueAndSettingValue_ReturnSetValue() - { - // Setup - var input = new PipingInput(new GeneralPipingInput()) - { - UseAssessmentLevelManualInput = true - }; - - var testLevel = (RoundedDouble) new Random(21).NextDouble(); - - // Call - input.AssessmentLevel = testLevel; - - // Assert - Assert.AreEqual(2, input.AssessmentLevel.NumberOfDecimalPlaces); - Assert.AreEqual(testLevel, input.AssessmentLevel, input.AssessmentLevel.GetAccuracy()); - } - - [Test] - public void GivenAssessmentLevelSetByHydraulicBoundaryLocation_WhenManualAssessmentLevelTrueAndNewLevelSet_ThenLevelUpdatedAndLocationRemoved() - { - // Given - var random = new Random(21); - var testLevel = (RoundedDouble) random.NextDouble(); - var input = new PipingInput(new GeneralPipingInput()) - { - HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(testLevel) - }; - - var newLevel = (RoundedDouble) random.NextDouble(); - - // When - input.UseAssessmentLevelManualInput = true; - input.AssessmentLevel = newLevel; - - // Then - Assert.AreEqual(2, input.AssessmentLevel.NumberOfDecimalPlaces); - Assert.AreEqual(newLevel, input.AssessmentLevel, input.AssessmentLevel.GetAccuracy()); - Assert.IsNull(input.HydraulicBoundaryLocation); - } - - [Test] - public void GivenAssessmentLevelSetByManualInput_WhenManualAssessmentLevelFalseAndHydraulicBoundaryLocationSet_ThenAssessmentLevelUpdatedAndLocationSet() - { - // Given - var random = new Random(21); - var testLevel = (RoundedDouble) random.NextDouble(); - var input = new PipingInput(new GeneralPipingInput()) - { - UseAssessmentLevelManualInput = true, - AssessmentLevel = testLevel - }; - - var newLevel = (RoundedDouble) random.NextDouble(); - TestHydraulicBoundaryLocation hydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(newLevel); - - // When - input.UseAssessmentLevelManualInput = false; - input.HydraulicBoundaryLocation = hydraulicBoundaryLocation; - - // Then - Assert.AreEqual(2, input.AssessmentLevel.NumberOfDecimalPlaces); - Assert.AreSame(hydraulicBoundaryLocation, input.HydraulicBoundaryLocation); - Assert.AreEqual(newLevel, input.AssessmentLevel, input.AssessmentLevel.GetAccuracy()); - } - - [Test] public void Clone_AllPropertiesSet_ReturnNewInstanceWithCopiedValues() { // Setup Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs =================================================================== diff -u -r6b60edb4d7f04f83c74089d70a72c4f79ed413dd -r7927641f2d9d74e77740f88c794fbcfd03a250dc --- Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs (.../PipingTestDataGenerator.cs) (revision 6b60edb4d7f04f83c74089d70a72c4f79ed413dd) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.TestUtil/PipingTestDataGenerator.cs (.../PipingTestDataGenerator.cs) (revision 7927641f2d9d74e77740f88c794fbcfd03a250dc) @@ -424,7 +424,7 @@ input.StochasticSoilProfile = new PipingStochasticSoilProfile(random.NextDouble(), PipingSoilProfileTestFactory.CreatePipingSoilProfile()); input.HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); - input.UseAssessmentLevelManualInput = true; + input.UseAssessmentLevelManualInput = random.NextBoolean(); input.AssessmentLevel = random.NextRoundedDouble(); input.PhreaticLevelExit = new NormalDistribution {