Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs =================================================================== diff -u -r1e8709c1680d46658119abf78016bc5d38886cc8 -r3a525b70c20312822d099cd69e89cb7f8bfd22ce --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs) (revision 1e8709c1680d46658119abf78016bc5d38886cc8) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationServiceIntegrationTest.cs) (revision 3a525b70c20312822d099cd69e89cb7f8bfd22ce) @@ -154,6 +154,7 @@ [Test] [TestCase(double.NaN)] [TestCase(double.NegativeInfinity)] + [TestCase(double.PositiveInfinity)] public void Validate_ValidInputAndValidateBreakWaterHeight_ReturnsFalse(double breakWaterHeight) { // Setup @@ -186,6 +187,7 @@ [TestCase(true, 10.0)] [TestCase(false, 10.0)] [TestCase(false, double.NaN)] + [TestCase(false, double.PositiveInfinity)] [TestCase(false, double.NegativeInfinity)] public void Validate_ValidInputAndValidateBreakWaterHeight_ReturnsTrue(bool useBreakWater, double breakWaterHeight) { Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -r1e8709c1680d46658119abf78016bc5d38886cc8 -r3a525b70c20312822d099cd69e89cb7f8bfd22ce --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs) (revision 1e8709c1680d46658119abf78016bc5d38886cc8) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs) (revision 3a525b70c20312822d099cd69e89cb7f8bfd22ce) @@ -282,6 +282,7 @@ } [Test] + [TestCase(double.PositiveInfinity)] [TestCase(double.NegativeInfinity)] [TestCase(double.NaN)] public void OnRun_CalculationWithForeshoreAndDoesNotUseBreakWaterAndHasInvalidBreakWaterHeight_PerformCalculationAndLogStartEnd(double breakWaterHeight) @@ -332,6 +333,7 @@ } [Test] + [TestCase(double.PositiveInfinity)] [TestCase(double.NegativeInfinity)] [TestCase(double.NaN)] public void OnRun_CalculationWithForeshoreAndUsesBreakWaterAndHasInvalidBreakWaterHeight_DoesNotPerformCalculationAndLogStartEnd(double breakWaterHeight) @@ -386,6 +388,7 @@ case CalculationType.NoForeshore: calculation.InputParameters.ForeshoreProfile = null; calculation.InputParameters.UseForeshore = false; + calculation.InputParameters.UseBreakWater = false; break; case CalculationType.ForeShoreWithoutBreakWater: calculation.InputParameters.ForeshoreProfile = CreateForeshoreProfile(null); Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceTest.cs =================================================================== diff -u -r4c15716555ea6ca122c2c9149d3703f956e3f529 -r3a525b70c20312822d099cd69e89cb7f8bfd22ce --- Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceTest.cs (.../WaveConditionsCalculationServiceTest.cs) (revision 4c15716555ea6ca122c2c9149d3703f956e3f529) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceTest.cs (.../WaveConditionsCalculationServiceTest.cs) (revision 3a525b70c20312822d099cd69e89cb7f8bfd22ce) @@ -203,6 +203,7 @@ [Test] [TestCase(double.NaN)] [TestCase(double.PositiveInfinity)] + [TestCase(double.NegativeInfinity)] public void Validate_ForeShoreProfileDoesNotUseBreakWaterAndHasInvalidBreakwaterHeight_ReturnsTrueAndLogsValidationMessages(double breakWaterHeight) { // Setup @@ -214,21 +215,9 @@ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") }; - var input = new WaveConditionsInput(WaveConditionsRevetment.StabilityStone) - { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) - { - DesignWaterLevel = (RoundedDouble) 12.0 - }, - ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, breakWaterHeight)), - UseBreakWater = false, - UseForeshore = true, - LowerBoundaryRevetment = (RoundedDouble) 1.0, - UpperBoundaryRevetment = (RoundedDouble) 10.0, - StepSize = WaveConditionsInputStepSize.One, - LowerBoundaryWaterLevels = (RoundedDouble) 1.0, - UpperBoundaryWaterLevels = (RoundedDouble) 10.0 - }; + WaveConditionsInput input = GetDefaultValidationInput(); + input.ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Wall, breakWaterHeight)); + input.UseBreakWater = false; // Call Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); @@ -248,6 +237,7 @@ [Test] [TestCase(double.NaN)] [TestCase(double.PositiveInfinity)] + [TestCase(double.NegativeInfinity)] public void Validate_ForeShoreProfileUseBreakWaterAndHasInvalidBreakWaterHeight_ReturnsFalseAndLogsValidationMessages(double breakWaterHeight) { // Setup @@ -259,21 +249,9 @@ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") }; - var input = new WaveConditionsInput(WaveConditionsRevetment.StabilityStone) - { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) - { - DesignWaterLevel = (RoundedDouble) 12.0 - }, - ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, breakWaterHeight)), - UseBreakWater = true, - UseForeshore = true, - LowerBoundaryRevetment = (RoundedDouble) 1.0, - UpperBoundaryRevetment = (RoundedDouble) 10.0, - StepSize = WaveConditionsInputStepSize.One, - LowerBoundaryWaterLevels = (RoundedDouble) 1.0, - UpperBoundaryWaterLevels = (RoundedDouble) 10.0 - }; + WaveConditionsInput input = GetDefaultValidationInput(); + input.ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, breakWaterHeight)); + input.UseBreakWater = true; // Call Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); @@ -292,7 +270,10 @@ } [Test] - public void Validate_AllInputConditionsSatisfiedWithoutForeshoreProfile_ReturnsTrueAndLogsValidationMessages() + [TestCase(CalculationType.NoForeshore)] + [TestCase(CalculationType.ForeShoreWithoutBreakWater)] + [TestCase(CalculationType.ForeshoreWithValidBreakWater)] + public void Validate_ValidInputValidateForeshoreProfile_ReturnsTrueAndLogsValidationMessages(CalculationType calculationType) { // Setup string name = "test"; @@ -303,63 +284,23 @@ FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") }; - var input = new WaveConditionsInput(WaveConditionsRevetment.StabilityStone) - { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) - { - DesignWaterLevel = (RoundedDouble) 12.0 - }, - UseForeshore = false, - LowerBoundaryRevetment = (RoundedDouble) 1.0, - UpperBoundaryRevetment = (RoundedDouble) 10.0, - StepSize = WaveConditionsInputStepSize.One, - LowerBoundaryWaterLevels = (RoundedDouble) 1.0, - UpperBoundaryWaterLevels = (RoundedDouble) 10.0 - }; + var input = GetDefaultValidationInput(); - // Call - Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); - - // Assert - TestHelper.AssertLogMessages(action, messages => + switch (calculationType) { - var msgs = messages.ToArray(); - Assert.AreEqual(2, msgs.Length); - StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", name), msgs[0]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beƫindigd om: ", name), msgs[1]); - }); + case CalculationType.NoForeshore: + input.ForeshoreProfile = null; + input.UseBreakWater = false; + input.UseForeshore = false; + break; + case CalculationType.ForeShoreWithoutBreakWater: + input.ForeshoreProfile = CreateForeshoreProfile(null); + input.UseBreakWater = false; + break; + case CalculationType.ForeshoreWithValidBreakWater: + break; + } - Assert.IsTrue(isValid); - } - - [Test] - public void Validate_AllInputConditionsSatisfiedWithForeshoreProfileAndUseBreakWater_ReturnsTrueAndLogsValidationMessages() - { - // Setup - string name = "test"; - bool isValid = false; - - HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() - { - FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") - }; - - var input = new WaveConditionsInput(WaveConditionsRevetment.StabilityStone) - { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) - { - DesignWaterLevel = (RoundedDouble) 12.0 - }, - ForeshoreProfile = CreateForeshoreProfile(), - UseBreakWater = true, - UseForeshore = true, - LowerBoundaryRevetment = (RoundedDouble) 1.0, - UpperBoundaryRevetment = (RoundedDouble) 10.0, - StepSize = WaveConditionsInputStepSize.One, - LowerBoundaryWaterLevels = (RoundedDouble) 1.0, - UpperBoundaryWaterLevels = (RoundedDouble) 10.0 - }; - // Call Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); @@ -376,49 +317,6 @@ } [Test] - public void Validate_AllInputConditionsSatisfiedWithForeshoreProfileWithoutBreakWater_ReturnsTrueAndLogsValidationMessages() - { - // Setup - string name = "test"; - bool isValid = false; - - HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() - { - FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") - }; - - var input = new WaveConditionsInput(WaveConditionsRevetment.StabilityStone) - { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) - { - DesignWaterLevel = (RoundedDouble) 12.0 - }, - ForeshoreProfile = CreateForeshoreProfile(null), - UseBreakWater = false, - UseForeshore = true, - LowerBoundaryRevetment = (RoundedDouble) 1.0, - UpperBoundaryRevetment = (RoundedDouble) 10.0, - StepSize = WaveConditionsInputStepSize.One, - LowerBoundaryWaterLevels = (RoundedDouble) 1.0, - UpperBoundaryWaterLevels = (RoundedDouble) 10.0 - }; - - // Call - Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); - - // Assert - TestHelper.AssertLogMessages(action, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(2, msgs.Length); - StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", name), msgs[0]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beƫindigd om: ", name), msgs[1]); - }); - - Assert.IsTrue(isValid); - } - - [Test] [Combinatorial] public void Calculate_Always_StartsCalculationWithRightParameters( [Values(true, false)] bool useForeshore, @@ -495,16 +393,36 @@ } } + public enum CalculationType + { + NoForeshore, + ForeshoreWithValidBreakWater, + ForeShoreWithoutBreakWater + } + + private static WaveConditionsInput GetDefaultValidationInput() + { + var input = new WaveConditionsInput(WaveConditionsRevetment.StabilityStone) + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = (RoundedDouble) 12.0 + }, + ForeshoreProfile = CreateForeshoreProfile(), + UseBreakWater = true, + UseForeshore = true, + LowerBoundaryRevetment = (RoundedDouble) 1.0, + UpperBoundaryRevetment = (RoundedDouble) 10.0, + StepSize = WaveConditionsInputStepSize.One, + LowerBoundaryWaterLevels = (RoundedDouble) 1.0, + UpperBoundaryWaterLevels = (RoundedDouble) 10.0 + }; + return input; + } + private static ForeshoreProfile CreateForeshoreProfile() { - return new ForeshoreProfile(new Point2D(0, 0), - new[] - { - new Point2D(2.2, 3.3), - new Point2D(4.4, 5.5) - }, - new BreakWater(BreakWaterType.Wall, 5.5), - new ForeshoreProfile.ConstructionProperties()); + return CreateForeshoreProfile(new BreakWater(BreakWaterType.Wall, 5.5)); } private static ForeshoreProfile CreateForeshoreProfile(BreakWater breakWater)