Index: Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs =================================================================== diff -u -re856305f59df8b905a53b34d03387fc3ff711fe5 -r2ab23c9bfbe6fc678ad320771b3fe842e434ac36 --- Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision e856305f59df8b905a53b34d03387fc3ff711fe5) +++ Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision 2ab23c9bfbe6fc678ad320771b3fe842e434ac36) @@ -274,7 +274,7 @@ (int) normType, typeof(NormType)); } - + var changedObservables = new List(); foreach (IFailureMechanism failureMechanism in assessmentSection.GetFailureMechanisms()) @@ -300,6 +300,51 @@ } /// + /// Clears the wave conditions calculation output that corresponds with the + /// in the . + /// + /// The which contains the calculations. + /// The to clear for. + /// All objects affected by the operation. + /// Thrown when any parameter is null. + public static IEnumerable ClearAllWaveConditionsCalculationOutput( + IAssessmentSection assessmentSection, HydraulicBoundaryLocationCalculationsForTargetProbability calculationsForTargetProbability) + { + if (assessmentSection == null) + { + throw new ArgumentNullException(nameof(assessmentSection)); + } + + if (calculationsForTargetProbability == null) + { + throw new ArgumentNullException(nameof(calculationsForTargetProbability)); + } + + var changedObservables = new List(); + + foreach (IFailureMechanism failureMechanism in assessmentSection.GetFailureMechanisms()) + { + switch (failureMechanism) + { + case GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwardsFailureMechanism: + changedObservables.AddRange(WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(grassCoverErosionOutwardsFailureMechanism, calculationsForTargetProbability)); + break; + case StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism: + changedObservables.AddRange(WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(stabilityStoneCoverFailureMechanism, calculationsForTargetProbability)); + break; + case WaveImpactAsphaltCoverFailureMechanism waveImpactAsphaltCoverFailureMechanism: + changedObservables.AddRange(WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(waveImpactAsphaltCoverFailureMechanism, calculationsForTargetProbability)); + break; + } + } + + return changedObservables; + } + + /// /// Clears all illustration point results of the norm target probability based water level calculations. /// /// The to clear the illustration point results for. Index: Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs =================================================================== diff -u -re856305f59df8b905a53b34d03387fc3ff711fe5 -r2ab23c9bfbe6fc678ad320771b3fe842e434ac36 --- Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision e856305f59df8b905a53b34d03387fc3ff711fe5) +++ Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision 2ab23c9bfbe6fc678ad320771b3fe842e434ac36) @@ -526,7 +526,7 @@ } [Test] - public void ClearAllWaveConditionsCalculationOutput_AssessmentSectionNull_ThrowsArgumentNullException() + public void ClearAllWaveConditionsCalculationOutputWithNormType_AssessmentSectionNull_ThrowsArgumentNullException() { // Call void Call() => RiskeerDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(null, NormType.LowerLimit); @@ -537,7 +537,7 @@ } [Test] - public void ClearAllWaveConditionsCalculationOutput_InvalidNormType_ThrowsInvalidEnumArgumentException() + public void ClearAllWaveConditionsCalculationOutputWithNormType_InvalidNormType_ThrowsInvalidEnumArgumentException() { // Setup const NormType normType = (NormType) 99; @@ -552,7 +552,7 @@ } [Test] - public void ClearAllWaveConditionsCalculationOutput_WithData_ClearsOutputAndReturnsAffectedObjects() + public void ClearAllWaveConditionsCalculationOutputWithNormType_WithData_ClearsOutputAndReturnsAffectedObjects() { // Setup const NormType normType = NormType.LowerLimit; @@ -588,6 +588,69 @@ } [Test] + public void ClearAllWaveConditionsCalculationOutputWithHydraulicBoundaryLocationCalculationsForTargetProbability_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => RiskeerDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(null, new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1)); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void ClearAllWaveConditionsCalculationOutputWithHydraulicBoundaryLocationCalculationsForTargetProbability_CalculationsForTargetProbabilityNull_ThrowsArgumentNullException() + { + // Call + void Call() => RiskeerDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(new AssessmentSectionStub(), null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("calculationsForTargetProbability", exception.ParamName); + } + + [Test] + public void ClearAllWaveConditionsCalculationOutputWithHydraulicBoundaryLocationCalculationsForTargetProbability_WithData_ClearsOutputAndReturnsAffectedObjects() + { + // Setup + AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); + + var calculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.1); + + var waveConditionsCalculations = new List>(); + waveConditionsCalculations.AddRange(assessmentSection.GrassCoverErosionOutwards.Calculations + .Cast()); + waveConditionsCalculations.AddRange(assessmentSection.StabilityStoneCover.Calculations + .Cast()); + waveConditionsCalculations.AddRange(assessmentSection.WaveImpactAsphaltCover.Calculations + .Cast()); + + waveConditionsCalculations.ForEachElementDo(c => + { + c.InputParameters.WaterLevelType = WaveConditionsInputWaterLevelType.UserDefinedTargetProbability; + c.InputParameters.CalculationsTargetProbability = calculationsForTargetProbability; + }); + + IEnumerable> expectedAffectedItems = waveConditionsCalculations.Where(c => c.HasOutput) + .ToArray(); + + // Call + IEnumerable affectedItems = RiskeerDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(assessmentSection, calculationsForTargetProbability); + + // Assert + // Note: To make sure the clear is performed regardless of what is done with + // the return result, no ToArray() should be called before these assertions: + Assert.IsTrue(assessmentSection.GrassCoverErosionOutwards.Calculations.Cast() + .All(c => !c.HasOutput)); + Assert.IsTrue(assessmentSection.StabilityStoneCover.Calculations.Cast() + .All(c => !c.HasOutput)); + Assert.IsTrue(assessmentSection.WaveImpactAsphaltCover.Calculations.Cast() + .All(c => !c.HasOutput)); + + CollectionAssert.AreEquivalent(expectedAffectedItems, affectedItems); + } + + [Test] public void ClearIllustrationPointResultsOfWaterLevelCalculationsForNormTargetProbabilities_AssessmentSectionNull_ThrowsArgumentNullException() { // Call