Index: Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs =================================================================== diff -u -rb14f85d007791f99296896e4a940a0e97ae6d8cf -r0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc --- Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision b14f85d007791f99296896e4a940a0e97ae6d8cf) +++ Riskeer/Integration/src/Riskeer.Integration.Service/RiskeerDataSynchronizationService.cs (.../RiskeerDataSynchronizationService.cs) (revision 0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc) @@ -126,30 +126,15 @@ throw new ArgumentNullException(nameof(assessmentSection)); } - return ClearFailureMechanismCalculationOutputs(assessmentSection.GetFailureMechanisms()); - } - - /// - /// Clears the output of all calculations of the given . - /// - /// The failure mechanisms that contain the calculations. - /// An of calculations that are affected by clearing the output. - /// Thrown when is null. - public static IEnumerable ClearFailureMechanismCalculationOutputs(IEnumerable failureMechanisms) - { - if (failureMechanisms == null) - { - throw new ArgumentNullException(nameof(failureMechanisms)); - } - var changedObservables = new List(); - foreach (IFailureMechanism failureMechanism in failureMechanisms) + foreach (IFailureMechanism failureMechanism in assessmentSection.GetFailureMechanisms()) { switch (failureMechanism) { case PipingFailureMechanism pipingFailureMechanism: - changedObservables.AddRange(PipingDataSynchronizationService.ClearAllCalculationOutput(pipingFailureMechanism)); + changedObservables.AddRange(PipingDataSynchronizationService.ClearAllSemiProbabilisticCalculationOutputWithoutManualAssessmentLevel(pipingFailureMechanism)); + changedObservables.AddRange(PipingDataSynchronizationService.ClearAllProbabilisticCalculationOutput(pipingFailureMechanism)); break; case GrassCoverErosionInwardsFailureMechanism grassCoverErosionInwardsFailureMechanism: changedObservables.AddRange(GrassCoverErosionInwardsDataSynchronizationService.ClearAllCalculationOutput(grassCoverErosionInwardsFailureMechanism)); @@ -173,7 +158,7 @@ changedObservables.AddRange(StabilityPointStructuresDataSynchronizationService.ClearAllCalculationOutput(stabilityPointStructuresFailureMechanism)); break; case MacroStabilityInwardsFailureMechanism macroStabilityInwardsFailureMechanism: - changedObservables.AddRange(MacroStabilityInwardsDataSynchronizationService.ClearAllCalculationOutput(macroStabilityInwardsFailureMechanism)); + changedObservables.AddRange(MacroStabilityInwardsDataSynchronizationService.ClearAllCalculationOutputWithoutManualAssessmentLevel(macroStabilityInwardsFailureMechanism)); break; } } Index: Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs =================================================================== diff -u -r270ab241e81b1049a6dc9ef0ce540f290039e82e -r0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc --- Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision 270ab241e81b1049a6dc9ef0ce540f290039e82e) +++ Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision 0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc) @@ -64,10 +64,10 @@ public class RiskeerDataSynchronizationServiceTest { [Test] - public void ClearFailureMechanismCalculationOutputs_WithoutAssessmentSection_ThrowsArgumentNullException() + public void ClearFailureMechanismCalculationOutputs_AssessmentSectionNull_ThrowsArgumentNullException() { // Call - void Call() => RiskeerDataSynchronizationService.ClearFailureMechanismCalculationOutputs((IAssessmentSection) null); + void Call() => RiskeerDataSynchronizationService.ClearFailureMechanismCalculationOutputs(null); // Assert var exception = Assert.Throws(Call); @@ -79,61 +79,71 @@ { // Setup AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); - IEnumerable expectedAffectedItems = assessmentSection.GetFailureMechanisms() - .SelectMany(f => f.Calculations) - .Where(c => c.HasOutput) - .ToList(); + var expectedAffectedItems = new List(); + expectedAffectedItems.AddRange(assessmentSection.ClosingStructures.Calculations + .Cast>() + .Where(c => c.HasOutput)); + expectedAffectedItems.AddRange(assessmentSection.GrassCoverErosionInwards.Calculations + .Cast() + .Where(c => c.HasOutput)); + expectedAffectedItems.AddRange(assessmentSection.GrassCoverErosionOutwards.Calculations + .Cast() + .Where(c => c.HasOutput)); + expectedAffectedItems.AddRange(assessmentSection.HeightStructures.Calculations + .Cast>() + .Where(c => c.HasOutput)); + expectedAffectedItems.AddRange(assessmentSection.Piping.Calculations + .OfType() + .Where(c => !c.InputParameters.UseAssessmentLevelManualInput && c.HasOutput)); + expectedAffectedItems.AddRange(assessmentSection.Piping.Calculations + .OfType() + .Where(c => c.HasOutput)); + expectedAffectedItems.AddRange(assessmentSection.StabilityPointStructures.Calculations + .Cast>() + .Where(c => c.HasOutput)); + expectedAffectedItems.AddRange(assessmentSection.StabilityStoneCover.Calculations + .Cast() + .Where(c => c.HasOutput)); + expectedAffectedItems.AddRange(assessmentSection.WaveImpactAsphaltCover.Calculations + .Cast() + .Where(c => c.HasOutput)); + expectedAffectedItems.AddRange(assessmentSection.MacroStabilityInwards.Calculations + .Cast() + .Where(c => c.HasOutput)); + // Call IEnumerable affectedItems = RiskeerDataSynchronizationService.ClearFailureMechanismCalculationOutputs(assessmentSection); // 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: - CollectionAssert.IsEmpty(assessmentSection.GetFailureMechanisms() - .SelectMany(f => f.Calculations) - .Where(c => c.HasOutput)); + Assert.IsTrue(assessmentSection.ClosingStructures.Calculations.Cast>() + .All(c => !c.HasOutput)); + Assert.IsTrue(assessmentSection.GrassCoverErosionInwards.Calculations.Cast() + .All(c => !c.HasOutput)); + Assert.IsTrue(assessmentSection.GrassCoverErosionOutwards.Calculations.Cast() + .All(c => !c.HasOutput)); + Assert.IsTrue(assessmentSection.HeightStructures.Calculations.Cast>() + .All(c => !c.HasOutput)); + Assert.IsTrue(assessmentSection.Piping.Calculations.OfType() + .Where(c => !c.InputParameters.UseAssessmentLevelManualInput) + .All(c => !c.HasOutput)); + Assert.IsTrue(assessmentSection.Piping.Calculations.OfType() + .All(c => !c.HasOutput)); + Assert.IsTrue(assessmentSection.StabilityPointStructures.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)); + Assert.IsTrue(assessmentSection.MacroStabilityInwards.Calculations.Cast() + .All(c => !c.InputParameters.UseAssessmentLevelManualInput && !c.HasOutput)); CollectionAssert.AreEquivalent(expectedAffectedItems, affectedItems); } [Test] - public void ClearFailureMechanismCalculationOutputs_WithoutFailureMechanisms_ThrowsArgumentNullException() - { - // Call - void Call() => RiskeerDataSynchronizationService.ClearFailureMechanismCalculationOutputs((IEnumerable) null); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("failureMechanisms", exception.ParamName); - } - - [Test] - public void ClearFailureMechanismCalculationOutputs_WithFailureMechanisms_ClearsFailureMechanismCalculationsOutputAndReturnsAffectedCalculations() - { - // Setup - IEnumerable failureMechanisms = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations() - .GetFailureMechanisms() - .ToList(); - IEnumerable expectedAffectedItems = failureMechanisms - .SelectMany(f => f.Calculations) - .Where(c => c.HasOutput) - .ToList(); - - // Call - IEnumerable affectedItems = RiskeerDataSynchronizationService.ClearFailureMechanismCalculationOutputs(failureMechanisms); - - // 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: - CollectionAssert.IsEmpty(failureMechanisms - .SelectMany(f => f.Calculations) - .Where(c => c.HasOutput)); - - CollectionAssert.AreEquivalent(expectedAffectedItems, affectedItems); - } - - [Test] public void ClearAllSemiProbabilisticCalculationOutput_AssessmentSectionNull_ThrowsArgumentNullException() { // Call @@ -330,7 +340,8 @@ Assert.IsTrue(assessmentSection.HeightStructures.Calculations.Cast>() .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); Assert.IsTrue(assessmentSection.Piping.Calculations.OfType() - .All(c => !c.InputParameters.UseAssessmentLevelManualInput && !c.HasOutput)); + .Where(c => !c.InputParameters.UseAssessmentLevelManualInput) + .All(c => !c.HasOutput)); Assert.IsTrue(assessmentSection.Piping.Calculations.OfType() .All(c => !c.HasOutput)); Assert.IsTrue(assessmentSection.Piping.Calculations.Cast>() Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/MacroStabilityInwardsDataSynchronizationService.cs =================================================================== diff -u -r741b9d245ecf082a4faf99642c0c2335d3e4eb0c -r0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/MacroStabilityInwardsDataSynchronizationService.cs (.../MacroStabilityInwardsDataSynchronizationService.cs) (revision 741b9d245ecf082a4faf99642c0c2335d3e4eb0c) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/MacroStabilityInwardsDataSynchronizationService.cs (.../MacroStabilityInwardsDataSynchronizationService.cs) (revision 0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc) @@ -39,25 +39,6 @@ public static class MacroStabilityInwardsDataSynchronizationService { /// - /// Clears the output for all calculations in the . - /// - /// The which contains the calculations. - /// An of calculations which are affected by clearing the output. - /// Thrown when is null. - public static IEnumerable ClearAllCalculationOutput(MacroStabilityInwardsFailureMechanism failureMechanism) - { - if (failureMechanism == null) - { - throw new ArgumentNullException(nameof(failureMechanism)); - } - - return failureMechanism.Calculations - .Cast() - .SelectMany(RiskeerCommonDataSynchronizationService.ClearCalculationOutput) - .ToArray(); - } - - /// /// Clears the output for all calculations in the , /// except where is true. /// Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Service.Test/MacroStabilityInwardsDataSynchronizationServiceTest.cs =================================================================== diff -u -r514fc2d1d9096ef2d86ff87526fd3ecf001e065b -r0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Service.Test/MacroStabilityInwardsDataSynchronizationServiceTest.cs (.../MacroStabilityInwardsDataSynchronizationServiceTest.cs) (revision 514fc2d1d9096ef2d86ff87526fd3ecf001e065b) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Service.Test/MacroStabilityInwardsDataSynchronizationServiceTest.cs (.../MacroStabilityInwardsDataSynchronizationServiceTest.cs) (revision 0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc) @@ -38,37 +38,6 @@ public class MacroStabilityInwardsDataSynchronizationServiceTest { [Test] - public void ClearAllCalculationOutput_FailureMechanismNull_ThrowsArgumentNullException() - { - // Call - void Call() => MacroStabilityInwardsDataSynchronizationService.ClearAllCalculationOutput(null); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("failureMechanism", exception.ParamName); - } - - [Test] - public void ClearAllCalculationOutput_WithVariousCalculations_ClearsCalculationsOutputAndReturnsAffectedCalculations() - { - // Setup - MacroStabilityInwardsFailureMechanism failureMechanism = MacroStabilityInwardsTestDataGenerator.GetMacroStabilityInwardsFailureMechanismWithAllCalculationConfigurations(); - ICalculation[] expectedAffectedCalculations = failureMechanism.Calculations - .Where(c => c.HasOutput) - .ToArray(); - - // Call - IEnumerable affectedItems = MacroStabilityInwardsDataSynchronizationService.ClearAllCalculationOutput(failureMechanism); - - // 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.All(c => !c.HasOutput)); - - CollectionAssert.AreEquivalent(expectedAffectedCalculations, affectedItems); - } - - [Test] public void ClearAllCalculationOutputWithoutManualAssessmentLevel_FailureMechanismNull_ThrowsArgumentNullException() { // Call Index: Riskeer/Piping/src/Riskeer.Piping.Service/PipingDataSynchronizationService.cs =================================================================== diff -u -r741b9d245ecf082a4faf99642c0c2335d3e4eb0c -r0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc --- Riskeer/Piping/src/Riskeer.Piping.Service/PipingDataSynchronizationService.cs (.../PipingDataSynchronizationService.cs) (revision 741b9d245ecf082a4faf99642c0c2335d3e4eb0c) +++ Riskeer/Piping/src/Riskeer.Piping.Service/PipingDataSynchronizationService.cs (.../PipingDataSynchronizationService.cs) (revision 0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc) @@ -43,25 +43,6 @@ public static class PipingDataSynchronizationService { /// - /// Clears the output for all calculations in the . - /// - /// The which contains the calculations. - /// An of calculations which are affected by clearing the output. - /// Thrown when is null. - public static IEnumerable ClearAllCalculationOutput(PipingFailureMechanism failureMechanism) - { - if (failureMechanism == null) - { - throw new ArgumentNullException(nameof(failureMechanism)); - } - - return failureMechanism.Calculations - .Cast>() - .SelectMany(RiskeerCommonDataSynchronizationService.ClearCalculationOutput) - .ToArray(); - } - - /// /// Clears the output for all in the , /// except for the where /// is true. Index: Riskeer/Piping/test/Riskeer.Piping.Service.Test/PipingDataSynchronizationServiceTest.cs =================================================================== diff -u -r514fc2d1d9096ef2d86ff87526fd3ecf001e065b -r0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc --- Riskeer/Piping/test/Riskeer.Piping.Service.Test/PipingDataSynchronizationServiceTest.cs (.../PipingDataSynchronizationServiceTest.cs) (revision 514fc2d1d9096ef2d86ff87526fd3ecf001e065b) +++ Riskeer/Piping/test/Riskeer.Piping.Service.Test/PipingDataSynchronizationServiceTest.cs (.../PipingDataSynchronizationServiceTest.cs) (revision 0c9d5a9c08c87f3604ac3b7f7433987382d2a7dc) @@ -40,37 +40,6 @@ public class PipingDataSynchronizationServiceTest { [Test] - public void ClearAllCalculationOutput_FailureMechanismNull_ThrowsArgumentNullException() - { - // Call - void Call() => PipingDataSynchronizationService.ClearAllCalculationOutput(null); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("failureMechanism", exception.ParamName); - } - - [Test] - public void ClearAllCalculationOutput_WithVariousCalculations_ClearsCalculationsOutputAndReturnsAffectedCalculations() - { - // Setup - PipingFailureMechanism failureMechanism = PipingTestDataGenerator.GetPipingFailureMechanismWithAllCalculationConfigurations(); - ICalculation[] expectedAffectedCalculations = failureMechanism.Calculations - .Where(c => c.HasOutput) - .ToArray(); - - // Call - IEnumerable affectedItems = PipingDataSynchronizationService.ClearAllCalculationOutput(failureMechanism); - - // 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.All(c => !c.HasOutput)); - - CollectionAssert.AreEquivalent(expectedAffectedCalculations, affectedItems); - } - - [Test] public void ClearAllSemiProbabilisticCalculationOutputWithoutManualAssessmentLevel_FailureMechanismNull_ThrowsArgumentNullException() { // Call