Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -rf1e93120b55e4ddbe23c8c28b0f36fa9d159502f -rcf5d53158510afca43ba9a7d2ac0893d3de29a76 --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision f1e93120b55e4ddbe23c8c28b0f36fa9d159502f) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision cf5d53158510afca43ba9a7d2ac0893d3de29a76) @@ -282,6 +282,121 @@ } [Test] + [TestCase(double.PositiveInfinity)] + [TestCase(double.NaN)] + public void OnRun_CalculationWithForeshoreAndDoesNotUseBreakWaterAndHasInvalidBreakWaterHeight_PerformCalculationAndLogStartEnd(double breakWaterHeight) + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = new StabilityStoneCoverWaveConditionsCalculation() + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), + ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, breakWaterHeight)), + UseForeshore = true, + UseBreakWater = false, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble)4, + UpperBoundaryRevetment = (RoundedDouble)10.0, + UpperBoundaryWaterLevels = (RoundedDouble)5.4, + LowerBoundaryWaterLevels = (RoundedDouble)5 + } + }; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble)12.0; + + var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.StabilityStoneCover, + assessmentSection); + + using (new HydraRingCalculationServiceConfig()) + { + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(16, msgs.Length); + + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]); + + int i = 2; + foreach (var waterLevel in calculation.InputParameters.WaterLevels) + { + StringAssert.StartsWith(string.Format("Blokken berekening '{0}' voor waterstand '{1}' gestart om: ", calculation.Name, waterLevel), msgs[i + 1]); + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' is niet gelukt.", calculation.Name, waterLevel), msgs[i + 2]); + StringAssert.StartsWith(string.Format("Blokken berekening '{0}' voor waterstand '{1}' beëindigd om: ", calculation.Name, waterLevel), msgs[i + 3]); + StringAssert.StartsWith(string.Format("Zuilen berekening '{0}' voor waterstand '{1}' gestart om: ", calculation.Name, waterLevel), msgs[i + 4]); + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' is niet gelukt.", calculation.Name, waterLevel), msgs[i + 5]); + StringAssert.StartsWith(string.Format("Zuilen berekening '{0}' voor waterstand '{1}' beëindigd om: ", calculation.Name, waterLevel), msgs[i + 6]); + + i = i + 6; + } + + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[15]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + } + + [Test] + [TestCase(double.PositiveInfinity)] + [TestCase(double.NaN)] + public void OnRun_CalculationWithForeshoreAndUsesBreakWaterAndHasInvalidBreakWaterHeight_DoesNotPerformCalculationAndLogStartEnd(double breakWaterHeight) + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), + ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, breakWaterHeight)), + UseForeshore = true, + UseBreakWater = true, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble)4, + UpperBoundaryRevetment = (RoundedDouble)10.0, + UpperBoundaryWaterLevels = (RoundedDouble)5.4, + LowerBoundaryWaterLevels = (RoundedDouble)5 + } + }; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble)12.0; + + var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.StabilityStoneCover, + assessmentSection); + + using (new HydraRingCalculationServiceConfig()) + { + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(3, msgs.Length); + + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + Assert.AreEqual("Validatie mislukt: Er is geen geldige damhoogte ingevoerd.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + } + + [Test] public void OnRun_CalculationWithWaterLevels_PerformCalculationAndLogStartAndEnd() { // Setup @@ -322,12 +437,75 @@ } [Test] - public void OnRun_CalculationWithValidInputConditionsCannotPerformCalculation_LogStartAndErrorAndEnd() + public void OnRun_CalculationWithValidInputConditionsAndWithoutBreakWaterCannotPerformCalculation_LogStartAndEnd() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); ImportHydraulicBoundaryDatabase(assessmentSection); + var calculation = new StabilityStoneCoverWaveConditionsCalculation() + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), + ForeshoreProfile = CreateForeshoreProfile(null), + UseForeshore = true, + UseBreakWater = false, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble)4, + UpperBoundaryRevetment = (RoundedDouble)10.0, + UpperBoundaryWaterLevels = (RoundedDouble)5.4, + LowerBoundaryWaterLevels = (RoundedDouble)5 + } + }; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble)12.0; + + var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.StabilityStoneCover, + assessmentSection); + + using (new HydraRingCalculationServiceConfig()) + { + // Call + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(16, msgs.Length); + + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[1]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[2]); + + int i = 2; + foreach (var waterLevel in calculation.InputParameters.WaterLevels) + { + StringAssert.StartsWith(string.Format("Blokken berekening '{0}' voor waterstand '{1}' gestart om: ", calculation.Name, waterLevel), msgs[i + 1]); + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' is niet gelukt.", calculation.Name, waterLevel), msgs[i + 2]); + StringAssert.StartsWith(string.Format("Blokken berekening '{0}' voor waterstand '{1}' beëindigd om: ", calculation.Name, waterLevel), msgs[i + 3]); + StringAssert.StartsWith(string.Format("Zuilen berekening '{0}' voor waterstand '{1}' gestart om: ", calculation.Name, waterLevel), msgs[i + 4]); + Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' is niet gelukt.", calculation.Name, waterLevel), msgs[i + 5]); + StringAssert.StartsWith(string.Format("Zuilen berekening '{0}' voor waterstand '{1}' beëindigd om: ", calculation.Name, waterLevel), msgs[i + 6]); + + i = i + 6; + } + + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[15]); + }); + Assert.AreEqual(ActivityState.Failed, activity.State); + } + } + + [Test] + public void OnRun_CalculationWithValidInputConditionsAndWithBreakWaterCannotPerformCalculation_LogStartAndErrorAndEnd() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection); var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, testDataPath, assessmentSection.StabilityStoneCover, assessmentSection); @@ -664,5 +842,17 @@ new BreakWater(BreakWaterType.Dam, 10.0), new ForeshoreProfile.ConstructionProperties()); } + + private static ForeshoreProfile CreateForeshoreProfile(BreakWater breakWater) + { + return new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + breakWater, + new ForeshoreProfile.ConstructionProperties()); + } } } \ No newline at end of file