Index: Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs
===================================================================
diff -u -r3fa590784870b7a0692243d07cc47caa8929f47c -re856305f59df8b905a53b34d03387fc3ff711fe5
--- Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision 3fa590784870b7a0692243d07cc47caa8929f47c)
+++ Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision e856305f59df8b905a53b34d03387fc3ff711fe5)
@@ -21,12 +21,14 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using Core.Common.Base;
using Riskeer.ClosingStructures.Data;
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;
@@ -45,6 +47,7 @@
using Riskeer.Piping.Data;
using Riskeer.Piping.Service;
using Riskeer.Revetment.Data;
+using Riskeer.Revetment.Service;
using Riskeer.StabilityPointStructures.Data;
using Riskeer.StabilityPointStructures.Service;
using Riskeer.StabilityStoneCover.Data;
@@ -249,6 +252,54 @@
}
///
+ /// 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 is null.
+ /// Thrown when is invalid.
+ /// Thrown when is not supported.
+ public static IEnumerable ClearAllWaveConditionsCalculationOutput(IAssessmentSection assessmentSection, NormType normType)
+ {
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ if (!Enum.IsDefined(typeof(NormType), normType))
+ {
+ throw new InvalidEnumArgumentException(nameof(normType),
+ (int) normType,
+ typeof(NormType));
+ }
+
+ var changedObservables = new List();
+
+ foreach (IFailureMechanism failureMechanism in assessmentSection.GetFailureMechanisms())
+ {
+ switch (failureMechanism)
+ {
+ case GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwardsFailureMechanism:
+ changedObservables.AddRange(WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(grassCoverErosionOutwardsFailureMechanism, normType));
+ break;
+ case StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism:
+ changedObservables.AddRange(WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(stabilityStoneCoverFailureMechanism, normType));
+ break;
+ case WaveImpactAsphaltCoverFailureMechanism waveImpactAsphaltCoverFailureMechanism:
+ changedObservables.AddRange(WaveConditionsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(waveImpactAsphaltCoverFailureMechanism, normType));
+ 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 -r3fa590784870b7a0692243d07cc47caa8929f47c -re856305f59df8b905a53b34d03387fc3ff711fe5
--- Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision 3fa590784870b7a0692243d07cc47caa8929f47c)
+++ Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision e856305f59df8b905a53b34d03387fc3ff711fe5)
@@ -21,13 +21,17 @@
using System;
using System.Collections.Generic;
+using System.ComponentModel;
using System.Linq;
using Core.Common.Base;
+using Core.Common.TestUtil;
+using Core.Common.Util.Extensions;
using NUnit.Framework;
using Rhino.Mocks;
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;
@@ -53,6 +57,7 @@
using Riskeer.Piping.Data.SoilProfile;
using Riskeer.Piping.Data.TestUtil;
using Riskeer.Piping.Primitives;
+using Riskeer.Revetment.Data;
using Riskeer.StabilityPointStructures.Data;
using Riskeer.StabilityStoneCover.Data;
using Riskeer.WaveImpactAsphaltCover.Data;
@@ -521,6 +526,68 @@
}
[Test]
+ public void ClearAllWaveConditionsCalculationOutput_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => RiskeerDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(null, NormType.LowerLimit);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void ClearAllWaveConditionsCalculationOutput_InvalidNormType_ThrowsInvalidEnumArgumentException()
+ {
+ // Setup
+ const NormType normType = (NormType) 99;
+
+ // Call
+ void Call() => RiskeerDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(new AssessmentSectionStub(), normType);
+
+ // Assert
+ var expectedMessage = $"The value of argument 'normType' ({normType}) is invalid for Enum type '{nameof(NormType)}'.";
+ var exception = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage);
+ Assert.AreEqual("normType", exception.ParamName);
+ }
+
+ [Test]
+ public void ClearAllWaveConditionsCalculationOutput_WithData_ClearsOutputAndReturnsAffectedObjects()
+ {
+ // Setup
+ const NormType normType = NormType.LowerLimit;
+ AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations();
+
+ 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.LowerLimit);
+
+ IEnumerable> expectedAffectedItems = waveConditionsCalculations.Where(c => c.HasOutput)
+ .ToArray();
+
+ // Call
+ IEnumerable affectedItems = RiskeerDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(assessmentSection, normType);
+
+ // 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