Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/LimitedPrecisionHelperTest.cs =================================================================== diff -u -rc196992ccccf32ce0fd55b83a17e3f3574467a1e -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/LimitedPrecisionHelperTest.cs (.../LimitedPrecisionHelperTest.cs) (revision c196992ccccf32ce0fd55b83a17e3f3574467a1e) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/LimitedPrecisionHelperTest.cs (.../LimitedPrecisionHelperTest.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -20,7 +20,9 @@ // All rights reserved. using System; +using System.Linq; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.Common.Data.Probabilistics; @@ -64,6 +66,22 @@ Assert.AreEqual(expectedPrecision, accuracy); } + [Test] + [TestCase(1)] + [TestCase(2)] + public void GetAccuracy_RoundedPoint2DCollection_ReturnsAccuracy(int precision) + { + // Setup + var roundedCollectoin = new RoundedPoint2DCollection(precision, Enumerable.Empty()); + + // Call + var accuracy = roundedCollectoin.GetAccuracy(); + + // Assert + var expectedPrecision = Math.Pow(10.0, -precision); + Assert.AreEqual(expectedPrecision, accuracy); + } + private class SimpleDistribution : IDistribution { public RoundedDouble Mean { get; set; } Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/LimitedPrecisionHelper.cs =================================================================== diff -u -rb65d24ff4389f2f38904cc15d791cf93dd358b6e -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/LimitedPrecisionHelper.cs (.../LimitedPrecisionHelper.cs) (revision b65d24ff4389f2f38904cc15d791cf93dd358b6e) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/LimitedPrecisionHelper.cs (.../LimitedPrecisionHelper.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -46,5 +46,13 @@ { return distribution.Mean.GetAccuracy(); } + + /// + /// Gets the accuracy for a . + /// + public static double GetAccuracy(this RoundedPoint2DCollection collection) + { + return Math.Pow(10.0, -collection.NumberOfDecimalPlaces); + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs =================================================================== diff -u -rc33fbb6a840ef596c665774b609f82b948f3b512 -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision c33fbb6a840ef596c665774b609f82b948f3b512) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/DerivedPipingInput.cs (.../DerivedPipingInput.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -134,7 +134,7 @@ StochasticSoilProfile stochasticSoilProfile = input.StochasticSoilProfile; RingtoetsPipingSurfaceLine surfaceLine = input.SurfaceLine; - double exitPointL = input.ExitPointL; + RoundedDouble exitPointL = input.ExitPointL; if (stochasticSoilProfile != null && stochasticSoilProfile.SoilProfile != null && surfaceLine != null && !double.IsNaN(exitPointL)) { @@ -162,7 +162,7 @@ } } - private static double GetThicknessTopAquiferLayer(PipingSoilProfile soilProfile, RingtoetsPipingSurfaceLine surfaceLine, double exitPointL) + private static double GetThicknessTopAquiferLayer(PipingSoilProfile soilProfile, RingtoetsPipingSurfaceLine surfaceLine, RoundedDouble exitPointL) { try { Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs =================================================================== diff -u -r06f68f0f847ca22a36b2b43b9c3cd82ebf60a629 -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision 06f68f0f847ca22a36b2b43b9c3cd82ebf60a629) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingInput.cs (.../PipingInput.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -91,8 +91,8 @@ /// /// Thrown when either: /// - /// is smaller or equal to . - /// is not on the . + /// is smaller or equal to . + /// does not fall within the local X-coordinate range of /// /// public RoundedDouble EntryPointL @@ -103,10 +103,15 @@ } set { - var newEntryPoint = value.ToPrecision(entryPointL.NumberOfDecimalPlaces); - ValidateEntryExitPoint(newEntryPoint, exitPointL); - ValidatePointOnSurfaceLine(newEntryPoint); - entryPointL = newEntryPoint; + var newEntryPointL = value.ToPrecision(entryPointL.NumberOfDecimalPlaces); + + if (!double.IsNaN(newEntryPointL) && !double.IsNaN(exitPointL)) + { + ValidateEntryExitPoint(newEntryPointL, exitPointL); + } + + ValidatePointOnSurfaceLine(newEntryPointL); + entryPointL = newEntryPointL; } } @@ -119,7 +124,7 @@ /// Thrown when either: /// /// is smaller or equal to . - /// is not on the . + /// does not fall within the local X-coordinate range of /// /// public RoundedDouble ExitPointL @@ -130,26 +135,31 @@ } set { - var newExitPoint = value.ToPrecision(exitPointL.NumberOfDecimalPlaces); - ValidateEntryExitPoint(entryPointL, newExitPoint); - ValidatePointOnSurfaceLine(newExitPoint); - exitPointL = newExitPoint; + var newExitPointL = value.ToPrecision(exitPointL.NumberOfDecimalPlaces); + + if (!double.IsNaN(entryPointL) && !double.IsNaN(newExitPointL)) + { + ValidateEntryExitPoint(entryPointL, newExitPointL); + } + + ValidatePointOnSurfaceLine(newExitPointL); + exitPointL = newExitPointL; } } - private void ValidateEntryExitPoint(RoundedDouble entryPoint, RoundedDouble exitPoint) + private void ValidateEntryExitPoint(RoundedDouble entryPointLocalXCoordinate, RoundedDouble exitPointLocalXCoordinate) { - if (!double.IsNaN(entryPoint) && !double.IsNaN(exitPoint) && entryPoint >= exitPoint) + if (entryPointLocalXCoordinate >= exitPointLocalXCoordinate) { throw new ArgumentOutOfRangeException(null, Resources.PipingInput_EntryPointL_greater_or_equal_to_ExitPointL); } } - private void ValidatePointOnSurfaceLine(RoundedDouble newPoint) + private void ValidatePointOnSurfaceLine(RoundedDouble newLocalXCoordinate) { if (surfaceLine != null) { - surfaceLine.ValidateInRange(newPoint, surfaceLine.ProjectGeometryToLZ().ToArray()); + surfaceLine.ValidateInRange(newLocalXCoordinate, surfaceLine.ProjectGeometryToLZ().ToArray()); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs =================================================================== diff -u -rfa851b16b32a7255c860355147a3ed4deaa10cef -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision fa851b16b32a7255c860355147a3ed4deaa10cef) +++ Ringtoets/Piping/src/Ringtoets.Piping.Primitives/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -36,6 +36,7 @@ /// public class RingtoetsPipingSurfaceLine : IStorable { + private const int numberOfDecimalPlaces = 2; private Point3D[] geometryPoints; /// @@ -246,7 +247,7 @@ /// intersection point at have a significant difference in their y coordinate. /// is not in range of the LZ-projected . /// is empty. - public double GetZAtL(double l) + public double GetZAtL(RoundedDouble l) { ValidateHasPoints(); @@ -281,7 +282,6 @@ /// Collection of 2D points in the LZ-plane. public RoundedPoint2DCollection ProjectGeometryToLZ() { - var numberOfDecimalPlaces = 2; var count = geometryPoints.Length; if (count == 0) { @@ -348,7 +348,7 @@ /// L-coordinate being monotonically non-decreasing /// falls outside the L-coordiante span /// defined by . - public void ValidateInRange(double localCoordinateL, Point2D[] geometryInLocalCoordinates) + public void ValidateInRange(RoundedDouble localCoordinateL, Point2D[] geometryInLocalCoordinates) { Point2D firstLocalPoint = geometryInLocalCoordinates.First(); Point2D lastLocalPoint = geometryInLocalCoordinates.Last(); Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs =================================================================== diff -u -rfa851b16b32a7255c860355147a3ed4deaa10cef -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision fa851b16b32a7255c860355147a3ed4deaa10cef) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingInputTest.cs (.../PipingInputTest.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -45,10 +45,10 @@ public void Constructor_ExpectedValues() { // Setup - var generalInputParameters = new GeneralPipingInput(); + GeneralPipingInput generalInputParameters = new GeneralPipingInput(); // Call - var inputParameters = new PipingInput(generalInputParameters); + PipingInput inputParameters = new PipingInput(generalInputParameters); // Assert Assert.IsInstanceOf(inputParameters); @@ -142,8 +142,6 @@ [Test] public void Constructor_GeneralPipingInputIsNull_ArgumentNullException() { - // Setup - // Call TestDelegate call = () => new PipingInput(null); @@ -152,14 +150,15 @@ } [Test] - public void ExitPointL_ExitPointSmallerThanEntryPoint_ThrowsArgumentOutOfRangeException() + [TestCase(1.23456)] + [TestCase(3.5)] + public void ExitPointL_ExitPointEqualSmallerThanEntryPoint_ThrowsArgumentOutOfRangeException(double value) { // Setup - var pipingInput = new PipingInput(new GeneralPipingInput()) + PipingInput pipingInput = new PipingInput(new GeneralPipingInput()) { EntryPointL = (RoundedDouble) 3.5 }; - const double value = 1.23456; // Call TestDelegate call = () => pipingInput.ExitPointL = (RoundedDouble)value; @@ -174,7 +173,7 @@ public void ExitPointL_Always_SameNumberOfDecimalsAsSurfaceLineLocalGeometry() { // Setup - var pipingInput = new PipingInput(new GeneralPipingInput()) + PipingInput pipingInput = new PipingInput(new GeneralPipingInput()) { SurfaceLine = CreateSurfaceLine() }; @@ -187,53 +186,55 @@ } [Test] - public void ExitPointL_ExitPointNotOnSurfaceLine_ThrowsArgumentOutOfRangeException() + [TestCase(5.4)] + [TestCase(1.006)] + [TestCase(-0.005)] + [TestCase(-5.4)] + public void ExitPointL_ExitPointNotOnSurfaceLine_ThrowsArgumentOutOfRangeException(double value) { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); - const double value = 5.4; + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + input.EntryPointL = (RoundedDouble) double.NaN; // Call TestDelegate call = () => input.ExitPointL = (RoundedDouble) value; // Assert - var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [{0}, {1}] liggen.", - 0, 1); + var expectedMessage = "Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [0, 1] liggen."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); } [Test] [TestCase(double.NaN)] - [TestCase(1.0)] - public void ExitPointL_SetToNew_ValueIsRounded(double entryPointValue) + [TestCase(-1e-3, Description = "Valid ExitPointL due to rounding to 0.0")] + [TestCase(0.994)] + [TestCase(0.50)] + public void ExitPointL_SetToNew_ValueIsRounded(double exitPointValue) { // Setup - var pipingInput = new PipingInput(new GeneralPipingInput()) - { - SurfaceLine = CreateSurfaceLine(), - EntryPointL = (RoundedDouble) entryPointValue - }; + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + input.EntryPointL = (RoundedDouble) double.NaN; + + int originalNumberOfDecimalPlaces = input.ExitPointL.NumberOfDecimalPlaces; - const double value = 1.23456; - int originalNumberOfDecimalPlaces = pipingInput.ExitPointL.NumberOfDecimalPlaces; - // Call - pipingInput.ExitPointL = (RoundedDouble) value; + input.ExitPointL = (RoundedDouble) exitPointValue; // Assert - Assert.AreEqual(originalNumberOfDecimalPlaces, pipingInput.ExitPointL.NumberOfDecimalPlaces); - Assert.AreEqual(new RoundedDouble(originalNumberOfDecimalPlaces, value), pipingInput.ExitPointL); + Assert.AreEqual(originalNumberOfDecimalPlaces, input.ExitPointL.NumberOfDecimalPlaces); + Assert.AreEqual(new RoundedDouble(originalNumberOfDecimalPlaces, exitPointValue), input.ExitPointL); } [Test] - public void EntryPointL_EntryPointGreaterThanExitPoint_ThrowsArgumentOutOfRangeException() + [TestCase(5.0)] + [TestCase(3.5)] + public void EntryPointL_EntryPointEqualOrGreaterThanExitPoint_ThrowsArgumentOutOfRangeException(double value) { // Setup - var pipingInput = new PipingInput(new GeneralPipingInput()) + PipingInput pipingInput = new PipingInput(new GeneralPipingInput()) { ExitPointL = (RoundedDouble)3.5 }; - const double value = 5.0; // Call TestDelegate call = () => pipingInput.EntryPointL = (RoundedDouble)value; @@ -245,49 +246,54 @@ } [Test] - public void EntryPointL_EntryPointNotOnSurfaceLine_ThrowsArgumentOutOfRangeException() + [TestCase(5.4)] + [TestCase(1.006)] + [TestCase(-0.005)] + [TestCase(-5.4)] + public void EntryPointL_EntryPointNotOnSurfaceLine_ThrowsArgumentOutOfRangeException(double value) { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); - const double value = -3.0; - + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + input.ExitPointL = (RoundedDouble) double.NaN; // Call TestDelegate call = () => input.EntryPointL = (RoundedDouble)value; // Assert - var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [{0}, {1}] liggen.", - 0, 1); + var expectedMessage = "Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [0, 1] liggen."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); } [Test] + [TestCase(double.NaN)] [TestCase(-1e-3, Description = "Valid EntryPointL due to rounding to 0.0")] - [TestCase(1.23456789)] - public void EntryPointL_SetToNew_ValueIsRounded(double value) + [TestCase(0.005)] + [TestCase(0.994)] + [TestCase(0.50)] + public void EntryPointL_SetToNew_ValueIsRounded(double entryPointValue) { // Setup - var pipingInput = new PipingInput(new GeneralPipingInput()); - int originalNumberOfDecimalPlaces = pipingInput.EntryPointL.NumberOfDecimalPlaces; + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + input.ExitPointL = (RoundedDouble)double.NaN; + int originalNumberOfDecimalPlaces = input.EntryPointL.NumberOfDecimalPlaces; + // Call - pipingInput.EntryPointL = (RoundedDouble) value; + input.EntryPointL = (RoundedDouble) entryPointValue; // Assert - Assert.AreEqual(originalNumberOfDecimalPlaces, pipingInput.EntryPointL.NumberOfDecimalPlaces); - Assert.AreEqual(new RoundedDouble(originalNumberOfDecimalPlaces, value), pipingInput.EntryPointL); + Assert.AreEqual(originalNumberOfDecimalPlaces, input.EntryPointL.NumberOfDecimalPlaces); + Assert.AreEqual(new RoundedDouble(originalNumberOfDecimalPlaces, entryPointValue), input.EntryPointL); } [Test] public void EntryPointL_Always_SameNumberOfDecimalsAsSurfaceLineLocalGeometry() { // Setup - var pipingInput = new PipingInput(new GeneralPipingInput()) - { - SurfaceLine = CreateSurfaceLine() - }; + RingtoetsPipingSurfaceLine surfaceLine = CreateSurfaceLine(); + PipingInput pipingInput = new PipingInput(new GeneralPipingInput()); // Call - RoundedPoint2DCollection localGeometry = pipingInput.SurfaceLine.ProjectGeometryToLZ(); + RoundedPoint2DCollection localGeometry = surfaceLine.ProjectGeometryToLZ(); // Assert Assert.AreEqual(localGeometry.NumberOfDecimalPlaces, pipingInput.EntryPointL.NumberOfDecimalPlaces); @@ -297,9 +303,9 @@ public void SurfaceLine_WithDikeToes_ThenExitPointLAndEntryPointLUpdated() { // Given - var input = new PipingInput(new GeneralPipingInput()); + PipingInput input = new PipingInput(new GeneralPipingInput()); - var surfaceLine = new RingtoetsPipingSurfaceLine(); + RingtoetsPipingSurfaceLine surfaceLine = new RingtoetsPipingSurfaceLine(); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 0), @@ -321,10 +327,10 @@ public void PhreaticLevelExit_SetNewValue_UpdateMeanAndStandardDeviation() { // Setup - var inputs = new PipingInput(new GeneralPipingInput()); + PipingInput inputs = new PipingInput(new GeneralPipingInput()); NormalDistribution originalPhreaticLevelExit = inputs.PhreaticLevelExit; - var newValue = new NormalDistribution(5) + NormalDistribution newValue = new NormalDistribution(5) { Mean = (RoundedDouble) 1.23456, StandardDeviation = (RoundedDouble) 7.89123 @@ -346,10 +352,10 @@ public void DampingFactorExit_SetNewValue_UpdateMeanAndStandardDeviation() { // Setup - var inputs = new PipingInput(new GeneralPipingInput()); + PipingInput inputs = new PipingInput(new GeneralPipingInput()); LogNormalDistribution originalDampingFactorExit = inputs.DampingFactorExit; - var newValue = new LogNormalDistribution(5) + LogNormalDistribution newValue = new LogNormalDistribution(5) { Mean = (RoundedDouble) 4.56789, StandardDeviation = (RoundedDouble) 1.23456 @@ -371,10 +377,10 @@ public void SaturatedVolumicWeightOfCoverageLayer_SetNewValue_UpdateMeanAndStandardDeviation() { // Setup - var inputs = new PipingInput(new GeneralPipingInput()); + PipingInput inputs = new PipingInput(new GeneralPipingInput()); ShiftedLogNormalDistribution originalSaturatedVolumicWeightOfCoverageLayer = inputs.SaturatedVolumicWeightOfCoverageLayer; - var newValue = new ShiftedLogNormalDistribution(5) + ShiftedLogNormalDistribution newValue = new ShiftedLogNormalDistribution(5) { Mean = (RoundedDouble) 1.11111, StandardDeviation = (RoundedDouble) 2.22222, @@ -399,10 +405,10 @@ public void Diameter70_SetNewValue_UpdateMeanAndStandardDeviation() { // Setup - var inputs = new PipingInput(new GeneralPipingInput()); + PipingInput inputs = new PipingInput(new GeneralPipingInput()); LogNormalDistribution originalDiameter70 = inputs.Diameter70; - var newValue = new LogNormalDistribution(5) + LogNormalDistribution newValue = new LogNormalDistribution(5) { Mean = (RoundedDouble) 8.8888, StandardDeviation = (RoundedDouble) 9.14363 @@ -424,10 +430,10 @@ public void DarcyPermeability_SetNewValue_UpdateMeanAndStandardDeviation() { // Setup - var inputs = new PipingInput(new GeneralPipingInput()); + PipingInput inputs = new PipingInput(new GeneralPipingInput()); LogNormalDistribution originalDarcyPermeability = inputs.DarcyPermeability; - var newValue = new LogNormalDistribution(5) + LogNormalDistribution newValue = new LogNormalDistribution(5) { Mean = (RoundedDouble) 1.93753, StandardDeviation = (RoundedDouble) 859.49028 @@ -449,7 +455,7 @@ public void AssessmentLevel_InputHasNewHydraulicBoundaryLocationSet_AssessmentLevelUpdated() { // Setup - var input = new PipingInput(new GeneralPipingInput()); + PipingInput input = new PipingInput(new GeneralPipingInput()); double testLevel = new Random(21).NextDouble(); @@ -459,7 +465,7 @@ }; // Call - var calculatedAssesmentLevel = input.AssessmentLevel; + RoundedDouble calculatedAssesmentLevel = input.AssessmentLevel; // Assert Assert.AreEqual(new RoundedDouble(2, testLevel), calculatedAssesmentLevel); @@ -469,19 +475,19 @@ public void PiezometricHeadExit_ValidInput_SetsParametersForCalculatorAndReturnsPiezometricHead() { // Setup - var input = new PipingInput(new GeneralPipingInput()); + PipingInput input = new PipingInput(new GeneralPipingInput()); using (new PipingSubCalculatorFactoryConfig()) { // Call - var piezometricHead = input.PiezometricHeadExit; + RoundedDouble piezometricHead = input.PiezometricHeadExit; // Assert Assert.AreEqual(2, piezometricHead.NumberOfDecimalPlaces); Assert.IsFalse(double.IsNaN(piezometricHead)); - var factory = (TestPipingSubCalculatorFactory) PipingSubCalculatorFactory.Instance; - var piezometricHeadAtExitCalculator = factory.LastCreatedPiezometricHeadAtExitCalculator; + TestPipingSubCalculatorFactory factory = (TestPipingSubCalculatorFactory) PipingSubCalculatorFactory.Instance; + PiezoHeadCalculatorStub piezometricHeadAtExitCalculator = factory.LastCreatedPiezometricHeadAtExitCalculator; Assert.AreEqual(piezometricHeadAtExitCalculator.HRiver, input.AssessmentLevel, input.AssessmentLevel.GetAccuracy()); Assert.AreEqual(PipingSemiProbabilisticDesignValueFactory.GetPhreaticLevelExit(input).GetDesignValue(), piezometricHeadAtExitCalculator.PhiPolder, @@ -495,10 +501,10 @@ public void PiezometricHeadExit_InputWithAssessmentLevelMissing_PiezometricHeadSetToNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(1.0, 1.0); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(1.0, 1.0); // Call - var piezometricHead = input.PiezometricHeadExit; + RoundedDouble piezometricHead = input.PiezometricHeadExit; // Assert Assert.IsNaN(piezometricHead); @@ -508,10 +514,10 @@ public void ThicknessAquiferLayer_SoilProfileSingleAquiferAndCoverageUnderSurfaceLine_ReturnsThicknessAquiferLayer() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); // Call - var thicknessAquiferLayer = input.ThicknessAquiferLayer; + LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; // Assert Assert.AreEqual(1.0, thicknessAquiferLayer.Mean.Value); @@ -521,11 +527,11 @@ public void ThicknessAquiferLayer_InputWithoutSoilProfile_MeansSetToNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.StochasticSoilProfile = null; // Call - var thicknessAquiferLayer = input.ThicknessAquiferLayer; + LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; // Assert Assert.IsNaN(thicknessAquiferLayer.Mean); @@ -535,11 +541,11 @@ public void ThicknessCoverageLayer_InputWithoutSoilProfile_MeansSetToNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.StochasticSoilProfile = null; // Call - var thicknessCoverageLayer = input.ThicknessCoverageLayer; + LogNormalDistribution thicknessCoverageLayer = input.ThicknessCoverageLayer; // Assert Assert.IsNaN(thicknessCoverageLayer.Mean); @@ -549,7 +555,7 @@ public void ThicknessAquiferLayer_InputWithoutSurfaceLine_MeansSetToNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.SurfaceLine = null; // Call @@ -563,7 +569,7 @@ public void ThicknessCoverageLayer_InputWithoutSurfaceLine_MeansSetToNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.SurfaceLine = null; // Call @@ -579,7 +585,7 @@ public void ThicknessCoverageLayer_SoilProfileSingleAquiferAboveSurfaceLine_ThicknessCoverageLayerNaN(double deltaAboveSurfaceLine) { // Setup - var input = PipingCalculationFactory.CreateInputWithSingleAquiferLayerAboveSurfaceLine(deltaAboveSurfaceLine); + PipingInput input = PipingCalculationFactory.CreateInputWithSingleAquiferLayerAboveSurfaceLine(deltaAboveSurfaceLine); // Call LogNormalDistribution thicknessCoverageLayer = input.ThicknessCoverageLayer; @@ -594,7 +600,7 @@ public void ThicknessAquiferLayer_SoilProfileSingleAquiferAboveSurfaceLine_ThicknessCoverageLayerNaN(double deltaAboveSurfaceLine) { // Setup - var input = PipingCalculationFactory.CreateInputWithSingleAquiferLayerAboveSurfaceLine(deltaAboveSurfaceLine); + PipingInput input = PipingCalculationFactory.CreateInputWithSingleAquiferLayerAboveSurfaceLine(deltaAboveSurfaceLine); // Call LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; @@ -608,7 +614,7 @@ { // Setup double expectedThickness; - var input = PipingCalculationFactory.CreateInputWithMultipleAquiferLayersUnderSurfaceLine(out expectedThickness); + PipingInput input = PipingCalculationFactory.CreateInputWithMultipleAquiferLayersUnderSurfaceLine(out expectedThickness); // Call LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; @@ -621,7 +627,7 @@ public void ThicknessAquiferLayer_MeanSetExitPointSetToNaN_ThicknessAquiferLayerNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.ExitPointL = (RoundedDouble) double.NaN; // Call @@ -635,7 +641,7 @@ public void ThicknessCoverageLayer_MeanSetSoilProfileSetToNull_ThicknessCoverageLayerNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.ThicknessCoverageLayer.Mean = new RoundedDouble(2, new Random(21).NextDouble() + 1); input.StochasticSoilProfile = null; @@ -651,7 +657,7 @@ public void ThicknessCoverageLayer_ProfileWithoutAquiferLayer_ThicknessCoverageLayerNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new PipingSoilProfile(String.Empty, 0, new[] @@ -674,7 +680,7 @@ public void ThicknessAquiferLayer_ProfileWithoutAquiferLayer_ThicknessAquiferLayerNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new PipingSoilProfile(String.Empty, 0, new[] @@ -697,10 +703,10 @@ public void ThicknessAquiferLayer_SoilProfileSingleAquiferUnderSurfaceLine_ThicknessAquiferLayerMeanSet() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); // Call - var thicknessAquiferLayer = input.ThicknessAquiferLayer; + LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; // Assert Assert.AreEqual(1.0, thicknessAquiferLayer.Mean.Value); @@ -711,10 +717,10 @@ { // Setup double expectedThickness; - var input = PipingCalculationFactory.CreateInputWithMultipleAquiferLayersUnderSurfaceLine(out expectedThickness); + PipingInput input = PipingCalculationFactory.CreateInputWithMultipleAquiferLayersUnderSurfaceLine(out expectedThickness); // Call - var thicknessAquiferLayer = input.ThicknessAquiferLayer; + LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; // Assert Assert.AreEqual(expectedThickness, thicknessAquiferLayer.Mean, 1e-6); @@ -724,12 +730,12 @@ public void ThicknessAquiferLayer_MeanSetSoilProfileSetToNull_ThicknessAquiferLayerNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.StochasticSoilProfile = null; // Call - var thicknessAquiferLayer = input.ThicknessAquiferLayer; + LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; // Assert Assert.IsNaN(thicknessAquiferLayer.Mean); @@ -739,7 +745,7 @@ public void ThicknessAquiferLayer_InputResultsInZeroAquiferThickness_ThicknessAquiferLayerNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new PipingSoilProfile(String.Empty, 0, new[] @@ -766,7 +772,7 @@ public void ThicknessCoverageLayer_InputResultsInZeroCoverageThickness_ThicknessCoverageLayerNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new PipingSoilProfile(String.Empty, 0, new[] @@ -793,7 +799,7 @@ public void ThicknessAquiferLayer_SurfaceLineHalfWayProfileLayer_ThicknessSetToLayerHeightUnderSurfaceLine() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.StochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new PipingSoilProfile(String.Empty, 0, new[] @@ -810,7 +816,7 @@ }; // Call - var thicknessAquiferLayer = input.ThicknessAquiferLayer; + LogNormalDistribution thicknessAquiferLayer = input.ThicknessAquiferLayer; // Assert Assert.AreEqual(2.0, thicknessAquiferLayer.Mean.Value, 1e-6); @@ -820,10 +826,10 @@ public void SeepageLength_ValidData_ReturnsSeepageLength() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); // Call - var seepageLength = input.SeepageLength; + LogNormalDistribution seepageLength = input.SeepageLength; // Assert Assert.AreEqual(0.5, seepageLength.Mean.Value); @@ -834,11 +840,11 @@ public void SeepageLength_EntryPointNaN_SeepageLengthNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.EntryPointL = (RoundedDouble) double.NaN; // Call - var seepageLength = input.SeepageLength; + LogNormalDistribution seepageLength = input.SeepageLength; // Assert Assert.IsNaN(seepageLength.Mean); @@ -849,11 +855,11 @@ public void SeepageLength_ExitPointNaN_SeepageLengthNaN() { // Setup - var input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); + PipingInput input = PipingCalculationFactory.CreateInputWithAquiferAndCoverageLayer(); input.ExitPointL = (RoundedDouble) double.NaN; // Call - var seepageLength = input.SeepageLength; + LogNormalDistribution seepageLength = input.SeepageLength; // Assert Assert.IsNaN(seepageLength.Mean); @@ -867,7 +873,7 @@ private static RingtoetsPipingSurfaceLine CreateSurfaceLine() { - var surfaceLine = new RingtoetsPipingSurfaceLine(); + RingtoetsPipingSurfaceLine surfaceLine = new RingtoetsPipingSurfaceLine(); surfaceLine.SetGeometry(new[] { new Point3D(0, 0, 0), Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs =================================================================== diff -u -rfa851b16b32a7255c860355147a3ed4deaa10cef -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision fa851b16b32a7255c860355147a3ed4deaa10cef) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/RingtoetsPipingSurfaceLineTest.cs (.../RingtoetsPipingSurfaceLineTest.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -20,13 +20,13 @@ // All rights reserved. using System; -using System.Collections.Generic; using System.Linq; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Base.Storage; using Core.Common.TestUtil; using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; using Ringtoets.Piping.Data.Properties; using Ringtoets.Piping.Primitives; using Ringtoets.Piping.Primitives.Exceptions; @@ -192,7 +192,7 @@ secondCoordinateFactor*length, length }; - CollectionAssert.AreEqual(expectedCoordinatesX, actual.Select(p => p.X).ToArray(), new DoubleWithToleranceComparer(Math.Pow(10.0, -actual.NumberOfDecimalPlaces))); + CollectionAssert.AreEqual(expectedCoordinatesX, actual.Select(p => p.X).ToArray(), new DoubleWithToleranceComparer(actual.GetAccuracy())); CollectionAssert.AreEqual(surfaceLine.Points.Select(p => p.Z).ToArray(), actual.Select(p => p.Y).ToArray()); Assert.AreEqual(2, actual.NumberOfDecimalPlaces); } @@ -233,7 +233,7 @@ { // Setup var surfaceLine = new RingtoetsPipingSurfaceLine(); - var l = new Random(21).NextDouble(); + RoundedDouble l = (RoundedDouble) new Random(21).NextDouble(); // Call TestDelegate test = () => surfaceLine.GetZAtL(l); @@ -250,7 +250,7 @@ var testZ = new Random(22).NextDouble(); var surfaceLine = new RingtoetsPipingSurfaceLine(); - var l = 2.0; + RoundedDouble l = (RoundedDouble) 2.0; surfaceLine.SetGeometry(new[] { new Point3D(0.0, 0.0, 2.2), @@ -284,11 +284,11 @@ }); // Call - TestDelegate test = () => surfaceLine.GetZAtL(l); + TestDelegate test = () => surfaceLine.GetZAtL((RoundedDouble) l); // Assert - var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [{0}, {1}] liggen.", - 0, 3.1); + var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [0, {0}] liggen.", + 3.1); TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } @@ -299,7 +299,7 @@ var testZ = new Random(22).NextDouble(); var surfaceLine = new RingtoetsPipingSurfaceLine(); - var l = 2.0; + RoundedDouble l = (RoundedDouble) 2.0; surfaceLine.SetGeometry(new[] { new Point3D(0.0, 0.0, 2.2), @@ -629,7 +629,11 @@ } [Test] - public void ValidateInRange_PointNotInRange_ThrowsArgumentOutOfRangeException() + [TestCase(5.0)] + [TestCase(1.375)] + [TestCase(-0.005)] + [TestCase(-5)] + public void ValidateInRange_PointNotInRange_ThrowsArgumentOutOfRangeException(double invalidValue) { // Setup var testX = 1.0; @@ -640,15 +644,18 @@ CreateTestGeometry(testPoint, surfaceLine); // Call - TestDelegate call = () => surfaceLine.ValidateInRange(5.0, surfaceLine.ProjectGeometryToLZ().ToArray()); + TestDelegate call = () => surfaceLine.ValidateInRange((RoundedDouble) invalidValue, surfaceLine.ProjectGeometryToLZ().ToArray()); // Assert - var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [{0}, {1}] liggen.", 0, 1.37); + var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [0, {0}] liggen.", 1.37); TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); } [Test] - public void ValidateInRange_PointInRange_DoesNotThrow() + [TestCase(-0e-3)] + [TestCase(1.37)] + [TestCase(1.0)] + public void ValidateInRange_PointInRange_DoesNotThrow(double validValue) { // Setup var testX = 1.0; @@ -659,7 +666,7 @@ CreateTestGeometry(testPoint, surfaceLine); // Call - TestDelegate call = () => surfaceLine.ValidateInRange(1.12, surfaceLine.ProjectGeometryToLZ().ToArray()); + TestDelegate call = () => surfaceLine.ValidateInRange((RoundedDouble) validValue, surfaceLine.ProjectGeometryToLZ().ToArray()); // Assert Assert.DoesNotThrow(call); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs =================================================================== diff -u -re62502b93eb5144e00dcba97a69b6c6088b99656 -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision e62502b93eb5144e00dcba97a69b6c6088b99656) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -51,7 +51,7 @@ public void DefaultConstructor_ExpectedValues() { // Call - var properties = new PipingInputContextProperties(); + PipingInputContextProperties properties = new PipingInputContextProperties(); // Assert Assert.IsInstanceOf>(properties); @@ -68,8 +68,8 @@ var random = new Random(22); - var surfaceLine = ValidSurfaceLine(0.0, 4.0); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) + RingtoetsPipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + StochasticSoilProfile stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new PipingSoilProfile(String.Empty, random.NextDouble(), new[] { @@ -82,20 +82,20 @@ StochasticSoilModel stochasticSoilModel = new StochasticSoilModel(0, "StochasticSoilModelName", "StochasticSoilModelSegmentName"); stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); - var testHydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(0.0); + HydraulicBoundaryLocation testHydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(0.0); - var inputParameters = new PipingInput(new GeneralPipingInput()) + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()) { HydraulicBoundaryLocation = testHydraulicBoundaryLocation }; inputParameters.SurfaceLine = surfaceLine; inputParameters.StochasticSoilModel = stochasticSoilModel; inputParameters.StochasticSoilProfile = (stochasticSoilProfile); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -142,13 +142,13 @@ projectObserver.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()); + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()); inputParameters.Attach(projectObserver); - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -179,33 +179,33 @@ projectObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberProperties); mocks.ReplayAll(); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()) + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()) { InputParameters = { SurfaceLine = ValidSurfaceLine(0.0, 4.0) } }; - var failureMechanism = new PipingFailureMechanism(); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = calculationItem.InputParameters; + PipingInput inputParameters = calculationItem.InputParameters; inputParameters.Attach(projectObserver); Random random = new Random(22); double assessmentLevel = random.NextDouble(); - var dampingFactorExit = new LogNormalDistribution(3); - var phreaticLevelExit = new NormalDistribution(2); - var diameter70 = new LogNormalDistribution(2); - var darcyPermeability = new LogNormalDistribution(3); - var saturatedVolumicWeightOfCoverageLoayer = new ShiftedLogNormalDistribution(2); + LogNormalDistribution dampingFactorExit = new LogNormalDistribution(3); + NormalDistribution phreaticLevelExit = new NormalDistribution(2); + LogNormalDistribution diameter70 = new LogNormalDistribution(2); + LogNormalDistribution darcyPermeability = new LogNormalDistribution(3); + ShiftedLogNormalDistribution saturatedVolumicWeightOfCoverageLoayer = new ShiftedLogNormalDistribution(2); - var surfaceLine = ValidSurfaceLine(0.0, 4.0); + RingtoetsPipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); StochasticSoilModel stochasticSoilModel1 = ValidStochasticSoilModel(0.0, 4.0); StochasticSoilModel stochasticSoilModel2 = ValidStochasticSoilModel(0.0, 4.0); - var stochasticSoilProfile2 = stochasticSoilModel2.StochasticSoilProfiles.First(); + StochasticSoilProfile stochasticSoilProfile2 = stochasticSoilModel2.StochasticSoilProfiles.First(); stochasticSoilModel2.StochasticSoilProfiles.Add(new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 1234)); // Call @@ -285,17 +285,17 @@ inputObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberProperties); mocks.ReplayAll(); - var surfaceLine = ValidSurfaceLine(0.0, 4.0); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + RingtoetsPipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()) + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()) { SurfaceLine = surfaceLine }; inputParameters.Attach(inputObserver); - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -326,15 +326,15 @@ inputObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberProperties); mocks.ReplayAll(); - var surfaceLine = ValidSurfaceLine(0.0, 4.0); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + RingtoetsPipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()); + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()); inputParameters.SurfaceLine = surfaceLine; inputParameters.Attach(inputObserver); - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -365,14 +365,14 @@ var inputObserver = mocks.StrictMock(); mocks.ReplayAll(); - var surfaceLine = ValidSurfaceLine(0.0, 4.0); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + RingtoetsPipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()); + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()); inputParameters.SurfaceLine = surfaceLine; - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -382,8 +382,7 @@ assessmentSectionMock) }; - const double l = 2.0; - properties.EntryPointL = (RoundedDouble) l; + properties.EntryPointL = (RoundedDouble) 2.0; inputParameters.Attach(inputObserver); @@ -395,28 +394,28 @@ call, RingtoetsPipingDataResources.PipingInput_EntryPointL_greater_or_equal_to_ExitPointL); - mocks.VerifyAll(); + mocks.VerifyAll(); // No observer notified } [Test] [TestCase(2.0)] [TestCase(5.0)] - public void entryPointL_InvalidValue_ThrowsArgumentOutOfRangeException(double newEntryPoint) + public void EntryPointL_InvalidValue_ThrowsArgumentOutOfRangeException(double newEntryPoint) { // Setup var mocks = new MockRepository(); var assessmentSectionMock = mocks.StrictMock(); var inputObserver = mocks.StrictMock(); mocks.ReplayAll(); - var surfaceLine = ValidSurfaceLine(0.0, 4.0); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + RingtoetsPipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()); + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()); inputParameters.SurfaceLine = surfaceLine; - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -426,8 +425,7 @@ assessmentSectionMock) }; - const double l = 2.0; - properties.ExitPointL = (RoundedDouble) l; + properties.ExitPointL = (RoundedDouble) 2.0; inputParameters.Attach(inputObserver); @@ -439,26 +437,26 @@ call, RingtoetsPipingDataResources.PipingInput_EntryPointL_greater_or_equal_to_ExitPointL); - mocks.VerifyAll(); + mocks.VerifyAll(); // No observer notified } [Test] - public void entryPointL_NotOnSurfaceline_ThrowsArgumentOutOfRangeException() + public void EntryPointL_NotOnSurfaceline_ThrowsArgumentOutOfRangeException() { // Setup var mocks = new MockRepository(); var assessmentSectionMock = mocks.StrictMock(); var inputObserver = mocks.StrictMock(); mocks.ReplayAll(); - var surfaceLine = ValidSurfaceLine(0.0, 4.0); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + RingtoetsPipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()); + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()); inputParameters.SurfaceLine = surfaceLine; - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -468,36 +466,34 @@ assessmentSectionMock) }; - const double entryPoint = -15.0; - const double exitPoint = 2.0; - properties.ExitPointL = (RoundedDouble)exitPoint; + properties.ExitPointL = (RoundedDouble) 2.0; inputParameters.Attach(inputObserver); // Call - TestDelegate call = () => properties.EntryPointL = (RoundedDouble)entryPoint; + TestDelegate call = () => properties.EntryPointL = (RoundedDouble)(-15.0); // Assert var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [{0}, {1}] liggen.", 0, 4); TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - mocks.VerifyAll(); + mocks.VerifyAll(); // No observer notified } [Test] - public void exitPointL_NotOnSurfaceline_ThrowsArgumentOutOfRangeException() + public void ExitPointL_NotOnSurfaceline_ThrowsArgumentOutOfRangeException() { // Setup var mocks = new MockRepository(); var assessmentSectionMock = mocks.StrictMock(); var inputObserver = mocks.StrictMock(); mocks.ReplayAll(); - var surfaceLine = ValidSurfaceLine(0.0, 4.0); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + RingtoetsPipingSurfaceLine surfaceLine = ValidSurfaceLine(0.0, 4.0); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()); + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()); inputParameters.SurfaceLine = surfaceLine; var properties = new PipingInputContextProperties @@ -510,20 +506,18 @@ assessmentSectionMock) }; - const double entryPoint = 2.0; - const double exitPoint = 10.0; - properties.EntryPointL = (RoundedDouble) entryPoint; + properties.EntryPointL = (RoundedDouble) 2.0; inputParameters.Attach(inputObserver); // Call - TestDelegate call = () => properties.ExitPointL = (RoundedDouble) exitPoint; + TestDelegate call = () => properties.ExitPointL = (RoundedDouble) 10.0; // Assert var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [{0}, {1}] liggen.", 0, 4); TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - mocks.VerifyAll(); + mocks.VerifyAll(); // No observer notified } [Test] @@ -537,10 +531,10 @@ mocks.ReplayAll(); double assessmentLevel = new Random(21).NextDouble(); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()) + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()) { HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, String.Empty, 0.0, 0.0) { @@ -549,7 +543,7 @@ }; inputParameters.Attach(projectObserver); - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -560,7 +554,7 @@ }; string testName = "TestName"; - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, testName, 0, 0) + HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, testName, 0, 0) { DesignWaterLevel = double.NaN }; @@ -584,13 +578,13 @@ projectObserver.Expect(o => o.UpdateObserver()).Repeat.Times(1); mocks.ReplayAll(); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()); + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()); inputParameters.Attach(projectObserver); - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -601,7 +595,7 @@ }; double testLevel = new Random(21).NextDouble(); - var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0, 0) + HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, string.Empty, 0, 0) { DesignWaterLevel = testLevel }; @@ -623,17 +617,17 @@ var assessmentSectionMock = mocks.StrictMock(); mocks.ReplayAll(); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()) + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()) { InputParameters = { SurfaceLine = ValidSurfaceLine(0.0, 4.0) } }; - var failureMechanism = new PipingFailureMechanism(); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = calculationItem.InputParameters; - var properties = new PipingInputContextProperties + PipingInput inputParameters = calculationItem.InputParameters; + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -663,24 +657,24 @@ var assessmentSectionMock = mocks.StrictMock(); mocks.ReplayAll(); - var testSurfaceLine = ValidSurfaceLine(0, 2); - var stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) + RingtoetsPipingSurfaceLine testSurfaceLine = ValidSurfaceLine(0, 2); + StochasticSoilProfile stochasticSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new TestPipingSoilProfile() }; - var stochasticSoilModel = new StochasticSoilModel(0, "StochasticSoilModelName", "StochasticSoilModelSegmentName"); + StochasticSoilModel stochasticSoilModel = new StochasticSoilModel(0, "StochasticSoilModelName", "StochasticSoilModelSegmentName"); stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()) + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()) { SurfaceLine = testSurfaceLine, StochasticSoilModel = stochasticSoilModel, StochasticSoilProfile = stochasticSoilProfile }; - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -709,13 +703,13 @@ var assessmentSectionMock = mocks.StrictMock(); mocks.ReplayAll(); - var testPipingSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) + StochasticSoilProfile testPipingSoilProfile = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new TestPipingSoilProfile() }; - var stochasticSoilModel = new StochasticSoilModel(0, "StochasticSoilModelName", "StochasticSoilModelSegmentName"); + StochasticSoilModel stochasticSoilModel = new StochasticSoilModel(0, "StochasticSoilModelName", "StochasticSoilModelSegmentName"); stochasticSoilModel.StochasticSoilProfiles.Add(testPipingSoilProfile); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()) + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()) { InputParameters = { @@ -725,10 +719,10 @@ } }; - var inputParameters = calculationItem.InputParameters; - var failureMechanism = new PipingFailureMechanism(); + PipingInput inputParameters = calculationItem.InputParameters; + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -757,31 +751,31 @@ var assessmentSectionMock = mocks.StrictMock(); mocks.ReplayAll(); - var testSurfaceLine = ValidSurfaceLine(0, 2); - var stochasticSoilProfile1 = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) + RingtoetsPipingSurfaceLine testSurfaceLine = ValidSurfaceLine(0, 2); + StochasticSoilProfile stochasticSoilProfile1 = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new TestPipingSoilProfile() }; - var stochasticSoilModel1 = new StochasticSoilModel(0, "StochasticSoilModel1Name", "StochasticSoilModelSegment1Name"); + StochasticSoilModel stochasticSoilModel1 = new StochasticSoilModel(0, "StochasticSoilModel1Name", "StochasticSoilModelSegment1Name"); stochasticSoilModel1.StochasticSoilProfiles.Add(stochasticSoilProfile1); - var stochasticSoilProfile2 = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) + StochasticSoilProfile stochasticSoilProfile2 = new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 0) { SoilProfile = new TestPipingSoilProfile() }; - var stochasticSoilModel2 = new StochasticSoilModel(0, "StochasticSoilModel2Name", "StochasticSoilModelSegment2Name"); + StochasticSoilModel stochasticSoilModel2 = new StochasticSoilModel(0, "StochasticSoilModel2Name", "StochasticSoilModelSegment2Name"); stochasticSoilModel1.StochasticSoilProfiles.Add(stochasticSoilProfile2); - var inputParameters = new PipingInput(new GeneralPipingInput()) + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()) { SurfaceLine = testSurfaceLine, StochasticSoilModel = stochasticSoilModel1, StochasticSoilProfile = stochasticSoilProfile1 }; - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var properties = new PipingInputContextProperties + PipingInputContextProperties properties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -808,11 +802,11 @@ var typeDescriptorContextMock = mocks.StrictMock(); var assessmentSectionMock = mocks.StrictMock(); - var calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); - var failureMechanism = new PipingFailureMechanism(); + PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); + PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - var inputParameters = new PipingInput(new GeneralPipingInput()); - var contextProperties = new PipingInputContextProperties + PipingInput inputParameters = new PipingInput(new GeneralPipingInput()); + PipingInputContextProperties contextProperties = new PipingInputContextProperties { Data = new PipingInputContext(inputParameters, calculationItem, @@ -827,7 +821,7 @@ }; DesignVariable phreaticLevelExitProperty = contextProperties.PhreaticLevelExit; - var dynamicPropertyBag = new DynamicPropertyBag(contextProperties); + DynamicPropertyBag dynamicPropertyBag = new DynamicPropertyBag(contextProperties); typeDescriptorContextMock.Expect(tdc => tdc.Instance).Return(dynamicPropertyBag).Repeat.Twice(); typeDescriptorContextMock.Stub(tdc => tdc.PropertyDescriptor).Return(dynamicPropertyBag.GetProperties()["PhreaticLevelExit"]); mocks.ReplayAll(); @@ -845,7 +839,7 @@ private static StochasticSoilModel ValidStochasticSoilModel(double xMin, double xMax) { - var stochasticSoilModel = new StochasticSoilModel(0, "StochasticSoilModelName", "StochasticSoilModelSegmentName"); + StochasticSoilModel stochasticSoilModel = new StochasticSoilModel(0, "StochasticSoilModelName", "StochasticSoilModelSegmentName"); stochasticSoilModel.StochasticSoilProfiles.Add(new StochasticSoilProfile(0.0, SoilProfileType.SoilProfile1D, 1234) { SoilProfile = new TestPipingSoilProfile() @@ -857,7 +851,7 @@ private static RingtoetsPipingSurfaceLine ValidSurfaceLine(double xMin, double xMax) { - var surfaceLine = new RingtoetsPipingSurfaceLine(); + RingtoetsPipingSurfaceLine surfaceLine = new RingtoetsPipingSurfaceLine(); surfaceLine.SetGeometry(new[] { new Point3D(xMin, 0.0, 0.0), Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs =================================================================== diff -u -re62502b93eb5144e00dcba97a69b6c6088b99656 -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs (.../PipingCalculationRowTest.cs) (revision e62502b93eb5144e00dcba97a69b6c6088b99656) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs (.../PipingCalculationRowTest.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -315,7 +315,7 @@ TestHelper.AssertThrowsArgumentExceptionAndTestMessage( call, RingtoetsPipingDataResources.PipingInput_EntryPointL_greater_or_equal_to_ExitPointL); - mocks.VerifyAll(); + mocks.VerifyAll(); // No observer notified } [Test] @@ -339,7 +339,7 @@ // Assert var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [{0}, {1}] liggen.", 0, 1); TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - mocks.VerifyAll(); + mocks.VerifyAll(); // No observer notified } [Test] @@ -388,7 +388,7 @@ TestHelper.AssertThrowsArgumentExceptionAndTestMessage( call, RingtoetsPipingDataResources.PipingInput_EntryPointL_greater_or_equal_to_ExitPointL); - mocks.VerifyAll(); + mocks.VerifyAll(); // No observer notified } [Test] @@ -412,7 +412,7 @@ // Assert var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [{0}, {1}] liggen.", 0, 1); TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, expectedMessage); - mocks.VerifyAll(); + mocks.VerifyAll(); // No observer notified } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs =================================================================== diff -u -re62502b93eb5144e00dcba97a69b6c6088b99656 -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision e62502b93eb5144e00dcba97a69b6c6088b99656) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -816,26 +816,38 @@ Assert.IsFalse(button.Enabled); } - [TestCase(isRelevantColumnIndex, true, 1, 0)] - [TestCase(contributionColumnIndex, 30.0, 1, 0)] - [TestCase(nameColumnIndex, "New name", 1, 0)] - [TestCase(stochasticSoilProfilesColumnIndex, null, 0, 1)] - [TestCase(hydraulicBoundaryLocationsColumnIndex, null, 0, 1)] - [TestCase(dampingFactorExitMeanColumnIndex, 1.1, 0, 1)] - [TestCase(phreaticLevelExitMeanColumnIndex, 1.1, 0, 1)] - [TestCase(entryPointLColumnIndex, 1.1, 0, 1)] - [TestCase(exitPointLColumnIndex, 5.5, 0, 1)] - public void PipingCalculationsView_EditingPropertyViaDataGridView_ObserversCorrectlyNotified(int cellIndex, object newValue, int expectedPipingCalculationCounter, int expectedPipingCalculationInputCounter) + [TestCase(isRelevantColumnIndex, true, true, false)] + [TestCase(contributionColumnIndex, 30.0, true, false)] + [TestCase(nameColumnIndex, "New name", true, false)] + [TestCase(stochasticSoilProfilesColumnIndex, null, false, true)] + [TestCase(hydraulicBoundaryLocationsColumnIndex, null, false, true)] + [TestCase(dampingFactorExitMeanColumnIndex, 1.1, false, true)] + [TestCase(phreaticLevelExitMeanColumnIndex, 1.1, false, true)] + [TestCase(entryPointLColumnIndex, 1.1, false, true)] + [TestCase(exitPointLColumnIndex, 5.5, false, true)] + public void PipingCalculationsView_EditingPropertyViaDataGridView_ObserversCorrectlyNotified(int cellIndex, object newValue, bool expectPipingCalculationNotify, bool expectPipingCalculationInputNotify) { // Setup + var mocks = new MockRepository(); + var pipingCalculationObserver = mocks.StrictMock(); + var pipingCalculationInputObserver = mocks.StrictMock(); + + if (expectPipingCalculationNotify) + { + pipingCalculationObserver.Expect(o => o.UpdateObserver()); + } + + if (expectPipingCalculationInputNotify) + { + pipingCalculationInputObserver.Expect(o => o.UpdateObserver()); + } + + mocks.ReplayAll(); + var pipingCalculationView = ShowFullyConfiguredPipingCalculationsView(); var data = (CalculationGroup) pipingCalculationView.Data; var pipingCalculation = (PipingCalculationScenario) data.Children.First(); - var pipingCalculationCounter = 0; - var pipingCalculationInputCounter = 0; - var pipingCalculationObserver = new Observer(() => pipingCalculationCounter++); - var pipingCalculationInputObserver = new Observer(() => pipingCalculationInputCounter++); pipingCalculation.Attach(pipingCalculationObserver); pipingCalculation.InputParameters.Attach(pipingCalculationInputObserver); @@ -846,71 +858,70 @@ dataGridView.Rows[0].Cells[cellIndex].Value = newValue is double ? (RoundedDouble) (double) newValue : newValue; // Assert - Assert.AreEqual(expectedPipingCalculationCounter, pipingCalculationCounter); - Assert.AreEqual(expectedPipingCalculationInputCounter, pipingCalculationInputCounter); + mocks.VerifyAll(); } [Test] [TestCase(entryPointLColumnIndex, 6.6)] [TestCase(entryPointLColumnIndex, 4.44)] [TestCase(exitPointLColumnIndex, 2.22)] [TestCase(exitPointLColumnIndex, 1.1)] - public void PipingCalculationsView_InvalidEntryOrExitPoint_ShowsErrorTooltip(int cellIndex, object newValue) + public void PipingCalculationsView_InvalidEntryOrExitPoint_ShowsErrorTooltip(int cellIndex, double newValue) { // Setup + var mocks = new MockRepository(); + var pipingCalculationObserver = mocks.StrictMock(); + var pipingCalculationInputObserver = mocks.StrictMock(); + mocks.ReplayAll(); + var pipingCalculationView = ShowFullyConfiguredPipingCalculationsView(); var data = (CalculationGroup)pipingCalculationView.Data; var pipingCalculation = (PipingCalculationScenario)data.Children.First(); - var pipingCalculationCounter = 0; - var pipingCalculationInputCounter = 0; - var pipingCalculationObserver = new Observer(() => pipingCalculationCounter++); - var pipingCalculationInputObserver = new Observer(() => pipingCalculationInputCounter++); pipingCalculation.Attach(pipingCalculationObserver); pipingCalculation.InputParameters.Attach(pipingCalculationInputObserver); var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Call - dataGridView.Rows[0].Cells[cellIndex].Value = newValue is double ? (RoundedDouble)(double)newValue : newValue; + dataGridView.Rows[0].Cells[cellIndex].Value = (RoundedDouble) newValue; // Assert Assert.AreEqual(RingtoetsPipingDataResources.PipingInput_EntryPointL_greater_or_equal_to_ExitPointL, dataGridView.Rows[0].ErrorText); - Assert.AreEqual(0, pipingCalculationCounter); - Assert.AreEqual(0, pipingCalculationInputCounter); + mocks.VerifyAll(); // No observer notified } [Test] [TestCase(entryPointLColumnIndex, -0.1)] [TestCase(entryPointLColumnIndex, -1.0)] [TestCase(exitPointLColumnIndex, 10.1)] [TestCase(exitPointLColumnIndex, 11.0)] - public void PipingCalculationsView_EntryOrExitPointNotOnSurfaceLine_ShowsErrorToolTip(int cellIndex, object newValue) + public void PipingCalculationsView_EntryOrExitPointNotOnSurfaceLine_ShowsErrorToolTip(int cellIndex, double newValue) { // Setup + var mocks = new MockRepository(); + var pipingCalculationObserver = mocks.StrictMock(); + var pipingCalculationInputObserver = mocks.StrictMock(); + mocks.ReplayAll(); + var pipingCalculationView = ShowFullyConfiguredPipingCalculationsView(); var data = (CalculationGroup)pipingCalculationView.Data; var pipingCalculation = (PipingCalculationScenario)data.Children.First(); - var pipingCalculationCounter = 0; - var pipingCalculationInputCounter = 0; - var pipingCalculationObserver = new Observer(() => pipingCalculationCounter++); - var pipingCalculationInputObserver = new Observer(() => pipingCalculationInputCounter++); pipingCalculation.Attach(pipingCalculationObserver); pipingCalculation.InputParameters.Attach(pipingCalculationInputObserver); var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; // Call - dataGridView.Rows[0].Cells[cellIndex].Value = newValue is double ? (RoundedDouble)(double)newValue : newValue; + dataGridView.Rows[0].Cells[cellIndex].Value = (RoundedDouble)newValue; // Assert var expectedMessage = string.Format("Kan geen hoogte bepalen. De lokale coördinaat moet in het bereik [{0}, {1}] liggen.", 0, 10); Assert.AreEqual(expectedMessage, dataGridView.Rows[0].ErrorText); - Assert.AreEqual(0, pipingCalculationCounter); - Assert.AreEqual(0, pipingCalculationInputCounter); + mocks.VerifyAll(); // No observer notified } private const int isRelevantColumnIndex = 0; Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs =================================================================== diff -u -r7dd0e37f171e62ef092707ffbc63dd64f5e9b674 -r35db69dfe64b7e7deeaf9ef85d4df42ff6009b11 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision 7dd0e37f171e62ef092707ffbc63dd64f5e9b674) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingSurfaceLinesCsvImporterTest.cs (.../PipingSurfaceLinesCsvImporterTest.cs) (revision 35db69dfe64b7e7deeaf9ef85d4df42ff6009b11) @@ -1759,7 +1759,7 @@ Assert.AreEqual(8, firstSurfaceLine.Points.Length); Assert.AreEqual(427776.654093, firstSurfaceLine.StartingWorldPoint.Y); - mocks.VerifyAll(); + mocks.VerifyAll(); // No observer notified } private static void AssertAreEqualPoint2D(Point2D expectedPoint, Point2D actualPoint)