Index: Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs
===================================================================
diff -u -rc66cd76ed12f37102c268a8a562071567ef496be -rab7d74806fab75a32c4064276e6de55ecd69a28a
--- Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision c66cd76ed12f37102c268a8a562071567ef496be)
+++ Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision ab7d74806fab75a32c4064276e6de55ecd69a28a)
@@ -102,7 +102,8 @@
(stabilityStoneCoverFailureMechanism, hydraulicBoundaryLocations));
break;
case WaveImpactAsphaltCoverFailureMechanism waveImpactAsphaltCoverFailureMechanism:
- changedObservables.AddRange(WaveImpactAsphaltCoverDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(waveImpactAsphaltCoverFailureMechanism));
+ changedObservables.AddRange(WaveImpactAsphaltCoverDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(
+ waveImpactAsphaltCoverFailureMechanism, hydraulicBoundaryLocations));
break;
case GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwardsFailureMechanism:
changedObservables.AddRange(GrassCoverErosionOutwardsDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(grassCoverErosionOutwardsFailureMechanism));
Index: Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Service/WaveImpactAsphaltCoverDataSynchronizationService.cs
===================================================================
diff -u -r9e9976818f1b446948c3bf815cafe2e023f98ac1 -rab7d74806fab75a32c4064276e6de55ecd69a28a
--- Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Service/WaveImpactAsphaltCoverDataSynchronizationService.cs (.../WaveImpactAsphaltCoverDataSynchronizationService.cs) (revision 9e9976818f1b446948c3bf815cafe2e023f98ac1)
+++ Riskeer/WaveImpactAsphaltCover/src/Riskeer.WaveImpactAsphaltCover.Service/WaveImpactAsphaltCoverDataSynchronizationService.cs (.../WaveImpactAsphaltCoverDataSynchronizationService.cs) (revision ab7d74806fab75a32c4064276e6de55ecd69a28a)
@@ -36,24 +36,33 @@
public static class WaveImpactAsphaltCoverDataSynchronizationService
{
///
- /// Clears the and output for all the wave conditions calculations
- /// in the .
+ /// Clears the and output for the wave conditions calculations
+ /// in the that uses an
+ /// from .
///
/// The
/// which contains the calculations.
+ /// The hydraulic boundary locations to clear for.
/// An of objects which are affected by removing data.
- /// Thrown when
- /// is null.
+ /// Thrown when any parameter is null.
public static IEnumerable ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(
- WaveImpactAsphaltCoverFailureMechanism failureMechanism)
+ WaveImpactAsphaltCoverFailureMechanism failureMechanism,
+ IEnumerable hydraulicBoundaryLocations)
{
if (failureMechanism == null)
{
throw new ArgumentNullException(nameof(failureMechanism));
}
+ if (hydraulicBoundaryLocations == null)
+ {
+ throw new ArgumentNullException(nameof(hydraulicBoundaryLocations));
+ }
+
var affectedItems = new List();
- foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in failureMechanism.Calculations.Cast())
+ foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in failureMechanism.Calculations.Cast()
+ .Where(c => hydraulicBoundaryLocations.Contains(
+ c.InputParameters.HydraulicBoundaryLocation)))
{
affectedItems.AddRange(RiskeerCommonDataSynchronizationService.ClearCalculationOutput(calculation));
affectedItems.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocation(calculation.InputParameters));
Index: Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Service.Test/WaveImpactAsphaltCoverDataSynchronizationServiceTest.cs
===================================================================
diff -u -r9e9976818f1b446948c3bf815cafe2e023f98ac1 -rab7d74806fab75a32c4064276e6de55ecd69a28a
--- Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Service.Test/WaveImpactAsphaltCoverDataSynchronizationServiceTest.cs (.../WaveImpactAsphaltCoverDataSynchronizationServiceTest.cs) (revision 9e9976818f1b446948c3bf815cafe2e023f98ac1)
+++ Riskeer/WaveImpactAsphaltCover/test/Riskeer.WaveImpactAsphaltCover.Service.Test/WaveImpactAsphaltCoverDataSynchronizationServiceTest.cs (.../WaveImpactAsphaltCoverDataSynchronizationServiceTest.cs) (revision ab7d74806fab75a32c4064276e6de55ecd69a28a)
@@ -28,6 +28,7 @@
using Riskeer.Common.Data.Calculation;
using Riskeer.Common.Data.FailureMechanism;
using Riskeer.Common.Data.Hydraulics;
+using Riskeer.Common.Data.TestUtil;
using Riskeer.Common.Service;
using Riskeer.Revetment.Data;
using Riskeer.WaveImpactAsphaltCover.Data;
@@ -41,41 +42,78 @@
public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_FailureMechanismNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate call = () =>
- WaveImpactAsphaltCoverDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(null);
+ void Call() => WaveImpactAsphaltCoverDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(
+ null, Enumerable.Empty());
// Assert
- var exception = Assert.Throws(call);
+ var exception = Assert.Throws(Call);
Assert.AreEqual("failureMechanism", exception.ParamName);
}
[Test]
+ public void ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations_HydraulicBoundaryLocationsNull_ThrowsArgumentNullException()
+ {
+ // Call
+ void Call() => WaveImpactAsphaltCoverDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(
+ new WaveImpactAsphaltCoverFailureMechanism(), null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("hydraulicBoundaryLocations", exception.ParamName);
+ }
+
+ [Test]
public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_WithVariousCalculations_ClearsOutputAndReturnsAffectedObjects()
{
// Setup
- WaveImpactAsphaltCoverFailureMechanism failureMechanism = CreateFullyConfiguredFailureMechanism();
- WaveImpactAsphaltCoverWaveConditionsCalculation[] calculations = failureMechanism.Calculations.Cast().ToArray();
- IObservable[] expectedAffectedCalculations = calculations.Where(c => c.HasOutput)
- .Cast()
- .ToArray();
- IObservable[] expectedAffectedCalculationInputs = calculations.Select(c => c.InputParameters)
- .Where(i => i.HydraulicBoundaryLocation != null)
- .Cast()
- .ToArray();
+ var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation();
+ var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation();
+ WaveImpactAsphaltCoverFailureMechanism failureMechanism = CreateFullyConfiguredFailureMechanism(hydraulicBoundaryLocation1);
+ failureMechanism.CalculationsGroup.Children.AddRange(new[]
+ {
+ new WaveImpactAsphaltCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = hydraulicBoundaryLocation2
+ }
+ },
+ new WaveImpactAsphaltCoverWaveConditionsCalculation
+ {
+ InputParameters =
+ {
+ HydraulicBoundaryLocation = hydraulicBoundaryLocation2
+ },
+ Output = new WaveImpactAsphaltCoverWaveConditionsOutput(Enumerable.Empty())
+ }
+ });
+
+ WaveImpactAsphaltCoverWaveConditionsCalculation[] calculations = failureMechanism.Calculations.Cast()
+ .ToArray();
+
+ IEnumerable expectedAffectedCalculations = calculations.Where(
+ c => c.InputParameters.HydraulicBoundaryLocation == hydraulicBoundaryLocation1
+ && c.HasOutput).ToArray();
+
+ var expectedAffectedItems = new List(expectedAffectedCalculations);
+ expectedAffectedItems.AddRange(calculations.Select(c => c.InputParameters)
+ .Where(i => i.HydraulicBoundaryLocation == hydraulicBoundaryLocation1));
+
// Call
- IEnumerable affectedItems =
- WaveImpactAsphaltCoverDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(failureMechanism);
+ IEnumerable affectedItems = WaveImpactAsphaltCoverDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(
+ failureMechanism, new[]
+ {
+ hydraulicBoundaryLocation1
+ });
// 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(failureMechanism.Calculations.Cast()
- .All(c => c.InputParameters.HydraulicBoundaryLocation == null
- && !c.HasOutput));
+ Assert.IsTrue(expectedAffectedCalculations.All(c => !c.HasOutput));
+ Assert.IsTrue(calculations.All(c => c.InputParameters.HydraulicBoundaryLocation != hydraulicBoundaryLocation1));
- CollectionAssert.AreEquivalent(expectedAffectedCalculations.Concat(expectedAffectedCalculationInputs),
- affectedItems);
+ CollectionAssert.AreEquivalent(expectedAffectedItems, affectedItems);
}
[Test]
@@ -153,7 +191,7 @@
CollectionAssert.AreEquivalent(expectedRemovedObjects, results.RemovedObjects);
}
- private static WaveImpactAsphaltCoverFailureMechanism CreateFullyConfiguredFailureMechanism()
+ private static WaveImpactAsphaltCoverFailureMechanism CreateFullyConfiguredFailureMechanism(HydraulicBoundaryLocation hydraulicBoundaryLocation = null)
{
var section1 = new FailureMechanismSection("A", new[]
{
@@ -173,7 +211,10 @@
section2
}, "some/path/to/sections");
- var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0, 0);
+ if (hydraulicBoundaryLocation == null)
+ {
+ hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation();
+ }
var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation();
var calculationWithOutput = new WaveImpactAsphaltCoverWaveConditionsCalculation