Index: Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/MacroStabilityInwardsDataSynchronizationService.cs =================================================================== diff -u -raf512699accf113b63e9fa871ff27ce539c2f508 -rb5b3e06b1d193ca35b0f17e580a49f31bb282939 --- Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/MacroStabilityInwardsDataSynchronizationService.cs (.../MacroStabilityInwardsDataSynchronizationService.cs) (revision af512699accf113b63e9fa871ff27ce539c2f508) +++ Riskeer/MacroStabilityInwards/src/Riskeer.MacroStabilityInwards.Service/MacroStabilityInwardsDataSynchronizationService.cs (.../MacroStabilityInwardsDataSynchronizationService.cs) (revision b5b3e06b1d193ca35b0f17e580a49f31bb282939) @@ -72,7 +72,7 @@ } return failureMechanism.Calculations - .OfType() + .Cast() .Where(c => !c.InputParameters.UseAssessmentLevelManualInput) .SelectMany(ClearCalculationOutput) .ToArray(); @@ -104,7 +104,12 @@ } /// - /// Clears the and output for all the calculations in the . + /// Clears: + /// + /// The for all the calculations in the ; + /// The output for all the calculations in the , + /// except where is true. + /// /// /// The which contains the calculations. /// An of objects which are affected by removing data. @@ -119,7 +124,7 @@ var affectedItems = new List(); foreach (MacroStabilityInwardsCalculation calculation in failureMechanism.Calculations.Cast()) { - affectedItems.AddRange(ClearCalculationOutput(calculation) + affectedItems.AddRange(ClearAllCalculationOutputWithoutManualAssessmentLevel(failureMechanism) .Concat(ClearHydraulicBoundaryLocation(calculation.InputParameters))); } Index: Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Service.Test/MacroStabilityInwardsDataSynchronizationServiceTest.cs =================================================================== diff -u -raf512699accf113b63e9fa871ff27ce539c2f508 -rb5b3e06b1d193ca35b0f17e580a49f31bb282939 --- Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Service.Test/MacroStabilityInwardsDataSynchronizationServiceTest.cs (.../MacroStabilityInwardsDataSynchronizationServiceTest.cs) (revision af512699accf113b63e9fa871ff27ce539c2f508) +++ Riskeer/MacroStabilityInwards/test/Riskeer.MacroStabilityInwards.Service.Test/MacroStabilityInwardsDataSynchronizationServiceTest.cs (.../MacroStabilityInwardsDataSynchronizationServiceTest.cs) (revision b5b3e06b1d193ca35b0f17e580a49f31bb282939) @@ -183,28 +183,36 @@ { // Setup MacroStabilityInwardsFailureMechanism failureMechanism = MacroStabilityInwardsTestDataGenerator.GetMacroStabilityInwardsFailureMechanismWithAllCalculationConfigurations(); - MacroStabilityInwardsCalculation[] 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(); + failureMechanism.CalculationsGroup.Children.Add(new MacroStabilityInwardsCalculationScenario + { + InputParameters = + { + UseAssessmentLevelManualInput = true + }, + Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() + }); + MacroStabilityInwardsCalculation[] calculations = failureMechanism.Calculations + .Cast() + .ToArray(); + + var expectedAffectedItems = new List(); + expectedAffectedItems.AddRange(calculations.Where(c => !c.InputParameters.UseAssessmentLevelManualInput + && c.HasOutput)); + expectedAffectedItems.AddRange(calculations.Select(c => c.InputParameters) + .Where(i => i.HydraulicBoundaryLocation != null)); + // Call IEnumerable affectedItems = MacroStabilityInwardsDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(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 - .Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null - && !c.HasOutput)); + Assert.IsTrue(calculations.Where(c => !c.InputParameters.UseAssessmentLevelManualInput) + .All(c => c.InputParameters.HydraulicBoundaryLocation == null + && !c.HasOutput)); - CollectionAssert.AreEquivalent(expectedAffectedCalculations.Concat(expectedAffectedCalculationInputs), - affectedItems); + CollectionAssert.AreEquivalent(expectedAffectedItems, affectedItems); } [Test]