Index: Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs =================================================================== diff -u -r53600fd15c4dbc49ba98553498baf69dc0faa0d7 -r9a931d552787ccfbee3455713a17d46e616ebdb2 --- Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision 53600fd15c4dbc49ba98553498baf69dc0faa0d7) +++ Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision 9a931d552787ccfbee3455713a17d46e616ebdb2) @@ -27,6 +27,7 @@ using Riskeer.ClosingStructures.Service; using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Data.Calculation; +using Riskeer.Common.Data.Contribution; using Riskeer.Common.Data.DikeProfiles; using Riskeer.Common.Data.FailureMechanism; using Riskeer.Common.Data.Hydraulics; @@ -229,6 +230,31 @@ } /// + /// Clears the hydraulic boundary location calculation output belonging to the + /// . + /// + /// The which contains the hydraulic boundary + /// location calculations and . + /// + /// All objects affected by the operation. + /// Thrown when is null. + public static IEnumerable ClearHydraulicBoundaryLocationCalculationOutputForNormativeNorm( + IAssessmentSection assessmentSection) + { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + IObservableEnumerable locationCalculationsToClear = assessmentSection.FailureMechanismContribution.NormativeNorm == NormType.LowerLimit + ? assessmentSection.WaterLevelCalculationsForLowerLimitNorm + : assessmentSection.WaterLevelCalculationsForSignalingNorm; + + return RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationOutput(locationCalculationsToClear) + .ToArray(); + } + + /// /// Clears the hydraulic boundary location calculation output that is contained /// within specific failure mechanisms of the . /// Index: Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs =================================================================== diff -u -r53600fd15c4dbc49ba98553498baf69dc0faa0d7 -r9a931d552787ccfbee3455713a17d46e616ebdb2 --- Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision 53600fd15c4dbc49ba98553498baf69dc0faa0d7) +++ Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision 9a931d552787ccfbee3455713a17d46e616ebdb2) @@ -28,6 +28,7 @@ using Riskeer.ClosingStructures.Data; using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Data.Calculation; +using Riskeer.Common.Data.Contribution; using Riskeer.Common.Data.DikeProfiles; using Riskeer.Common.Data.FailureMechanism; using Riskeer.Common.Data.Hydraulics; @@ -237,6 +238,72 @@ } [Test] + public void ClearHydraulicBoundaryLocationCalculationOutputForNormativeNorm_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => RiskeerDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationOutputForNormativeNorm(null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + [TestCase(NormType.LowerLimit)] + [TestCase(NormType.Signaling)] + public void ClearHydraulicBoundaryLocationCalculationOutputForNormativeNorm_NormativeNormIsLowerLimitNorm_ClearDataAndReturnAffectedObjects(NormType normType) + { + // Setup + var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation(); + + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = + { + Locations = + { + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 + } + }, + FailureMechanismContribution = + { + NormativeNorm = normType + } + }; + + assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] + { + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 + }); + + HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculationForLowerLimitNorm = assessmentSection.WaterLevelCalculationsForLowerLimitNorm + .First(c => ReferenceEquals(c.HydraulicBoundaryLocation, hydraulicBoundaryLocation1)); + HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculationForSignalingNorm = assessmentSection.WaterLevelCalculationsForSignalingNorm + .First(c => ReferenceEquals(c.HydraulicBoundaryLocation, hydraulicBoundaryLocation1)); + + hydraulicBoundaryLocationCalculationForLowerLimitNorm.Output = new TestHydraulicBoundaryLocationCalculationOutput(); + hydraulicBoundaryLocationCalculationForSignalingNorm.Output = new TestHydraulicBoundaryLocationCalculationOutput(); + + var expectedAffectedItems = new List + { + normType == NormType.LowerLimit + ? hydraulicBoundaryLocationCalculationForLowerLimitNorm + : hydraulicBoundaryLocationCalculationForSignalingNorm + }; + + // Call + IEnumerable affectedObjects = RiskeerDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationOutputForNormativeNorm(null); + + // Assert + CollectionAssert.AreEquivalent(expectedAffectedItems, affectedObjects); + Assert.AreEqual(normType != NormType.LowerLimit, hydraulicBoundaryLocationCalculationForLowerLimitNorm.HasOutput); + Assert.AreEqual(normType != NormType.Signaling, hydraulicBoundaryLocationCalculationForSignalingNorm.HasOutput); + } + + [Test] public void ClearHydraulicBoundaryLocationCalculationOutput_AssessmentSectionNull_ThrowsArgumentNullException() { // Call