Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs =================================================================== diff -u -r440f228de8eb72ed5be40270b20a46113917333e -r2731ce4dea0447322aef9238f4ef33cffe864c9e --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs (.../ClosingStructuresCalculationActivityIntegrationTest.cs) (revision 440f228de8eb72ed5be40270b20a46113917333e) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Integration.Test/ClosingStructuresCalculationActivityIntegrationTest.cs (.../ClosingStructuresCalculationActivityIntegrationTest.cs) (revision 2731ce4dea0447322aef9238f4ef33cffe864c9e) @@ -23,7 +23,6 @@ using System.IO; using System.Linq; using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Base.Service; using Core.Common.TestUtil; @@ -48,7 +47,7 @@ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); [Test] - public void Run_ClosingStructuresCalculationInvalidHydraulicBoundaryDatabase_LogValidationStartAndEndWithError() + public void Run_ClosingStructuresCalculationInvalidInput_LogValidationStartAndEndWithError() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) @@ -86,52 +85,6 @@ } [Test] - public void Run_ClosingStructuresCalculationWithoutHydraulicBoundaryLocation_LogValidationStartAndEndWithError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - - var failureMechanism = new ClosingStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - - var calculation = new StructuresCalculation() - { - InputParameters = - { - Structure = new TestClosingStructure() - } - }; - calculation.InputParameters.DeviationWaveDirection = (RoundedDouble) 0; - calculation.InputParameters.FactorStormDurationOpenStructure = (RoundedDouble) 1.0; - - var activity = new ClosingStructuresCalculationActivity(calculation, "", failureMechanism, assessmentSection); - - // 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 Run_ValidClosingStructuresCalculation_PerformClosingStructuresValidationAndCalculationAndLogStartAndEnd() { // Setup @@ -264,7 +217,10 @@ var activity = new ClosingStructuresCalculationActivity(calculation, validFilePath, failureMechanism, assessmentSection); - activity.Run(); + using (new HydraRingCalculatorFactoryConfig()) + { + activity.Run(); + } // Call activity.Finish(); Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs =================================================================== diff -u -r3023413fe1c0f6dd469e8d16f3a6ebf25adac5da -r2731ce4dea0447322aef9238f4ef33cffe864c9e --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision 3023413fe1c0f6dd469e8d16f3a6ebf25adac5da) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Service/GrassCoverErosionInwardsCalculationService.cs (.../GrassCoverErosionInwardsCalculationService.cs) (revision 2731ce4dea0447322aef9238f4ef33cffe864c9e) @@ -271,45 +271,38 @@ { List validationResult = new List(); - if (assessmentSection.HydraulicBoundaryDatabase == null) + var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(assessmentSection.HydraulicBoundaryDatabase.FilePath); + if (!string.IsNullOrEmpty(validationProblem)) { - validationResult.Add(RingtoetsCommonServiceResources.CalculationService_ValidateInput_No_hydraulic_boundary_database_selected); + validationResult.Add(validationProblem); + return validationResult.ToArray(); } + + if (inputParameters.HydraulicBoundaryLocation == null) + { + validationResult.Add(RingtoetsCommonServiceResources.CalculationService_ValidateInput_No_hydraulic_boundary_location_selected); + } + + if (inputParameters.DikeProfile == null) + { + validationResult.Add(RingtoetsCommonServiceResources.CalculationService_ValidateInput_No_dike_profile_selected); + } else { - if (inputParameters.HydraulicBoundaryLocation == null) + if (double.IsNaN(inputParameters.Orientation)) { - validationResult.Add(RingtoetsCommonServiceResources.CalculationService_ValidateInput_No_hydraulic_boundary_location_selected); + string message = string.Format(RingtoetsCommonServiceResources.Validation_ValidateInput_No_value_entered_for_ParameterName_0_, + ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonForms.Orientation_DisplayName)); + validationResult.Add(message); } + } - var validationProblem = HydraulicDatabaseHelper.ValidatePathForCalculation(assessmentSection.HydraulicBoundaryDatabase.FilePath); - - if (!string.IsNullOrEmpty(validationProblem)) + if (inputParameters.UseBreakWater) + { + if (double.IsNaN(inputParameters.BreakWater.Height) || double.IsInfinity(inputParameters.BreakWater.Height)) { - validationResult.Add(validationProblem); + validationResult.Add(RingtoetsCommonServiceResources.Validation_Invalid_BreakWaterHeight_value); } - - if (inputParameters.DikeProfile == null) - { - validationResult.Add(RingtoetsCommonServiceResources.CalculationService_ValidateInput_No_dike_profile_selected); - } - else - { - if (double.IsNaN(inputParameters.Orientation)) - { - string message = string.Format(RingtoetsCommonServiceResources.Validation_ValidateInput_No_value_entered_for_ParameterName_0_, - ParameterNameExtractor.GetFromDisplayName(RingtoetsCommonForms.Orientation_DisplayName)); - validationResult.Add(message); - } - } - - if (inputParameters.UseBreakWater) - { - if (double.IsNaN(inputParameters.BreakWater.Height) || double.IsInfinity(inputParameters.BreakWater.Height)) - { - validationResult.Add(RingtoetsCommonServiceResources.Validation_Invalid_BreakWaterHeight_value); - } - } } return validationResult.ToArray(); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs =================================================================== diff -u -r7d4fdb527410c89577828ea5d84896945341bae8 -r2731ce4dea0447322aef9238f4ef33cffe864c9e --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision 7d4fdb527410c89577828ea5d84896945341bae8) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision 2731ce4dea0447322aef9238f4ef33cffe864c9e) @@ -23,7 +23,6 @@ using System.IO; using System.Linq; using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Base.Service; using Core.Common.TestUtil; @@ -36,7 +35,6 @@ using Ringtoets.Common.IO.FileImporters; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Service; -using Ringtoets.HydraRing.Calculation.Calculator.Factory; using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; @@ -49,39 +47,6 @@ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); [Test] - public void Run_InvalidGrassCoverErosionInwardsCalculationNoHydraulicBoundaryDatabase_LogValidationStartAndEndWithError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); - AddSectionToAssessmentSection(assessmentSection); - - var calculation = new GrassCoverErosionInwardsCalculation - { - InputParameters = - { - DikeProfile = CreateDikeProfile() - } - }; - - var activity = new GrassCoverErosionInwardsCalculationActivity(calculation, "", assessmentSection.GrassCoverErosionInwards, assessmentSection); - - // 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 Run_InvalidGrassCoverErosionInwardsCalculationInvalidHydraulicBoundaryDatabase_LogValidationStartAndEndWithError() { // Setup @@ -111,44 +76,9 @@ TestHelper.AssertLogMessages(call, messages => { var msgs = messages.ToArray(); - Assert.AreEqual(4, 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("Validatie mislukt: Fout bij het lezen van bestand", msgs[2]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[3]); - }); - Assert.AreEqual(ActivityState.Failed, activity.State); - } - - [Test] - public void Run_InvalidGrassCoverErosionInwardsCalculationNoDikeProfile_LogValidationStartAndEndWithError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); - AddSectionToAssessmentSection(assessmentSection); - - var calculation = new GrassCoverErosionInwardsCalculation - { - InputParameters = - { - HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), - Orientation = (RoundedDouble) 0 - } - }; - - var activity = new GrassCoverErosionInwardsCalculationActivity(calculation, testDataPath, assessmentSection.GrassCoverErosionInwards, assessmentSection); - - // 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 dijkprofiel geselecteerd.", msgs[1]); + StringAssert.StartsWith("Validatie mislukt: Fout bij het lezen van bestand", msgs[1]); StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); }); Assert.AreEqual(ActivityState.Failed, activity.State); @@ -174,20 +104,23 @@ var activity = new GrassCoverErosionInwardsCalculationActivity(calculation, testDataPath, assessmentSection.GrassCoverErosionInwards, assessmentSection); // Call - Action call = () => activity.Run(); - - // Assert - TestHelper.AssertLogMessages(call, messages => + using (new HydraRingCalculatorFactoryConfig()) { - var msgs = messages.ToArray(); - Assert.AreEqual(5, 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]); - StringAssert.StartsWith("Overloop berekeningsverslag. Klik op details voor meer informatie.", msgs[3]); - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[4]); - }); - Assert.AreEqual(ActivityState.Executed, activity.State); + Action call = () => activity.Run(); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + var msgs = messages.ToArray(); + Assert.AreEqual(5, 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]); + StringAssert.StartsWith("Overloop berekeningsverslag. Klik op details voor meer informatie.", msgs[3]); + StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[4]); + }); + Assert.AreEqual(ActivityState.Executed, activity.State); + } } [Test] Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -ra14d1309ecf82ff5b0385a2f6e3b2c4a216a4184 -r2731ce4dea0447322aef9238f4ef33cffe864c9e --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs) (revision a14d1309ecf82ff5b0385a2f6e3b2c4a216a4184) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Integration.Test/GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionOutwardsWaveConditionsCalculationActivityIntegrationTest.cs) (revision 2731ce4dea0447322aef9238f4ef33cffe864c9e) @@ -56,7 +56,7 @@ } [Test] - public void Run_NoHydraulicBoundaryDatabase_DoesNotPerformCalculationAndLogsError() + public void Run_CalculationWithInvalidInput_DoesNotPerformCalculationAndLogsError() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); @@ -100,346 +100,6 @@ } [Test] - public void Run_InvalidHydraulicBoundaryDatabase_DoesNotPerformCalculationAndLogsError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation - { - 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 testFilePath = Path.Combine(testDataPath, "corruptschema.sqlite"); - var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, - testFilePath, - assessmentSection.GrassCoverErosionOutwards, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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(string.Format("Validatie mislukt: Fout bij het lezen van bestand '{0}': Kon geen locaties verkrijgen van de database.", testFilePath), 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 Run_NoHydraulicBoundaryLocation_DoesNotPerformCalculationAndLogsError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); - - var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation - { - 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 GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.GrassCoverErosionOutwards, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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 Run_NoDesignWaterLevel_DoesNotPerformCalculationAndLogsError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); - - var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation - { - 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 - } - }; - - var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.GrassCoverErosionOutwards, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // Call - activity.Run(); - 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 de waterstand bij doorsnede-eis 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 Run_NoWaterLevels_DoesNotPerformCalculationAndLogsError(double lowerBoundaryRevetment, double upperBoundaryRevetment) - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); - - var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation - { - 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 GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.GrassCoverErosionOutwards, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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] - [TestCase(double.NegativeInfinity, TestName = "Run_CalculationForeshoreNoBWInvalidBWHeight_PerformAndLog(negativeInfinity)")] - [TestCase(double.PositiveInfinity, TestName = "Run_CalculationForeshoreNoBWInvalidBWHeight_PerformAndLog(positiveInfinity)")] - [TestCase(double.NaN, TestName = "Run_CalculationForeshoreNoBWInvalidBWHeight_PerformAndLog(NaN)")] - public void Run_CalculationWithForeshoreAndDoesNotUseBreakWaterAndHasInvalidBreakWaterHeight_PerformCalculationAndLogStartEnd(double breakWaterHeight) - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); - - GrassCoverErosionOutwardsWaveConditionsCalculation calculation = GetDefaultCalculation(assessmentSection); - calculation.InputParameters.ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, - breakWaterHeight)); - calculation.InputParameters.UseBreakWater = false; - - var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.GrassCoverErosionOutwards, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // Call - Action call = () => activity.Run(); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(10, 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) - { - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[i + 1]); - StringAssert.StartsWith("Golfcondities berekeningsverslag. Klik op details voor meer informatie.", msgs[i + 2]); - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[i + 3]); - - i = i + 3; - } - - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[9]); - }); - Assert.AreEqual(ActivityState.Executed, activity.State); - } - } - - [Test] - [TestCase(double.NegativeInfinity, TestName = "Run_CalculationWithForeshoreBWInvalidBWHeight_LogNotPerform(negativeInfinity)")] - [TestCase(double.PositiveInfinity, TestName = "Run_CalculationWithForeshoreBWInvalidBWHeight_LogNotPerform(positiveInfinity)")] - [TestCase(double.NaN, TestName = "Run_CalculationWithForeshoreBWInvalidBWHeight_LogNotPerform(NaN)")] - public void Run_CalculationWithForeshoreAndUsesBreakWaterAndHasInvalidBreakWaterHeight_DoesNotPerformCalculationAndLogStartEnd(double breakWaterHeight) - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); - - GrassCoverErosionOutwardsWaveConditionsCalculation calculation = GetDefaultCalculation(assessmentSection); - calculation.InputParameters.ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, - breakWaterHeight)); - calculation.InputParameters.UseBreakWater = true; - - var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.GrassCoverErosionOutwards, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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] - [TestCase(CalculationType.NoForeshore)] - [TestCase(CalculationType.ForeshoreWithoutBreakWater)] - [TestCase(CalculationType.ForeshoreWithValidBreakWater)] - public void Run_CalculationValidValidateForeshore_LogStartErrorEnd(CalculationType calculationType) - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); - - GrassCoverErosionOutwardsWaveConditionsCalculation calculation = GetDefaultCalculation(assessmentSection); - - switch (calculationType) - { - case CalculationType.NoForeshore: - calculation.InputParameters.ForeshoreProfile = null; - calculation.InputParameters.UseForeshore = false; - calculation.InputParameters.UseBreakWater = false; - calculation.InputParameters.Orientation = (RoundedDouble) 0; - break; - case CalculationType.ForeshoreWithoutBreakWater: - calculation.InputParameters.ForeshoreProfile = CreateForeshoreProfile(null); - calculation.InputParameters.UseBreakWater = false; - break; - case CalculationType.ForeshoreWithValidBreakWater: - break; - } - - var activity = new GrassCoverErosionOutwardsWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.GrassCoverErosionOutwards, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // Call - Action call = () => activity.Run(); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(10, 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) - { - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[i + 1]); - StringAssert.StartsWith("Golfcondities berekeningsverslag. Klik op details voor meer informatie.", msgs[i + 2]); - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[i + 3]); - - i = i + 3; - } - - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[9]); - }); - Assert.AreEqual(ActivityState.Executed, activity.State); - } - } - - [Test] public void Run_CalculationWithValidCalculation_PerformCalculationAndLogStartAndEnd() { // Setup @@ -659,13 +319,6 @@ Assert.IsNull(calculation.Output); } } - - public enum CalculationType - { - NoForeshore, - ForeshoreWithValidBreakWater, - ForeshoreWithoutBreakWater - } private static GrassCoverErosionOutwardsWaveConditionsCalculation GetValidCalculation(AssessmentSection assessmentSection) { @@ -688,15 +341,6 @@ return calculation; } - private static GrassCoverErosionOutwardsWaveConditionsCalculation GetDefaultCalculation(AssessmentSection assessmentSection) - { - GrassCoverErosionOutwardsWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection); - calculation.InputParameters.LowerBoundaryWaterLevels = (RoundedDouble) 5; - calculation.InputParameters.UpperBoundaryWaterLevels = (RoundedDouble) 5.4; - - return calculation; - } - private void ImportHydraulicBoundaryDatabase(AssessmentSection assessmentSection) { using (var importer = new HydraulicBoundaryDatabaseImporter()) @@ -707,18 +351,13 @@ private static ForeshoreProfile CreateForeshoreProfile() { - return CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, 10.0)); - } - - 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 BreakWater(BreakWaterType.Dam, 10.0), new ForeshoreProfile.ConstructionProperties()); } } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs =================================================================== diff -u -ra14d1309ecf82ff5b0385a2f6e3b2c4a216a4184 -r2731ce4dea0447322aef9238f4ef33cffe864c9e --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs (.../HeightStructuresCalculationActivityIntegrationTest.cs) (revision a14d1309ecf82ff5b0385a2f6e3b2c4a216a4184) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Integration.Test/HeightStructuresCalculationActivityIntegrationTest.cs (.../HeightStructuresCalculationActivityIntegrationTest.cs) (revision 2731ce4dea0447322aef9238f4ef33cffe864c9e) @@ -20,11 +20,9 @@ // All rights reserved. using System; -using System.Collections.Generic; using System.IO; using System.Linq; using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Base.Service; using Core.Common.TestUtil; @@ -49,7 +47,7 @@ private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); [Test] - public void Run_CalculationInvalidHydraulicBoundaryDatabase_LogValidationStartAndEndWithError() + public void Run_CalculationInvalidInput_LogValidationStartAndEndWithError() { // Setup var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) @@ -87,397 +85,6 @@ } [Test] - public void Run_CalculationWithoutHydraulicBoundaryLocation_LogValidationStartAndEndWithError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - - var calculation = new StructuresCalculation() - { - InputParameters = - { - Structure = new TestHeightStructure() - } - }; - calculation.InputParameters.DeviationWaveDirection = (RoundedDouble) 0; - - var activity = new HeightStructuresCalculationActivity(calculation, "", failureMechanism, assessmentSection); - - // 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 Run_CalculationWithoutStructure_LogValidationStartAndEndWithError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - - var calculation = new StructuresCalculation() - { - InputParameters = - { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1234, "location", 0, 0) - } - }; - - var activity = new HeightStructuresCalculationActivity(calculation, "", failureMechanism, assessmentSection); - - // 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 kunstwerk 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 Run_CalculationInValidDeviationWaveDirection_LogValidationStartAndEndWithError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - const string parameterName = "afwijking golfrichting"; - string expectedValidationMessage = string.Format("Validatie mislukt: Er is geen concreet getal ingevoerd voor '{0}'.", parameterName); - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - - var calculation = new TestHeightStructuresCalculation() - { - InputParameters = - { - HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), - Structure = new TestHeightStructure() - } - }; - calculation.InputParameters.DeviationWaveDirection = RoundedDouble.NaN; - - var activity = new HeightStructuresCalculationActivity(calculation, testDataPath, failureMechanism, assessmentSection); - - // 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(expectedValidationMessage, msgs[1]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); - }); - } - - [Test] - public void Run_CalculationInvalidStructureNormalOrientation_LogValidationStartAndEndWithError() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - string expectedValidationMessage = "Validatie mislukt: Er is geen concreet getal ingevoerd voor 'oriëntatie'"; - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - - var calculation = new TestHeightStructuresCalculation() - { - InputParameters = - { - HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), - Structure = new TestHeightStructure() - } - }; - calculation.InputParameters.StructureNormalOrientation = RoundedDouble.NaN; - - var activity = new HeightStructuresCalculationActivity(calculation, testDataPath, failureMechanism, assessmentSection); - // 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(expectedValidationMessage, msgs[1]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); - }); - } - - [Test] - [TestCaseSource("NormalDistributionsWithInvalidMean")] - public void Run_CalculationInvalidNormalDistributionMeans_LogValidationStartAndEndWithError(double meanOne, double meanTwo, double meanThree, string parameterName) - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - string expectedValidationMessage = string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een concreet getal zijn.", parameterName); - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - - var calculation = new TestHeightStructuresCalculation() - { - InputParameters = - { - HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), - Structure = new TestHeightStructure() - } - }; - - calculation.InputParameters.ModelFactorSuperCriticalFlow.Mean = (RoundedDouble) meanOne; - calculation.InputParameters.LevelCrestStructure.Mean = (RoundedDouble) meanTwo; - calculation.InputParameters.WidthFlowApertures.Mean = (RoundedDouble) meanThree; - - var activity = new HeightStructuresCalculationActivity(calculation, testDataPath, failureMechanism, assessmentSection); - - // 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(expectedValidationMessage, msgs[1]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); - }); - } - - [Test] - [TestCaseSource("LogNormalDistributionsWithInvalidMean")] - public void Run_CalculationInvalidLogNormalDistributionMeans_LogValidationStartAndEndWithError(double meanOne, double meanTwo, double meanThree, - double meanFour, double meanFive, string parameterName) - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - string expectedValidationMessage = string.Format("Validatie mislukt: De verwachtingswaarde voor '{0}' moet een positief getal zijn.", parameterName); - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - - var calculation = new TestHeightStructuresCalculation() - { - InputParameters = - { - HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), - Structure = new TestHeightStructure() - } - }; - calculation.InputParameters.StormDuration.Mean = (RoundedDouble) meanOne; - calculation.InputParameters.AllowedLevelIncreaseStorage.Mean = (RoundedDouble) meanTwo; - calculation.InputParameters.StorageStructureArea.Mean = (RoundedDouble) meanThree; - calculation.InputParameters.FlowWidthAtBottomProtection.Mean = (RoundedDouble) meanFour; - calculation.InputParameters.CriticalOvertoppingDischarge.Mean = (RoundedDouble) meanFive; - - var activity = new HeightStructuresCalculationActivity(calculation, testDataPath, failureMechanism, assessmentSection); - - // 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(expectedValidationMessage, msgs[1]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); - }); - } - - [Test] - [TestCaseSource("DistributionsWithInvalidDeviation")] - public void Run_CalculationDistributionInvalidStandardDeviation_LogStartAndEndAndError(double deviationOne, double deviationTwo, - double deviationThree, double deviationFour, string parameterName) - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - string expectedValidationMessage = string.Format("Validatie mislukt: De standaard afwijking voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterName); - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - - var calculation = new TestHeightStructuresCalculation() - { - InputParameters = - { - HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), - Structure = new TestHeightStructure() - } - }; - calculation.InputParameters.ModelFactorSuperCriticalFlow.StandardDeviation = (RoundedDouble) deviationOne; - calculation.InputParameters.LevelCrestStructure.StandardDeviation = (RoundedDouble) deviationTwo; - calculation.InputParameters.AllowedLevelIncreaseStorage.StandardDeviation = (RoundedDouble) deviationThree; - calculation.InputParameters.FlowWidthAtBottomProtection.StandardDeviation = (RoundedDouble) deviationFour; - - var activity = new HeightStructuresCalculationActivity(calculation, testDataPath, failureMechanism, assessmentSection); - - // 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(expectedValidationMessage, msgs[1]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); - }); - } - - [Test] - [TestCaseSource("DistributionsWithInvalidCoefficient")] - public void Run_CalculationDistributionInvalidVariationCoefficient_LogValidationStartAndEndWithError(double coefficientOne, double coefficientTwo, - double coefficientThree, double coefficientFour, string parameterName) - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - string expectedValidationMessage = string.Format("Validatie mislukt: De variatiecoëfficient voor '{0}' moet groter zijn dan of gelijk zijn aan 0.", parameterName); - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - - var failureMechanism = new HeightStructuresFailureMechanism(); - failureMechanism.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - - var calculation = new TestHeightStructuresCalculation() - { - InputParameters = - { - HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), - Structure = new TestHeightStructure() - } - }; - calculation.InputParameters.StormDuration.CoefficientOfVariation = (RoundedDouble) coefficientOne; - calculation.InputParameters.StorageStructureArea.CoefficientOfVariation = (RoundedDouble) coefficientTwo; - calculation.InputParameters.CriticalOvertoppingDischarge.CoefficientOfVariation = (RoundedDouble) coefficientThree; - calculation.InputParameters.WidthFlowApertures.CoefficientOfVariation = (RoundedDouble) coefficientFour; - - var activity = new HeightStructuresCalculationActivity(calculation, testDataPath, failureMechanism, assessmentSection); - - // 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(expectedValidationMessage, msgs[1]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); - }); - } - - [Test] public void Run_ValidCalculation_PerformHeightStructuresValidationAndCalculationAndLogStartAndEnd() { // Setup @@ -614,8 +221,11 @@ var activity = new HeightStructuresCalculationActivity(calculation, validFilePath, failureMechanism, assessmentSection); - activity.Run(); - + using (new HydraRingCalculatorFactoryConfig()) + { + activity.Run(); + } + // Call activity.Finish(); @@ -671,84 +281,5 @@ Assert.IsNull(calculation.Output); mocks.VerifyAll(); } - - #region Testcases - - private static IEnumerable NormalDistributionsWithInvalidMean - { - get - { - yield return new TestCaseData(double.NaN, 1, 2, "modelfactor overloopdebiet volkomen overlaat"); - yield return new TestCaseData(double.PositiveInfinity, 1, 2, "modelfactor overloopdebiet volkomen overlaat"); - yield return new TestCaseData(double.NegativeInfinity, 1, 2, "modelfactor overloopdebiet volkomen overlaat"); - - yield return new TestCaseData(1, double.NaN, 2, "kerende hoogte"); - yield return new TestCaseData(1, double.PositiveInfinity, 2, "kerende hoogte"); - yield return new TestCaseData(1, double.NegativeInfinity, 2, "kerende hoogte"); - - yield return new TestCaseData(1, 2, double.NaN, "breedte van doorstroomopening"); - yield return new TestCaseData(1, 2, double.PositiveInfinity, "breedte van doorstroomopening"); - yield return new TestCaseData(1, 2, double.NegativeInfinity, "breedte van doorstroomopening"); - } - } - - private static IEnumerable LogNormalDistributionsWithInvalidMean - { - get - { - yield return new TestCaseData(double.NaN, 1, 2, 3, 4, "stormduur"); - yield return new TestCaseData(double.PositiveInfinity, 1, 2, 3, 4, "stormduur"); - - yield return new TestCaseData(1, double.NaN, 2, 3, 4, "toegestane peilverhoging komberging"); - yield return new TestCaseData(1, double.PositiveInfinity, 2, 3, 4, "toegestane peilverhoging komberging"); - - yield return new TestCaseData(1, 2, double.NaN, 3, 4, "kombergend oppervlak"); - yield return new TestCaseData(1, 2, double.PositiveInfinity, 3, 4, "kombergend oppervlak"); - - yield return new TestCaseData(1, 2, 3, double.NaN, 4, "stroomvoerende breedte bodembescherming"); - yield return new TestCaseData(1, 2, 3, double.PositiveInfinity, 4, "stroomvoerende breedte bodembescherming"); - - yield return new TestCaseData(1, 2, 3, 4, double.NaN, "kritiek instromend debiet"); - yield return new TestCaseData(1, 2, 3, 4, double.PositiveInfinity, "kritiek instromend debiet"); - } - } - - private static IEnumerable DistributionsWithInvalidDeviation - { - get - { - yield return new TestCaseData(double.NaN, 1, 2, 3, "modelfactor overloopdebiet volkomen overlaat"); - yield return new TestCaseData(double.PositiveInfinity, 1, 2, 3, "modelfactor overloopdebiet volkomen overlaat"); - - yield return new TestCaseData(1, double.NaN, 2, 3, "kerende hoogte"); - yield return new TestCaseData(1, double.PositiveInfinity, 2, 3, "kerende hoogte"); - - yield return new TestCaseData(1, 2, double.NaN, 3, "toegestane peilverhoging komberging"); - yield return new TestCaseData(1, 2, double.PositiveInfinity, 3, "toegestane peilverhoging komberging"); - - yield return new TestCaseData(1, 2, 3, double.NaN, "stroomvoerende breedte bodembescherming"); - yield return new TestCaseData(1, 2, 3, double.PositiveInfinity, "stroomvoerende breedte bodembescherming"); - } - } - - private static IEnumerable DistributionsWithInvalidCoefficient - { - get - { - yield return new TestCaseData(double.NaN, 1, 2, 3, "stormduur"); - yield return new TestCaseData(double.PositiveInfinity, 1, 2, 3, "stormduur"); - - yield return new TestCaseData(1, double.NaN, 2, 3, "kombergend oppervlak"); - yield return new TestCaseData(1, double.PositiveInfinity, 2, 3, "kombergend oppervlak"); - - yield return new TestCaseData(1, 2, double.NaN, 3, "kritiek instromend debiet"); - yield return new TestCaseData(1, 2, double.PositiveInfinity, 3, "kritiek instromend debiet"); - - yield return new TestCaseData(1, 2, 3, double.NaN, "breedte van doorstroomopening"); - yield return new TestCaseData(1, 2, 3, double.PositiveInfinity, "breedte van doorstroomopening"); - } - } - - #endregion } } \ No newline at end of file Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -r7fa4481428458d47cc3ec2fe6e75b12a1c539c8d -r2731ce4dea0447322aef9238f4ef33cffe864c9e --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision 7fa4481428458d47cc3ec2fe6e75b12a1c539c8d) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Integration.Test/StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../StabilityStoneCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision 2731ce4dea0447322aef9238f4ef33cffe864c9e) @@ -56,7 +56,7 @@ } [Test] - public void Run_NoHydraulicBoundaryDatabase_DoesNotPerformCalculationAndLogsError() + public void Run_CalculationWithInvalidInput_DoesNotPerformCalculationAndLogsError() { // Setup var mockRepository = new MockRepository(); @@ -104,384 +104,6 @@ } [Test] - public void Run_InvalidHydraulicBoundaryDatabase_DoesNotPerformCalculationAndLogsError() - { - // Setup - var mockRepository = new MockRepository(); - StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism = new StabilityStoneCoverFailureMechanism(); - var calculation = new StabilityStoneCoverWaveConditionsCalculation - { - 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 testFilePath = Path.Combine(testDataPath, "corruptschema.sqlite"); - var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, - testFilePath, - stabilityStoneCoverFailureMechanism, - AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - stabilityStoneCoverFailureMechanism, mockRepository)); - mockRepository.ReplayAll(); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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(string.Format("Validatie mislukt: Fout bij het lezen van bestand '{0}': Kon geen locaties verkrijgen van de database.", testFilePath), msgs[1]); - StringAssert.StartsWith(string.Format("Validatie van '{0}' beëindigd om: ", calculation.Name), msgs[2]); - }); - Assert.AreEqual(ActivityState.Failed, activity.State); - } - mockRepository.VerifyAll(); - } - - [Test] - public void Run_NoHydraulicBoundaryLocation_DoesNotPerformCalculationAndLogsError() - { - // Setup - var mockRepository = new MockRepository(); - var calculation = new StabilityStoneCoverWaveConditionsCalculation - { - InputParameters = - { - ForeshoreProfile = CreateForeshoreProfile(), - UseForeshore = true, - UseBreakWater = true, - StepSize = WaveConditionsInputStepSize.Half, - LowerBoundaryRevetment = (RoundedDouble) 5.3, - UpperBoundaryRevetment = (RoundedDouble) 10, - UpperBoundaryWaterLevels = (RoundedDouble) 5.4, - LowerBoundaryWaterLevels = (RoundedDouble) 5 - } - }; - - StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism = new StabilityStoneCoverFailureMechanism(); - var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - stabilityStoneCoverFailureMechanism, - AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - stabilityStoneCoverFailureMechanism, mockRepository)); - mockRepository.ReplayAll(); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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); - } - mockRepository.VerifyAll(); - } - - [Test] - public void Run_NoDesignWaterLevel_DoesNotPerformCalculationAndLogsError() - { - // Setup - var mockRepository = new MockRepository(); - var calculation = new StabilityStoneCoverWaveConditionsCalculation - { - InputParameters = - { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(13001, string.Empty, 0, 0), - ForeshoreProfile = CreateForeshoreProfile(), - UseForeshore = true, - UseBreakWater = true, - StepSize = WaveConditionsInputStepSize.Half, - LowerBoundaryRevetment = (RoundedDouble) 5.3, - UpperBoundaryRevetment = (RoundedDouble) 10, - UpperBoundaryWaterLevels = (RoundedDouble) 5.4, - LowerBoundaryWaterLevels = (RoundedDouble) 5 - } - }; - - StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism = new StabilityStoneCoverFailureMechanism(); - var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - stabilityStoneCoverFailureMechanism, - AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - stabilityStoneCoverFailureMechanism, mockRepository)); - mockRepository.ReplayAll(); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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 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); - } - mockRepository.VerifyAll(); - } - - [Test] - [TestCase(double.NaN, 10.0)] - [TestCase(1.0, double.NaN)] - public void Run_NoWaterLevels_DoesNotPerformCalculationAndLogsError(double lowerBoundaryRevetment, double upperBoundaryRevetment) - { - // Setup - var mockRepository = new MockRepository(); - var calculation = new StabilityStoneCoverWaveConditionsCalculation - { - InputParameters = - { - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(13001, string.Empty, 0, 0) - { - DesignWaterLevel = (RoundedDouble) 12.0 - }, - ForeshoreProfile = CreateForeshoreProfile(), - UseForeshore = true, - UseBreakWater = true, - StepSize = WaveConditionsInputStepSize.Half, - LowerBoundaryRevetment = (RoundedDouble) lowerBoundaryRevetment, - UpperBoundaryRevetment = (RoundedDouble) upperBoundaryRevetment, - UpperBoundaryWaterLevels = (RoundedDouble) 5.4, - LowerBoundaryWaterLevels = (RoundedDouble) 5 - } - }; - - StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism = new StabilityStoneCoverFailureMechanism(); - var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - stabilityStoneCoverFailureMechanism, - AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - stabilityStoneCoverFailureMechanism, mockRepository)); - mockRepository.ReplayAll(); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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); - } - mockRepository.VerifyAll(); - } - - [Test] - [TestCase(double.NegativeInfinity, TestName = "Run_CalculationWithForeshoreNoBreakWaterInvalidBreakWaterHeight_PerformAndLog(negativeInfinity)")] - [TestCase(double.PositiveInfinity, TestName = "Run_CalculationWithForeshoreNoBreakWaterInvalidBreakWaterHeight_PerformAndLog(positiveInfinity)")] - [TestCase(double.NaN, TestName = "Run_CalculationWithForeshoreNoBreakWaterInvalidBreakWaterHeight_PerformAndLog(NaN)")] - public void Run_CalculationWithForeshoreAndDoesNotUseBreakWaterAndHasInvalidBreakWaterHeight_PerformCalculationAndLogStartAndEnd(double breakWaterHeight) - { - // Setup - var mockRepository = new MockRepository(); - StabilityStoneCoverWaveConditionsCalculation calculation = GetDefaultCalculation(); - calculation.InputParameters.ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, - breakWaterHeight)); - calculation.InputParameters.UseBreakWater = false; - - StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism = new StabilityStoneCoverFailureMechanism(); - var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - stabilityStoneCoverFailureMechanism, - AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - stabilityStoneCoverFailureMechanism, mockRepository)); - mockRepository.ReplayAll(); - - using (new HydraRingCalculatorFactoryConfig()) - { - // Call - Action call = () => activity.Run(); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(20, 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]); - - Assert.AreEqual(string.Format("Berekening '{0}' voor blokken gestart.", calculation.Name), msgs[3]); - - int i = 4; - foreach (var waterLevel in calculation.InputParameters.WaterLevels) - { - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[i++]); - StringAssert.StartsWith("Golfcondities berekeningsverslag. Klik op details voor meer informatie.", msgs[i++]); - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[i++]); - } - - Assert.AreEqual(string.Format("Berekening '{0}' voor blokken beëindigd.", calculation.Name), msgs[10]); - Assert.AreEqual(string.Format("Berekening '{0}' voor zuilen gestart.", calculation.Name), msgs[11]); - - i = 12; - foreach (var waterLevel in calculation.InputParameters.WaterLevels) - { - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[i++]); - StringAssert.StartsWith("Golfcondities berekeningsverslag. Klik op details voor meer informatie.", msgs[i++]); - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[i++]); - } - - Assert.AreEqual(string.Format("Berekening '{0}' voor zuilen beëindigd.", calculation.Name), msgs[18]); - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[19]); - }); - Assert.AreEqual(ActivityState.Executed, activity.State); - } - mockRepository.VerifyAll(); - } - - [Test] - [TestCase(double.NegativeInfinity, TestName = "Run_CalculationWithForeshoreAndBreakWaterInvalidBreakWaterHeight_LogNotPerform(negativeInfinity)")] - [TestCase(double.PositiveInfinity, TestName = "Run_CalculationWithForeshoreAndBreakWaterInvalidBreakWaterHeight_LogNotPerform(positiveInfinity)")] - [TestCase(double.NaN, TestName = "Run_CalculationWithForeshoreAndBreakWaterInvalidBreakWaterHeight_LogNotPerform(NaN)")] - public void Run_CalculationWithForeshoreAndUsesBreakWaterAndHasInvalidBreakWaterHeight_DoesNotPerformCalculationAndLogStartEnd(double breakWaterHeight) - { - // Setup - var mockRepository = new MockRepository(); - StabilityStoneCoverWaveConditionsCalculation calculation = GetDefaultCalculation(); - calculation.InputParameters.ForeshoreProfile = CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, - breakWaterHeight)); - calculation.InputParameters.UseBreakWater = true; - - StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism = new StabilityStoneCoverFailureMechanism(); - var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - stabilityStoneCoverFailureMechanism, - AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - stabilityStoneCoverFailureMechanism, mockRepository)); - mockRepository.ReplayAll(); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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); - } - mockRepository.VerifyAll(); - } - - [Test] - [TestCase(CalculationType.NoForeshore)] - [TestCase(CalculationType.ForeshoreWithoutBreakWater)] - [TestCase(CalculationType.ForeshoreWithValidBreakWater)] - public void Run_CalculationWithValidInputAndValidForeshore_LogStartAndEnd(CalculationType calculationType) - { - // Setup - var mockRepository = new MockRepository(); - StabilityStoneCoverWaveConditionsCalculation calculation = GetDefaultCalculation(); - StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism = new StabilityStoneCoverFailureMechanism(); - var activity = new StabilityStoneCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - stabilityStoneCoverFailureMechanism, - AssessmentSectionHelper.CreateAssessmentSectionStubWithoutBoundaryDatabase( - stabilityStoneCoverFailureMechanism, mockRepository)); - mockRepository.ReplayAll(); - - switch (calculationType) - { - case CalculationType.NoForeshore: - calculation.InputParameters.ForeshoreProfile = null; - calculation.InputParameters.UseForeshore = false; - calculation.InputParameters.UseBreakWater = false; - calculation.InputParameters.Orientation = (RoundedDouble) 0; - break; - case CalculationType.ForeshoreWithoutBreakWater: - calculation.InputParameters.ForeshoreProfile = CreateForeshoreProfile(null); - calculation.InputParameters.UseBreakWater = false; - break; - case CalculationType.ForeshoreWithValidBreakWater: - break; - } - - using (new HydraRingCalculatorFactoryConfig()) - { - // Call - Action call = () => activity.Run(); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(20, 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]); - - Assert.AreEqual(string.Format("Berekening '{0}' voor blokken gestart.", calculation.Name), msgs[3]); - - int i = 4; - foreach (var waterLevel in calculation.InputParameters.WaterLevels) - { - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[i++]); - StringAssert.StartsWith("Golfcondities berekeningsverslag. Klik op details voor meer informatie.", msgs[i++]); - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[i++]); - } - - Assert.AreEqual(string.Format("Berekening '{0}' voor blokken beëindigd.", calculation.Name), msgs[10]); - Assert.AreEqual(string.Format("Berekening '{0}' voor zuilen gestart.", calculation.Name), msgs[11]); - - i = 12; - foreach (var waterLevel in calculation.InputParameters.WaterLevels) - { - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[i++]); - StringAssert.StartsWith("Golfcondities berekeningsverslag. Klik op details voor meer informatie.", msgs[i++]); - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[i++]); - } - - Assert.AreEqual(string.Format("Berekening '{0}' voor zuilen beëindigd.", calculation.Name), msgs[18]); - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[19]); - }); - Assert.AreEqual(ActivityState.Executed, activity.State); - } - mockRepository.VerifyAll(); - } - - [Test] public void Run_Always_SetProgressTexts() { // Setup @@ -790,13 +412,6 @@ mockRepository.VerifyAll(); } - public enum CalculationType - { - NoForeshore, - ForeshoreWithValidBreakWater, - ForeshoreWithoutBreakWater - } - private static StabilityStoneCoverWaveConditionsCalculation GetValidCalculation() { var calculation = new StabilityStoneCoverWaveConditionsCalculation @@ -820,29 +435,15 @@ return calculation; } - private static StabilityStoneCoverWaveConditionsCalculation GetDefaultCalculation() - { - StabilityStoneCoverWaveConditionsCalculation calculation = GetValidCalculation(); - calculation.InputParameters.LowerBoundaryWaterLevels = (RoundedDouble) 5; - calculation.InputParameters.UpperBoundaryWaterLevels = (RoundedDouble) 5.4; - - return calculation; - } - private static ForeshoreProfile CreateForeshoreProfile() { - return CreateForeshoreProfile(new BreakWater(BreakWaterType.Dam, 10.0)); - } - - 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 BreakWater(BreakWaterType.Dam, 10.0), new ForeshoreProfile.ConstructionProperties()); } } Index: Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Integration.Test/WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs =================================================================== diff -u -ra14d1309ecf82ff5b0385a2f6e3b2c4a216a4184 -r2731ce4dea0447322aef9238f4ef33cffe864c9e --- Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Integration.Test/WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision a14d1309ecf82ff5b0385a2f6e3b2c4a216a4184) +++ Ringtoets/WaveImpactAsphaltCover/test/Ringtoets.WaveImpactAsphaltCover.Integration.Test/WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs (.../WaveImpactAsphaltCoverWaveConditionsCalculationActivityIntegrationTest.cs) (revision 2731ce4dea0447322aef9238f4ef33cffe864c9e) @@ -55,7 +55,6 @@ validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); } - [Test] public void Run_NoHydraulicBoundaryDatabase_DoesNotPerformCalculationAndLogsError() { @@ -101,370 +100,6 @@ } [Test] - public void Run_InvalidHydraulicBoundaryDatabase_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 testFilePath = Path.Combine(testDataPath, "corruptschema.sqlite"); - var activity = new WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, - testFilePath, - assessmentSection.WaveImpactAsphaltCover, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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(string.Format("Validatie mislukt: Fout bij het lezen van bestand '{0}': Kon geen locaties verkrijgen van de database.", testFilePath), 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 Run_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, - validFilePath, - assessmentSection.WaveImpactAsphaltCover, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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 Run_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 - } - }; - - var activity = new WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.WaveImpactAsphaltCover, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // Call - activity.Run(); - 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 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 Run_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, - validFilePath, - assessmentSection.WaveImpactAsphaltCover, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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] - [TestCase(double.NegativeInfinity, TestName = "Run_CalculationWithForeshoreNoBWInvalidBWHeight_PerformAndLog(negativeInfinity)")] - [TestCase(double.PositiveInfinity, TestName = "Run_CalculationWithForeshoreNoBWInvalidBWHeight_PerformAndLog(positiveInfinity)")] - [TestCase(double.NaN, TestName = "Run_CalculationWithForeshoreNoBWInvalidBWrHeight_PerformAndLog(NaN)")] - public void Run_CalculationWithForeshoreAndDoesNotUseBreakWaterAndHasInvalidBreakWaterHeight_PerformCalculationAndLogStartEnd(double breakWaterHeight) - { - // 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(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 WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.WaveImpactAsphaltCover, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // Call - Action call = () => activity.Run(); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(10, 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) - { - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[i + 1]); - StringAssert.StartsWith("Golfcondities berekeningsverslag. Klik op details voor meer informatie.", msgs[i + 2]); - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[i + 3]); - - i = i + 3; - } - - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[9]); - }); - Assert.AreEqual(ActivityState.Executed, activity.State); - } - } - - [Test] - [TestCase(double.NegativeInfinity, TestName = "Run_CalculationWithForeshoreBreakWaterInvalidBreakWaterHeight_LogNotPerform(negativeInfinity)")] - [TestCase(double.PositiveInfinity, TestName = "Run_CalculationWithForeshoreBreakWaterInvalidBreakWaterHeight_LogNotPerform(positiveInfinity)")] - [TestCase(double.NaN, TestName = "Run_CalculationWithForeshoreBreakWaterInvalidBreakWaterHeight_LogNotPerform(NaN)")] - public void Run_CalculationWithForeshoreAndUsesBreakWaterAndHasInvalidBreakWaterHeight_DoesNotPerformCalculationAndLogStartEnd(double breakWaterHeight) - { - // 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(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 WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.WaveImpactAsphaltCover, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // 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] - [TestCase(CalculationType.NoForeshore)] - [TestCase(CalculationType.ForeshoreWithoutBreakWater)] - [TestCase(CalculationType.ForeshoreWithValidBreakWater)] - public void Run_CalculationValidateForeshoreProfile_PerformLogStartErrorEnd(CalculationType calculationType) - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - ImportHydraulicBoundaryDatabase(assessmentSection); - - WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetDefaultCalculation(assessmentSection); - - switch (calculationType) - { - case CalculationType.NoForeshore: - calculation.InputParameters.ForeshoreProfile = null; - calculation.InputParameters.UseForeshore = false; - calculation.InputParameters.UseBreakWater = false; - calculation.InputParameters.Orientation = (RoundedDouble) 0; - break; - case CalculationType.ForeshoreWithoutBreakWater: - calculation.InputParameters.ForeshoreProfile = CreateForeshoreProfile(null); - calculation.InputParameters.UseBreakWater = false; - break; - case CalculationType.ForeshoreWithValidBreakWater: - break; - } - - var activity = new WaveImpactAsphaltCoverWaveConditionsCalculationActivity(calculation, - validFilePath, - assessmentSection.WaveImpactAsphaltCover, - assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // Call - Action call = () => activity.Run(); - - // Assert - TestHelper.AssertLogMessages(call, messages => - { - var msgs = messages.ToArray(); - Assert.AreEqual(10, 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) - { - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' gestart.", calculation.Name, waterLevel), msgs[i + 1]); - StringAssert.StartsWith("Golfcondities berekeningsverslag. Klik op details voor meer informatie.", msgs[i + 2]); - Assert.AreEqual(string.Format("Berekening '{0}' voor waterstand '{1}' beëindigd.", calculation.Name, waterLevel), msgs[i + 3]); - - i = i + 3; - } - - StringAssert.StartsWith(string.Format("Berekening van '{0}' beëindigd om: ", calculation.Name), msgs[9]); - }); - Assert.AreEqual(ActivityState.Executed, activity.State); - } - } - - [Test] public void Run_Always_SetProgressTexts() { // Setup @@ -616,13 +251,6 @@ } } - public enum CalculationType - { - NoForeshore, - ForeshoreWithValidBreakWater, - ForeshoreWithoutBreakWater - } - private static WaveImpactAsphaltCoverWaveConditionsCalculation GetValidCalculation(AssessmentSection assessmentSection) { var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation @@ -644,15 +272,6 @@ return calculation; } - private static WaveImpactAsphaltCoverWaveConditionsCalculation GetDefaultCalculation(AssessmentSection assessmentSection) - { - WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection); - calculation.InputParameters.LowerBoundaryWaterLevels = (RoundedDouble) 5; - calculation.InputParameters.UpperBoundaryWaterLevels = (RoundedDouble) 5.4; - - return calculation; - } - private void ImportHydraulicBoundaryDatabase(AssessmentSection assessmentSection) { string filePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); @@ -674,17 +293,5 @@ 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