Index: Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs
===================================================================
diff -u -r1ceb376282c1b8c7efc172811cbca4993693e58e -r9a4b965ad3b5a3ba1d98a8a00086becd2d16eca3
--- Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision 1ceb376282c1b8c7efc172811cbca4993693e58e)
+++ Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision 9a4b965ad3b5a3ba1d98a8a00086becd2d16eca3)
@@ -309,6 +309,56 @@
}
///
+ /// Clears all the illustration point results for the design water level calculations.
+ ///
+ /// The to clear the illustration point results for.
+ /// All objects that are affected by the operation.
+ /// Thrown when is null.
+ public static IEnumerable ClearIllustrationPointResultsForDesignWaterLevelCalculations(IAssessmentSection assessmentSection)
+ {
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ var affectedObjects = new List();
+ affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints(
+ assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm));
+ affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints(
+ assessmentSection.WaterLevelCalculationsForSignalingNorm));
+ affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints(
+ assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm));
+ affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints(
+ assessmentSection.WaterLevelCalculationsForLowerLimitNorm));
+ return affectedObjects;
+ }
+
+ ///
+ /// Clears all the illustration point results for the wave height calculations.
+ ///
+ /// The to clear the illustration point results for.
+ /// All objects that are affected by the operation.
+ /// Thrown when is null.
+ public static IEnumerable ClearIllustrationPointResultsForWaveHeightCalculations(IAssessmentSection assessmentSection)
+ {
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException(nameof(assessmentSection));
+ }
+
+ var affectedObjects = new List();
+ affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints(
+ assessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm));
+ affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints(
+ assessmentSection.WaveHeightCalculationsForSignalingNorm));
+ affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints(
+ assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm));
+ affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints(
+ assessmentSection.WaveHeightCalculationsForLowerLimitNorm));
+ return affectedObjects;
+ }
+
+ ///
/// Clears the reference line and all data that depends on it, either directly or indirectly.
///
/// The assessment section.
Index: Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs
===================================================================
diff -u -r1ceb376282c1b8c7efc172811cbca4993693e58e -r9a4b965ad3b5a3ba1d98a8a00086becd2d16eca3
--- Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision 1ceb376282c1b8c7efc172811cbca4993693e58e)
+++ Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision 9a4b965ad3b5a3ba1d98a8a00086becd2d16eca3)
@@ -33,6 +33,7 @@
using Riskeer.Common.Data.Hydraulics;
using Riskeer.Common.Data.Structures;
using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Data.TestUtil.IllustrationPoints;
using Riskeer.Common.Service;
using Riskeer.DuneErosion.Data;
using Riskeer.DuneErosion.Data.TestUtil;
@@ -567,6 +568,102 @@
}
[Test]
+ public void ClearIllustrationPointResultsForDesignWaterLevelCalculations_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => RiskeerDataSynchronizationService.ClearIllustrationPointResultsForDesignWaterLevelCalculations(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void ClearIllustrationPointResultsForDesignWaterLevelCalculations_AssessmentSectionWithCalculations_ClearsIllustrationPointsAndReturnsAffectedObjects()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = GetConfiguredAssessmentSectionWithHydraulicBoundaryLocationCalculations();
+
+ HydraulicBoundaryLocationCalculation[] waterLevelCalculationsWithOutput = assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm
+ .Concat(assessmentSection.WaterLevelCalculationsForSignalingNorm)
+ .Concat(assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm)
+ .Concat(assessmentSection.WaterLevelCalculationsForLowerLimitNorm)
+ .Where(calc => calc.HasOutput)
+ .ToArray();
+ HydraulicBoundaryLocationCalculation[] waterLevelCalculationsWithIllustrationPoints = waterLevelCalculationsWithOutput.Where(calc => calc.Output.HasGeneralResult)
+ .ToArray();
+
+ HydraulicBoundaryLocationCalculation[] waveHeightCalculationsWithOutput = assessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm
+ .Concat(assessmentSection.WaveHeightCalculationsForSignalingNorm)
+ .Concat(assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm)
+ .Concat(assessmentSection.WaveHeightCalculationsForLowerLimitNorm)
+ .Where(calc => calc.HasOutput)
+ .ToArray();
+ HydraulicBoundaryLocationCalculation[] waveHeightCalculationsWithIllustrationPoints = waveHeightCalculationsWithOutput.Where(calc => calc.Output.HasGeneralResult)
+ .ToArray();
+
+ // Call
+ IEnumerable affectedObjects = RiskeerDataSynchronizationService.ClearIllustrationPointResultsForDesignWaterLevelCalculations(assessmentSection);
+
+ // Assert
+ CollectionAssert.AreEquivalent(waterLevelCalculationsWithIllustrationPoints, affectedObjects);
+
+ Assert.IsTrue(waterLevelCalculationsWithIllustrationPoints.All(calc => !calc.Output.HasGeneralResult));
+ Assert.IsTrue(waterLevelCalculationsWithOutput.All(calc => calc.HasOutput));
+
+ Assert.IsTrue(waveHeightCalculationsWithIllustrationPoints.All(calc => calc.Output.HasGeneralResult));
+ Assert.IsTrue(waveHeightCalculationsWithOutput.All(calc => calc.HasOutput));
+ }
+
+ [Test]
+ public void ClearIllustrationPointResultsForWaveHeightCalculations_AssessmentSectionNull_ThrowsArgumentNullException()
+ {
+ // Call
+ TestDelegate call = () => RiskeerDataSynchronizationService.ClearIllustrationPointResultsForWaveHeightCalculations(null);
+
+ // Assert
+ var exception = Assert.Throws(call);
+ Assert.AreEqual("assessmentSection", exception.ParamName);
+ }
+
+ [Test]
+ public void ClearIllustrationPointResultsForWaveHeightCalculations_AssessmentSectionWithCalculations_ClearsIllustrationPointsAndReturnsAffectedObjects()
+ {
+ // Setup
+ IAssessmentSection assessmentSection = GetConfiguredAssessmentSectionWithHydraulicBoundaryLocationCalculations();
+
+ HydraulicBoundaryLocationCalculation[] waterLevelCalculationsWithOutput = assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm
+ .Concat(assessmentSection.WaterLevelCalculationsForSignalingNorm)
+ .Concat(assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm)
+ .Concat(assessmentSection.WaterLevelCalculationsForLowerLimitNorm)
+ .Where(calc => calc.HasOutput)
+ .ToArray();
+ HydraulicBoundaryLocationCalculation[] waterLevelCalculationsWithIllustrationPoints = waterLevelCalculationsWithOutput.Where(calc => calc.Output.HasGeneralResult)
+ .ToArray();
+
+ HydraulicBoundaryLocationCalculation[] waveHeightCalculationsWithOutput = assessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm
+ .Concat(assessmentSection.WaveHeightCalculationsForSignalingNorm)
+ .Concat(assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm)
+ .Concat(assessmentSection.WaveHeightCalculationsForLowerLimitNorm)
+ .Where(calc => calc.HasOutput)
+ .ToArray();
+ HydraulicBoundaryLocationCalculation[] waveHeightCalculationsWithIllustrationPoints = waveHeightCalculationsWithOutput.Where(calc => calc.Output.HasGeneralResult)
+ .ToArray();
+
+ // Call
+ IEnumerable affectedObjects = RiskeerDataSynchronizationService.ClearIllustrationPointResultsForWaveHeightCalculations(assessmentSection);
+
+ // Assert
+ CollectionAssert.AreEquivalent(waveHeightCalculationsWithIllustrationPoints, affectedObjects);
+
+ Assert.IsTrue(waterLevelCalculationsWithIllustrationPoints.All(calc => calc.Output.HasGeneralResult));
+ Assert.IsTrue(waterLevelCalculationsWithOutput.All(calc => calc.HasOutput));
+
+ Assert.IsTrue(waveHeightCalculationsWithIllustrationPoints.All(calc => !calc.Output.HasGeneralResult));
+ Assert.IsTrue(waveHeightCalculationsWithOutput.All(calc => calc.HasOutput));
+ }
+
+ [Test]
public void ClearReferenceLine_AssessmentSectionNull_ThrowArgumentNullException()
{
// Call
@@ -1151,7 +1248,7 @@
{
// Call
TestDelegate call = () => RiskeerDataSynchronizationService.RemoveAllForeshoreProfiles(null,
- new ForeshoreProfileCollection());
+ new ForeshoreProfileCollection());
// Assert
var exception = Assert.Throws(call);
@@ -1163,7 +1260,7 @@
{
// Call
TestDelegate call = () => RiskeerDataSynchronizationService.RemoveAllForeshoreProfiles(Enumerable.Empty>(),
- null);
+ null);
// Assert
var exception = Assert.Throws(call);
@@ -1663,5 +1760,37 @@
failureMechanism.CalculationsForFactorizedLowerLimitNorm.First().Output = new TestDuneLocationCalculationOutput();
}
}
+
+ private static IAssessmentSection GetConfiguredAssessmentSectionWithHydraulicBoundaryLocationCalculations()
+ {
+ var assessmentSection = new AssessmentSectionStub();
+
+ var hydraulicBoundaryLocations = new[]
+ {
+ new TestHydraulicBoundaryLocation(),
+ new TestHydraulicBoundaryLocation(),
+ new TestHydraulicBoundaryLocation()
+ };
+
+ assessmentSection.SetHydraulicBoundaryLocationCalculations(hydraulicBoundaryLocations, true);
+ SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm);
+ SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaterLevelCalculationsForSignalingNorm);
+ SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaterLevelCalculationsForLowerLimitNorm);
+ SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm);
+
+ SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaveHeightCalculationsForFactorizedSignalingNorm);
+ SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaveHeightCalculationsForSignalingNorm);
+ SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaveHeightCalculationsForLowerLimitNorm);
+ SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm);
+
+ return assessmentSection;
+ }
+
+ private static void SetHydraulicBoundaryLocationCalculationOutputConfigurations(IObservableEnumerable calculations)
+ {
+ var random = new Random(21);
+ calculations.ElementAt(0).Output = null;
+ calculations.ElementAt(2).Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble(), new TestGeneralResultSubMechanismIllustrationPoint());
+ }
}
}
\ No newline at end of file