Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.Designer.cs =================================================================== diff -u -rd41c64af372c44d81c66ed5bf25a9469816f3f48 -r8a04b4a13dcd6b3a78888b0305e239b2978c5dae --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d41c64af372c44d81c66ed5bf25a9469816f3f48) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8a04b4a13dcd6b3a78888b0305e239b2978c5dae) @@ -82,6 +82,15 @@ } /// + /// Looks up a localized string similar to Geen geldige damhoogte ingevoerd.. + /// + internal static string WaveConditionsCalculationService_ValidateInput_Invalid_BreakWaterHeight_value { + get { + return ResourceManager.GetString("WaveConditionsCalculationService_ValidateInput_Invalid_BreakWaterHeight_value", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Kan geen waterstanden afleiden op basis van de invoer. Controleer de opgegeven boven- en ondergrenzen.. /// internal static string WaveConditionsCalculationService_ValidateInput_No_derived_WaterLevels { Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.resx =================================================================== diff -u -rd41c64af372c44d81c66ed5bf25a9469816f3f48 -r8a04b4a13dcd6b3a78888b0305e239b2978c5dae --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.resx (.../Resources.resx) (revision d41c64af372c44d81c66ed5bf25a9469816f3f48) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/Properties/Resources.resx (.../Resources.resx) (revision 8a04b4a13dcd6b3a78888b0305e239b2978c5dae) @@ -129,4 +129,7 @@ Kan geen waterstanden afleiden op basis van de invoer. Controleer de opgegeven boven- en ondergrenzen. + + Er is geen geldige damhoogte ingevoerd. + \ No newline at end of file Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationService.cs =================================================================== diff -u -r500506841399316b5653e244102305664ba1b914 -r8a04b4a13dcd6b3a78888b0305e239b2978c5dae --- Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationService.cs (.../WaveConditionsCalculationService.cs) (revision 500506841399316b5653e244102305664ba1b914) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Service/WaveConditionsCalculationService.cs (.../WaveConditionsCalculationService.cs) (revision 8a04b4a13dcd6b3a78888b0305e239b2978c5dae) @@ -192,6 +192,14 @@ return Resources.WaveConditionsCalculationService_ValidateInput_No_derived_WaterLevels; } + if (input.UseBreakWater) + { + if (double.IsInfinity(input.BreakWater.Height) || double.IsNaN(input.BreakWater.Height)) + { + return Resources.WaveConditionsCalculationService_ValidateInput_Invalid_BreakWaterHeight_value; + } + } + return null; } } Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceTest.cs =================================================================== diff -u -r3b9088c00c08d2d55eeb857a6a21a4c43b90fd60 -r8a04b4a13dcd6b3a78888b0305e239b2978c5dae --- Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceTest.cs (.../WaveConditionsCalculationServiceTest.cs) (revision 3b9088c00c08d2d55eeb857a6a21a4c43b90fd60) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Service.Test/WaveConditionsCalculationServiceTest.cs (.../WaveConditionsCalculationServiceTest.cs) (revision 8a04b4a13dcd6b3a78888b0305e239b2978c5dae) @@ -87,7 +87,7 @@ var msgs = messages.ToArray(); Assert.AreEqual(3, msgs.Length); StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", name), msgs[0]); - StringAssert.StartsWith("Validatie mislukt: Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt", msgs[1]); + StringAssert.StartsWith("Validatie mislukt: Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", msgs[1]); StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); }); @@ -175,15 +175,15 @@ { HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) { - DesignWaterLevel = (RoundedDouble)designWaterLevel + DesignWaterLevel = (RoundedDouble) designWaterLevel }, - LowerBoundaryRevetment = (RoundedDouble)lowerBoundaryRevetments, - UpperBoundaryRevetment = (RoundedDouble)upperBoundaryRevetments, + LowerBoundaryRevetment = (RoundedDouble) lowerBoundaryRevetments, + UpperBoundaryRevetment = (RoundedDouble) upperBoundaryRevetments, StepSize = WaveConditionsInputStepSize.One, - LowerBoundaryWaterLevels = (RoundedDouble)1.0, - UpperBoundaryWaterLevels = (RoundedDouble)10.0 + LowerBoundaryWaterLevels = (RoundedDouble) 1.0, + UpperBoundaryWaterLevels = (RoundedDouble) 10.0 }; - + // Call Action action = () => isValid = WaveConditionsCalculationService.Instance.Validate(input, database, name); @@ -201,8 +201,114 @@ } [Test] - public void Validate_AllInputConditionsSatisfied_ReturnsTrueAndLogsValidationMessages() + [TestCase(double.NaN)] + [TestCase(double.PositiveInfinity)] + public void Validate_ForeShoreProfileDoesNotUseBreakWaterAndHasInvalidBreakwaterHeight_ReturnsTrueAndLogsValidationMessages(double breakWaterHeight) { + // Setup + string name = "test"; + bool isValid = false; + + HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + }; + + ForeshoreProfile foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + new BreakWater(BreakWaterType.Dam, breakWaterHeight), + new ForeshoreProfile.ConstructionProperties()); + + var input = new WaveConditionsInput + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = (RoundedDouble) 12.0 + }, + ForeshoreProfile = foreshoreProfile, + UseBreakWater = false, + 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] + [TestCase(double.NaN)] + [TestCase(double.PositiveInfinity)] + public void Validate_ForeShoreProfileUseBreakWaterAndHasInvalidBreakWaterHeight_ReturnsFalseAndLogsValidationMessages(double breakWaterHeight) + { + // Setup + string name = "test"; + bool isValid = false; + + HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + }; + + ForeshoreProfile foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + new BreakWater(BreakWaterType.Dam, breakWaterHeight), + new ForeshoreProfile.ConstructionProperties()); + + var input = new WaveConditionsInput + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = (RoundedDouble) 12.0 + }, + ForeshoreProfile = foreshoreProfile, + 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(3, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", name), msgs[0]); + StringAssert.StartsWith("Validatie mislukt: Er is geen geldige damhoogte ingevoerd.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", name), msgs[2]); + }); + + Assert.IsFalse(isValid); + } + + [Test] + public void Validate_AllInputConditionsSatisfiedWithoutForeshoreProfile_ReturnsTrueAndLogsValidationMessages() + { // Setup string name = "test"; bool isValid = false; @@ -216,13 +322,13 @@ { HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) { - DesignWaterLevel = (RoundedDouble)12.0 + DesignWaterLevel = (RoundedDouble) 12.0 }, - LowerBoundaryRevetment = (RoundedDouble)1.0, - UpperBoundaryRevetment = (RoundedDouble)10.0, + LowerBoundaryRevetment = (RoundedDouble) 1.0, + UpperBoundaryRevetment = (RoundedDouble) 10.0, StepSize = WaveConditionsInputStepSize.One, - LowerBoundaryWaterLevels = (RoundedDouble)1.0, - UpperBoundaryWaterLevels = (RoundedDouble)10.0 + LowerBoundaryWaterLevels = (RoundedDouble) 1.0, + UpperBoundaryWaterLevels = (RoundedDouble) 10.0 }; // Call @@ -241,6 +347,106 @@ } [Test] + public void Validate_AllInputConditionsSatisfiedWithBreakWater_ReturnsTrueAndLogsValidationMessages() + { + // Setup + string name = "test"; + bool isValid = false; + + HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + }; + + ForeshoreProfile foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + new BreakWater(BreakWaterType.Dam, 10.0), + new ForeshoreProfile.ConstructionProperties()); + + var input = new WaveConditionsInput + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = (RoundedDouble) 12.0 + }, + ForeshoreProfile = foreshoreProfile, + 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] + public void Validate_AllInputConditionsSatisfiedWithoutBreakWater_ReturnsTrueAndLogsValidationMessages() + { + // Setup + string name = "test"; + bool isValid = false; + + HydraulicBoundaryDatabase database = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "HRD ijsselmeer.sqlite") + }; + + ForeshoreProfile foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + null, + new ForeshoreProfile.ConstructionProperties()); + + var input = new WaveConditionsInput + { + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0) + { + DesignWaterLevel = (RoundedDouble) 12.0 + }, + ForeshoreProfile = foreshoreProfile, + 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, Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Integration.Test/WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -r0d43b27e8aa5f3bfa5224448946e0332d047b1e3 -r8a04b4a13dcd6b3a78888b0305e239b2978c5dae --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Integration.Test/WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision 0d43b27e8aa5f3bfa5224448946e0332d047b1e3) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Integration.Test/WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision 8a04b4a13dcd6b3a78888b0305e239b2978c5dae) @@ -32,6 +32,7 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.TestUtil; using Ringtoets.HydraRing.Calculation.TestUtil; +using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; using Ringtoets.Integration.Plugin.FileImporters; using Ringtoets.Revetment.Data; @@ -49,25 +50,161 @@ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); [Test] - public void OnRun_NoWaterLevels_LogStartAndEnd() + public void OnRun_NoHydraulicBoundaryDatabase_DoesNotPerformCalculationAndLogsError() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation() + { + InputParameters = + { + ForeshoreProfile = CreateForeshoreProfile(), + UseForeshore = true, + UseBreakWater = true, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble) 5.3, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 5.4, + LowerBoundaryWaterLevels = (RoundedDouble) 5 + } + }; + + var activity = new WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.WaveImpactAsphaltCover, + 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]); + StringAssert.StartsWith("Validatie mislukt: Er is geen hydraulische randvoorwaardendatabase geïmporteerd.", 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_InvalidHydraulicBoundaryDatabase_DoesNotPerformCalculationAndLogsError() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + assessmentSection.HydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + { + FilePath = Path.Combine(testDataPath, "NonExisting.sqlite") + }; + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = CreateForeshoreProfile(), + UseForeshore = true, + UseBreakWater = true, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble) 5.3, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 5.4, + LowerBoundaryWaterLevels = (RoundedDouble) 5 + } + }; + + var activity = new WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.WaveImpactAsphaltCover, + 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]); + StringAssert.StartsWith("Validatie mislukt: Herstellen van de verbinding met de hydraulische randvoorwaardendatabase is mislukt.", 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_NoHydraulicBoundaryLocation_DoesNotPerformCalculationAndLogsError() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); ImportHydraulicBoundaryDatabase(assessmentSection); var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation { InputParameters = { + ForeshoreProfile = CreateForeshoreProfile(), + UseForeshore = true, + UseBreakWater = true, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble) 5.3, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 5.4, + LowerBoundaryWaterLevels = (RoundedDouble) 5 + } + }; + + var activity = new WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.WaveImpactAsphaltCover, + 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]); + StringAssert.StartsWith("Validatie mislukt: Er is geen hydraulische randvoorwaardenlocatie geselecteerd.", 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_NoDesignWaterLevel_DoesNotPerformCalculationAndLogsError() + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), ForeshoreProfile = CreateForeshoreProfile(), UseForeshore = true, UseBreakWater = true, StepSize = WaveConditionsInputStepSize.Half, - LowerBoundaryRevetment = (RoundedDouble)5.3, - UpperBoundaryRevetment = (RoundedDouble)10, - UpperBoundaryWaterLevels = (RoundedDouble)5.4, - LowerBoundaryWaterLevels = (RoundedDouble)5 + LowerBoundaryRevetment = (RoundedDouble) 5.3, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 5.4, + LowerBoundaryWaterLevels = (RoundedDouble) 5 } }; @@ -76,24 +213,75 @@ assessmentSection.WaveImpactAsphaltCover, assessmentSection); - using (new WaveConditionsCalculationServiceConfig()) + using (new HydraRingCalculationServiceConfig()) { // Call + activity.Run(); Action call = () => activity.Run(); // Assert TestHelper.AssertLogMessages(call, messages => { var msgs = messages.ToArray(); - Assert.AreEqual(2, msgs.Length); - StringAssert.StartsWith(string.Format("Berekening van '{0}' gestart om: ", calculation.Name), msgs[0]); - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[1]); + Assert.AreEqual(3, msgs.Length); + StringAssert.StartsWith(string.Format("Validatie van '{0}' gestart om: ", calculation.Name), msgs[0]); + StringAssert.StartsWith("Validatie mislukt: Kan het toetspeil niet afleiden op basis van de invoer.", msgs[1]); + StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); }); Assert.AreEqual(ActivityState.Failed, activity.State); } } [Test] + [TestCase(double.NaN, 10.0)] + [TestCase(1.0, double.NaN)] + public void OnRun_NoWaterLevels_DoesNotPerformCalculationAndLogsError(double lowerBoundaryRevetment, double upperBoundaryRevetment) + { + // Setup + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + ImportHydraulicBoundaryDatabase(assessmentSection); + + var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), + ForeshoreProfile = CreateForeshoreProfile(), + UseForeshore = true, + UseBreakWater = true, + StepSize = WaveConditionsInputStepSize.Half, + LowerBoundaryRevetment = (RoundedDouble) lowerBoundaryRevetment, + UpperBoundaryRevetment = (RoundedDouble) upperBoundaryRevetment, + UpperBoundaryWaterLevels = (RoundedDouble) 5.4, + LowerBoundaryWaterLevels = (RoundedDouble) 5 + } + }; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 12.0; + + var activity = new WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, + testDataPath, + assessmentSection.WaveImpactAsphaltCover, + 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]); + StringAssert.StartsWith("Validatie mislukt: Kan geen waterstanden afleiden op basis van de invoer. Controleer de opgegeven boven- en ondergrenzen.", 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 @@ -134,7 +322,7 @@ } [Test] - public void OnRun_CalculationWithWaterLevelsCannotPerformCalculation_LogStartAndErrorAndEnd() + public void OnRun_CalculationWithValidInputConditionsCannotPerformCalculation_LogStartAndErrorAndEnd() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); @@ -226,7 +414,7 @@ using (new WaveConditionsCalculationServiceConfig()) { - var testService = (TestWaveConditionsCalculationService)WaveConditionsCalculationService.Instance; + var testService = (TestWaveConditionsCalculationService) WaveConditionsCalculationService.Instance; // Call activity.Run(); @@ -304,9 +492,9 @@ WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection); var activity = new WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, - testDataPath, - assessmentSection.WaveImpactAsphaltCover, - assessmentSection); + testDataPath, + assessmentSection.WaveImpactAsphaltCover, + assessmentSection); using (new WaveConditionsCalculationServiceConfig()) { @@ -393,13 +581,13 @@ UseForeshore = true, UseBreakWater = true, StepSize = WaveConditionsInputStepSize.Half, - LowerBoundaryRevetment = (RoundedDouble)4, - UpperBoundaryRevetment = (RoundedDouble)10, - UpperBoundaryWaterLevels = (RoundedDouble)8, - LowerBoundaryWaterLevels = (RoundedDouble)7.1 + LowerBoundaryRevetment = (RoundedDouble) 4, + UpperBoundaryRevetment = (RoundedDouble) 10, + UpperBoundaryWaterLevels = (RoundedDouble) 8, + LowerBoundaryWaterLevels = (RoundedDouble) 7.1 } }; - calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble)9.3; + calculation.InputParameters.HydraulicBoundaryLocation.DesignWaterLevel = (RoundedDouble) 9.3; return calculation; }