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()); } }