Index: Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs =================================================================== diff -u -rade14068f963945d8be9fa8881015d99bcd2b699 -rb21a6af2eaa9f8d96c56608dfd03092779e1e666 --- Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision ade14068f963945d8be9fa8881015d99bcd2b699) +++ Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision b21a6af2eaa9f8d96c56608dfd03092779e1e666) @@ -98,105 +98,125 @@ // Setup AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); IEnumerable hydraulicBoundaryLocations = assessmentSection.HydraulicBoundaryData.GetLocations(); + HydraulicBoundaryLocation locationToRemove = hydraulicBoundaryLocations.First(); - var expectedAffectedItems = new List(); + var expectedAffectedCalculations = new List>(); + expectedAffectedCalculations.AddRange(assessmentSection.ClosingStructures.Calculations + .Cast>() + .Where(c => c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + expectedAffectedCalculations.AddRange(assessmentSection.GrassCoverErosionInwards.Calculations + .Cast() + .Where(c => c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + expectedAffectedCalculations.AddRange(assessmentSection.GrassCoverErosionOutwards.Calculations + .Cast() + .Where(c => c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + expectedAffectedCalculations.AddRange(assessmentSection.HeightStructures.Calculations + .Cast>() + .Where(c => c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + expectedAffectedCalculations.AddRange(assessmentSection.Piping.Calculations + .OfType() + .Where(c => !c.InputParameters.UseAssessmentLevelManualInput + && c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + expectedAffectedCalculations.AddRange(assessmentSection.Piping.Calculations + .OfType() + .Where(c => c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + expectedAffectedCalculations.AddRange(assessmentSection.StabilityPointStructures.Calculations + .Cast>() + .Where(c => c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + expectedAffectedCalculations.AddRange(assessmentSection.StabilityStoneCover.Calculations + .Cast() + .Where(c => c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + expectedAffectedCalculations.AddRange(assessmentSection.WaveImpactAsphaltCover.Calculations + .Cast() + .Where(c => c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + expectedAffectedCalculations.AddRange(assessmentSection.MacroStabilityInwards.Calculations + .Cast() + .Where(c => c.InputParameters.HydraulicBoundaryLocation == locationToRemove + && c.HasOutput)); + + var expectedAffectedItems = new List(expectedAffectedCalculations); expectedAffectedItems.AddRange(assessmentSection.ClosingStructures.Calculations .Cast>() - .Where(c => c.HasOutput)); - expectedAffectedItems.AddRange(assessmentSection.ClosingStructures.Calculations - .Cast>() .Select(c => c.InputParameters) - .Where(i => i.HydraulicBoundaryLocation != null)); + .Where(i => i.HydraulicBoundaryLocation == locationToRemove)); expectedAffectedItems.AddRange(assessmentSection.GrassCoverErosionInwards.Calculations .Cast() - .Where(c => c.HasOutput)); - expectedAffectedItems.AddRange(assessmentSection.GrassCoverErosionInwards.Calculations - .Cast() .Select(c => c.InputParameters) - .Where(i => i.HydraulicBoundaryLocation != null)); + .Where(i => i.HydraulicBoundaryLocation == locationToRemove)); expectedAffectedItems.AddRange(assessmentSection.GrassCoverErosionOutwards.Calculations .Cast() - .Where(c => c.HasOutput)); - expectedAffectedItems.AddRange(assessmentSection.GrassCoverErosionOutwards.Calculations - .Cast() .Select(c => c.InputParameters) - .Where(i => i.HydraulicBoundaryLocation != null)); + .Where(i => i.HydraulicBoundaryLocation == locationToRemove)); expectedAffectedItems.AddRange(assessmentSection.HeightStructures.Calculations .Cast>() - .Where(c => c.HasOutput)); - expectedAffectedItems.AddRange(assessmentSection.HeightStructures.Calculations - .Cast>() .Select(c => c.InputParameters) - .Where(i => i.HydraulicBoundaryLocation != null)); + .Where(i => i.HydraulicBoundaryLocation == locationToRemove)); 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.Piping.Calculations .Cast>() .Select(c => c.InputParameters) - .Where(i => i.HydraulicBoundaryLocation != null)); + .Where(i => i.HydraulicBoundaryLocation == locationToRemove)); expectedAffectedItems.AddRange(assessmentSection.StabilityPointStructures.Calculations .Cast>() - .Where(c => c.HasOutput)); - expectedAffectedItems.AddRange(assessmentSection.StabilityPointStructures.Calculations - .Cast>() .Select(c => c.InputParameters) - .Where(i => i.HydraulicBoundaryLocation != null)); + .Where(i => i.HydraulicBoundaryLocation == locationToRemove)); expectedAffectedItems.AddRange(assessmentSection.StabilityStoneCover.Calculations .Cast() - .Where(c => c.HasOutput)); - expectedAffectedItems.AddRange(assessmentSection.StabilityStoneCover.Calculations - .Cast() .Select(c => c.InputParameters) - .Where(i => i.HydraulicBoundaryLocation != null)); + .Where(i => i.HydraulicBoundaryLocation == locationToRemove)); expectedAffectedItems.AddRange(assessmentSection.WaveImpactAsphaltCover.Calculations .Cast() - .Where(c => c.HasOutput)); - expectedAffectedItems.AddRange(assessmentSection.WaveImpactAsphaltCover.Calculations - .Cast() .Select(c => c.InputParameters) - .Where(i => i.HydraulicBoundaryLocation != null)); + .Where(i => i.HydraulicBoundaryLocation == locationToRemove)); expectedAffectedItems.AddRange(assessmentSection.MacroStabilityInwards.Calculations .Cast() - .Where(c => c.HasOutput)); - expectedAffectedItems.AddRange(assessmentSection.MacroStabilityInwards.Calculations - .Cast() .Select(c => c.InputParameters) - .Where(i => i.HydraulicBoundaryLocation != null)); + .Where(i => i.HydraulicBoundaryLocation == locationToRemove)); // Call IEnumerable affectedItems = RiskeerDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations( - assessmentSection, hydraulicBoundaryLocations); + assessmentSection, new[] + { + locationToRemove + }); // 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(expectedAffectedCalculations.All(c => !c.HasOutput)); + Assert.IsTrue(assessmentSection.ClosingStructures.Calculations.Cast>() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.GrassCoverErosionInwards.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.GrassCoverErosionOutwards.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.HeightStructures.Calculations.Cast>() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.Piping.Calculations.OfType() .Where(c => !c.InputParameters.UseAssessmentLevelManualInput) - .All(c => !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.Piping.Calculations.OfType() - .All(c => !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.Piping.Calculations.Cast>() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.StabilityPointStructures.Calculations.Cast>() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.StabilityStoneCover.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.WaveImpactAsphaltCover.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); Assert.IsTrue(assessmentSection.MacroStabilityInwards.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + .All(c => c.InputParameters.HydraulicBoundaryLocation != locationToRemove)); + CollectionAssert.AreEquivalent(expectedAffectedItems, affectedItems); } Index: Riskeer/Integration/test/Riskeer.Integration.TestUtil/TestDataGenerator.cs =================================================================== diff -u -r9a9ec78578a4c7b1b5e54cc6033692a25517ed68 -rb21a6af2eaa9f8d96c56608dfd03092779e1e666 --- Riskeer/Integration/test/Riskeer.Integration.TestUtil/TestDataGenerator.cs (.../TestDataGenerator.cs) (revision 9a9ec78578a4c7b1b5e54cc6033692a25517ed68) +++ Riskeer/Integration/test/Riskeer.Integration.TestUtil/TestDataGenerator.cs (.../TestDataGenerator.cs) (revision b21a6af2eaa9f8d96c56608dfd03092779e1e666) @@ -69,7 +69,8 @@ AssessmentSectionComposition composition = AssessmentSectionComposition.Dike) { var random = new Random(21); - var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation(); var assessmentSection = new AssessmentSection(composition) { HydraulicBoundaryData = @@ -80,7 +81,8 @@ { Locations = { - hydraulicBoundaryLocation + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 } } } @@ -92,7 +94,8 @@ assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { - hydraulicBoundaryLocation + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 }); assessmentSection.WaterLevelCalculationsForSignalFloodingProbability.First().Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble()); @@ -103,15 +106,15 @@ assessmentSection.WaveHeightCalculationsForUserDefinedTargetProbabilities.First() .HydraulicBoundaryLocationCalculations.First().Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble()); - SetFullyConfiguredFailureMechanism(assessmentSection.ClosingStructures, hydraulicBoundaryLocation); - SetFullyConfiguredFailureMechanism(assessmentSection.GrassCoverErosionInwards, hydraulicBoundaryLocation); - MacroStabilityInwardsTestDataGenerator.ConfigureFailureMechanismWithAllCalculationConfigurations(assessmentSection.MacroStabilityInwards, hydraulicBoundaryLocation); - SetFullyConfiguredFailureMechanism(assessmentSection.GrassCoverErosionOutwards, hydraulicBoundaryLocation); - SetFullyConfiguredFailureMechanism(assessmentSection.HeightStructures, hydraulicBoundaryLocation); - PipingTestDataGenerator.ConfigureFailureMechanismWithAllCalculationConfigurations(assessmentSection.Piping, hydraulicBoundaryLocation); - SetFullyConfiguredFailureMechanism(assessmentSection.StabilityPointStructures, hydraulicBoundaryLocation); - SetFullyConfiguredFailureMechanism(assessmentSection.StabilityStoneCover, hydraulicBoundaryLocation); - SetFullyConfiguredFailureMechanism(assessmentSection.WaveImpactAsphaltCover, hydraulicBoundaryLocation); + SetFullyConfiguredFailureMechanism(assessmentSection.ClosingStructures, hydraulicBoundaryLocation1); + SetFullyConfiguredFailureMechanism(assessmentSection.GrassCoverErosionInwards, hydraulicBoundaryLocation2); + MacroStabilityInwardsTestDataGenerator.ConfigureFailureMechanismWithAllCalculationConfigurations(assessmentSection.MacroStabilityInwards, hydraulicBoundaryLocation2); + SetFullyConfiguredFailureMechanism(assessmentSection.GrassCoverErosionOutwards, hydraulicBoundaryLocation1); + SetFullyConfiguredFailureMechanism(assessmentSection.HeightStructures, hydraulicBoundaryLocation1); + PipingTestDataGenerator.ConfigureFailureMechanismWithAllCalculationConfigurations(assessmentSection.Piping, hydraulicBoundaryLocation2); + SetFullyConfiguredFailureMechanism(assessmentSection.StabilityPointStructures, hydraulicBoundaryLocation1); + SetFullyConfiguredFailureMechanism(assessmentSection.StabilityStoneCover, hydraulicBoundaryLocation1); + SetFullyConfiguredFailureMechanism(assessmentSection.WaveImpactAsphaltCover, hydraulicBoundaryLocation1); SetFullyConfiguredFailureMechanism(assessmentSection.DuneErosion); SetFullyConfiguredFailureMechanism(assessmentSection.GrassCoverSlipOffInwards); SetFullyConfiguredFailureMechanism(assessmentSection.GrassCoverSlipOffOutwards);