Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs =================================================================== diff -u -rb46e7362cfbeafe2ea25d7d3c36e7d25e5cfdb65 -r3677b8248a272c85b66a85669c5f11fa96a18e40 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision b46e7362cfbeafe2ea25d7d3c36e7d25e5cfdb65) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs (.../GrassCoverErosionInwardsCalculationActivityIntegrationTest.cs) (revision 3677b8248a272c85b66a85669c5f11fa96a18e40) @@ -151,6 +151,48 @@ Assert.AreEqual(expectedProgressTexts, progressTexts); } + private static void AddSectionToAssessmentSection(AssessmentSection assessmentSection) + { + assessmentSection.GrassCoverErosionInwards.AddSection(new FailureMechanismSection("test section", new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + } + + private static void ImportHydraulicBoundaryDatabase(AssessmentSection assessmentSection) + { + string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); + + using (var importer = new HydraulicBoundaryDatabaseImporter()) + { + importer.Import(assessmentSection, validFilePath); + } + } + + private static DikeProfile CreateDikeProfile() + { + return new DikeProfile(new Point2D(0, 0), + new[] + { + new RoughnessPoint(new Point2D(1.1, 2.2), 0.6), + new RoughnessPoint(new Point2D(3.3, 4.4), 0.7) + }, new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + new BreakWater(BreakWaterType.Dam, 10.0), + new DikeProfile.ConstructionProperties + { + Id = "id", + Orientation = 5.5, + DikeHeight = 10 + }); + } + + #region Overtopping calculations + [Test] public void Run_ValidOvertoppingCalculation_InputPropertiesCorrectlySendToService() { @@ -217,124 +259,6 @@ } [Test] - [TestCase(DikeHeightCalculationType.CalculateByAssessmentSectionNorm, TestName = "Run_ValidDikeHeightCalculation_InputPropertiesCorrectlySendToService(AssessmentSectionNorm)")] - [TestCase(DikeHeightCalculationType.CalculateByProfileSpecificRequiredProbability, TestName = "Run_ValidDikeHeightCalculation_InputPropertiesCorrectlySendToService(ProfileProbability)")] - public void Run_ValidDikeHeightCalculation_InputPropertiesCorrectlySendToService(DikeHeightCalculationType dikeHeightCalculationType) - { - // 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), - DikeProfile = CreateDikeProfile(), - DikeHeightCalculationType = dikeHeightCalculationType - } - }; - - var activity = new GrassCoverErosionInwardsCalculationActivity(calculation, validFile, assessmentSection.GrassCoverErosionInwards, assessmentSection); - - using (new HydraRingCalculatorFactoryConfig()) - { - // Call - activity.Run(); - - // Assert - TestHydraulicLoadsCalculator dikeHeightCalculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).DikeHeightCalculator; - HydraulicLoadsCalculationInput[] dikeHeightCalculationInputs = dikeHeightCalculator.ReceivedInputs.ToArray(); - Assert.AreEqual(1, dikeHeightCalculationInputs.Length); - - HydraulicLoadsCalculationInput actualInput = dikeHeightCalculationInputs[0]; - GeneralGrassCoverErosionInwardsInput generalInput = assessmentSection.GrassCoverErosionInwards.GeneralInput; - - GrassCoverErosionInwardsInput input = calculation.InputParameters; - - double norm = dikeHeightCalculationType == DikeHeightCalculationType.CalculateByAssessmentSectionNorm - ? assessmentSection.FailureMechanismContribution.Norm - : RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability( - assessmentSection.FailureMechanismContribution.Norm, - assessmentSection.GrassCoverErosionInwards.Contribution, - generalInput.N); - - var expectedInput = new DikeHeightCalculationInput(calculation.InputParameters.HydraulicBoundaryLocation.Id, - norm, - calculation.InputParameters.Orientation, - calculation.InputParameters.DikeGeometry.Select(roughnessPoint => new HydraRingRoughnessProfilePoint(roughnessPoint.Point.X, roughnessPoint.Point.Y, roughnessPoint.Roughness)), - input.ForeshoreGeometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)), - new HydraRingBreakWater((int) input.BreakWater.Type, input.BreakWater.Height), - generalInput.CriticalOvertoppingModelFactor, - generalInput.FbFactor.Mean, - generalInput.FbFactor.StandardDeviation, - generalInput.FbFactor.LowerBoundary, - generalInput.FbFactor.UpperBoundary, - generalInput.FnFactor.Mean, - generalInput.FnFactor.StandardDeviation, - generalInput.FnFactor.LowerBoundary, - generalInput.FnFactor.UpperBoundary, - generalInput.OvertoppingModelFactor, - calculation.InputParameters.CriticalFlowRate.Mean, - calculation.InputParameters.CriticalFlowRate.StandardDeviation, - generalInput.FrunupModelFactor.Mean, - generalInput.FrunupModelFactor.StandardDeviation, - generalInput.FrunupModelFactor.LowerBoundary, - generalInput.FrunupModelFactor.UpperBoundary, - generalInput.FshallowModelFactor.Mean, - generalInput.FshallowModelFactor.StandardDeviation, - generalInput.FshallowModelFactor.LowerBoundary, - generalInput.FshallowModelFactor.UpperBoundary); - - HydraRingDataEqualityHelper.AreEqual(expectedInput, actualInput); - Assert.AreEqual(testDataPath, dikeHeightCalculator.HydraulicBoundaryDatabaseDirectory); - } - } - - private static void AddSectionToAssessmentSection(AssessmentSection assessmentSection) - { - assessmentSection.GrassCoverErosionInwards.AddSection(new FailureMechanismSection("test section", new[] - { - new Point2D(0, 0), - new Point2D(1, 1) - })); - } - - private static void ImportHydraulicBoundaryDatabase(AssessmentSection assessmentSection) - { - string validFilePath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); - - using (var importer = new HydraulicBoundaryDatabaseImporter()) - { - importer.Import(assessmentSection, validFilePath); - } - } - - private static DikeProfile CreateDikeProfile() - { - return new DikeProfile(new Point2D(0, 0), - new[] - { - new RoughnessPoint(new Point2D(1.1, 2.2), 0.6), - new RoughnessPoint(new Point2D(3.3, 4.4), 0.7) - }, new[] - { - new Point2D(3.3, 4.4), - new Point2D(5.5, 6.6) - }, - new BreakWater(BreakWaterType.Dam, 10.0), - new DikeProfile.ConstructionProperties - { - Id = "id", - Orientation = 5.5, - DikeHeight = 10 - }); - } - - #region Overtopping calculations - - [Test] public void Run_InvalidOvertoppingCalculationWithExceptionAndLastErrorPresent_LogErrorAndThrowException() { // Setup @@ -595,6 +519,82 @@ [Test] [TestCase(DikeHeightCalculationType.CalculateByAssessmentSectionNorm)] [TestCase(DikeHeightCalculationType.CalculateByProfileSpecificRequiredProbability)] + public void Run_ValidDikeHeightCalculation_InputPropertiesCorrectlySendToService(DikeHeightCalculationType dikeHeightCalculationType) + { + // 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), + DikeProfile = CreateDikeProfile(), + DikeHeightCalculationType = dikeHeightCalculationType + } + }; + + var activity = new GrassCoverErosionInwardsCalculationActivity(calculation, validFile, assessmentSection.GrassCoverErosionInwards, assessmentSection); + + using (new HydraRingCalculatorFactoryConfig()) + { + // Call + activity.Run(); + + // Assert + TestHydraulicLoadsCalculator dikeHeightCalculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).DikeHeightCalculator; + HydraulicLoadsCalculationInput[] hydraulicLoadsCalculationInputs = dikeHeightCalculator.ReceivedInputs.ToArray(); + Assert.AreEqual(1, hydraulicLoadsCalculationInputs.Length); + + HydraulicLoadsCalculationInput actualInput = hydraulicLoadsCalculationInputs[0]; + GeneralGrassCoverErosionInwardsInput generalInput = assessmentSection.GrassCoverErosionInwards.GeneralInput; + + GrassCoverErosionInwardsInput input = calculation.InputParameters; + + double norm = dikeHeightCalculationType == DikeHeightCalculationType.CalculateByAssessmentSectionNorm + ? assessmentSection.FailureMechanismContribution.Norm + : RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability( + assessmentSection.FailureMechanismContribution.Norm, + assessmentSection.GrassCoverErosionInwards.Contribution, + generalInput.N); + + var expectedInput = new DikeHeightCalculationInput(calculation.InputParameters.HydraulicBoundaryLocation.Id, + norm, + calculation.InputParameters.Orientation, + calculation.InputParameters.DikeGeometry.Select(roughnessPoint => new HydraRingRoughnessProfilePoint(roughnessPoint.Point.X, roughnessPoint.Point.Y, roughnessPoint.Roughness)), + input.ForeshoreGeometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)), + new HydraRingBreakWater((int) input.BreakWater.Type, input.BreakWater.Height), + generalInput.CriticalOvertoppingModelFactor, + generalInput.FbFactor.Mean, + generalInput.FbFactor.StandardDeviation, + generalInput.FbFactor.LowerBoundary, + generalInput.FbFactor.UpperBoundary, + generalInput.FnFactor.Mean, + generalInput.FnFactor.StandardDeviation, + generalInput.FnFactor.LowerBoundary, + generalInput.FnFactor.UpperBoundary, + generalInput.OvertoppingModelFactor, + calculation.InputParameters.CriticalFlowRate.Mean, + calculation.InputParameters.CriticalFlowRate.StandardDeviation, + generalInput.FrunupModelFactor.Mean, + generalInput.FrunupModelFactor.StandardDeviation, + generalInput.FrunupModelFactor.LowerBoundary, + generalInput.FrunupModelFactor.UpperBoundary, + generalInput.FshallowModelFactor.Mean, + generalInput.FshallowModelFactor.StandardDeviation, + generalInput.FshallowModelFactor.LowerBoundary, + generalInput.FshallowModelFactor.UpperBoundary); + + HydraRingDataEqualityHelper.AreEqual(expectedInput, actualInput); + Assert.AreEqual(testDataPath, dikeHeightCalculator.HydraulicBoundaryDatabaseDirectory); + } + } + + [Test] + [TestCase(DikeHeightCalculationType.CalculateByAssessmentSectionNorm)] + [TestCase(DikeHeightCalculationType.CalculateByProfileSpecificRequiredProbability)] public void Run_InvalidDikeHeightCalculationWithExceptionAndLastErrorPresent_LogError(DikeHeightCalculationType dikeHeightCalculationType) { // Setup @@ -890,6 +890,81 @@ [Test] [TestCase(OvertoppingRateCalculationType.CalculateByAssessmentSectionNorm)] [TestCase(OvertoppingRateCalculationType.CalculateByProfileSpecificRequiredProbability)] + public void Run_ValidOvertoppingRateCalculation_InputPropertiesCorrectlySendToService(OvertoppingRateCalculationType overtoppingRateCalculationType) + { + // 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), + DikeProfile = CreateDikeProfile(), + OvertoppingRateCalculationType = overtoppingRateCalculationType + } + }; + + var activity = new GrassCoverErosionInwardsCalculationActivity(calculation, validFile, assessmentSection.GrassCoverErosionInwards, assessmentSection); + + using (new HydraRingCalculatorFactoryConfig()) + { + // Call + activity.Run(); + + // Assert + TestHydraulicLoadsCalculator overtoppingRateCalculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).OvertoppingRateCalculator; + HydraulicLoadsCalculationInput[] hydraulicLoadsCalculationInputs = overtoppingRateCalculator.ReceivedInputs.ToArray(); + Assert.AreEqual(1, hydraulicLoadsCalculationInputs.Length); + + HydraulicLoadsCalculationInput actualInput = hydraulicLoadsCalculationInputs[0]; + GeneralGrassCoverErosionInwardsInput generalInput = assessmentSection.GrassCoverErosionInwards.GeneralInput; + + GrassCoverErosionInwardsInput input = calculation.InputParameters; + + double norm = overtoppingRateCalculationType == OvertoppingRateCalculationType.CalculateByAssessmentSectionNorm + ? assessmentSection.FailureMechanismContribution.Norm + : RingtoetsCommonDataCalculationService.ProfileSpecificRequiredProbability( + assessmentSection.FailureMechanismContribution.Norm, + assessmentSection.GrassCoverErosionInwards.Contribution, + generalInput.N); + + var expectedInput = new OvertoppingRateCalculationInput(calculation.InputParameters.HydraulicBoundaryLocation.Id, + norm, + calculation.InputParameters.Orientation, + calculation.InputParameters.DikeGeometry.Select(roughnessPoint => new HydraRingRoughnessProfilePoint(roughnessPoint.Point.X, roughnessPoint.Point.Y, roughnessPoint.Roughness)), + input.ForeshoreGeometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)), + new HydraRingBreakWater((int) input.BreakWater.Type, input.BreakWater.Height), + calculation.InputParameters.DikeHeight, + generalInput.CriticalOvertoppingModelFactor, + generalInput.FbFactor.Mean, + generalInput.FbFactor.StandardDeviation, + generalInput.FbFactor.LowerBoundary, + generalInput.FbFactor.UpperBoundary, + generalInput.FnFactor.Mean, + generalInput.FnFactor.StandardDeviation, + generalInput.FnFactor.LowerBoundary, + generalInput.FnFactor.UpperBoundary, + generalInput.OvertoppingModelFactor, + generalInput.FrunupModelFactor.Mean, + generalInput.FrunupModelFactor.StandardDeviation, + generalInput.FrunupModelFactor.LowerBoundary, + generalInput.FrunupModelFactor.UpperBoundary, + generalInput.FshallowModelFactor.Mean, + generalInput.FshallowModelFactor.StandardDeviation, + generalInput.FshallowModelFactor.LowerBoundary, + generalInput.FshallowModelFactor.UpperBoundary); + + HydraRingDataEqualityHelper.AreEqual(expectedInput, actualInput); + Assert.AreEqual(testDataPath, overtoppingRateCalculator.HydraulicBoundaryDatabaseDirectory); + } + } + + [Test] + [TestCase(OvertoppingRateCalculationType.CalculateByAssessmentSectionNorm)] + [TestCase(OvertoppingRateCalculationType.CalculateByProfileSpecificRequiredProbability)] public void Run_InvalidOvertoppingRateCalculationWithExceptionAndLastErrorPresent_LogError(OvertoppingRateCalculationType overtoppingRateCalculationType) { // Setup