Index: Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs =================================================================== diff -u -r008f330233a663eff7365bd639b4a0096242b6ca -rade14068f963945d8be9fa8881015d99bcd2b699 --- Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision 008f330233a663eff7365bd639b4a0096242b6ca) +++ Riskeer/Integration/test/Riskeer.Integration.Service.Test/RiskeerDataSynchronizationServiceTest.cs (.../RiskeerDataSynchronizationServiceTest.cs) (revision ade14068f963945d8be9fa8881015d99bcd2b699) @@ -68,6 +68,139 @@ public class RiskeerDataSynchronizationServiceTest { [Test] + public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_AssessmentSectionNull_ThrowsArgumentNullException() + { + // Call + void Call() => RiskeerDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(null, Enumerable.Empty()); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("assessmentSection", exception.ParamName); + } + + [Test] + public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_HydraulicBoundaryLocationsNull_ThrowsArgumentNullException() + { + // Setup + AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); + + // Call + void Call() => RiskeerDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(assessmentSection, null); + + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("hydraulicBoundaryLocations", exception.ParamName); + } + + [Test] + public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_VariousCalculations_ClearsHydraulicBoundaryLocationAndCalculationsAndReturnsAffectedObjects() + { + // Setup + AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); + IEnumerable hydraulicBoundaryLocations = assessmentSection.HydraulicBoundaryData.GetLocations(); + + var expectedAffectedItems = new List(); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + 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)); + + // Call + IEnumerable affectedItems = RiskeerDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations( + assessmentSection, hydraulicBoundaryLocations); + + // 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(assessmentSection.ClosingStructures.Calculations.Cast>() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + Assert.IsTrue(assessmentSection.GrassCoverErosionInwards.Calculations.Cast() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + Assert.IsTrue(assessmentSection.GrassCoverErosionOutwards.Calculations.Cast() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + Assert.IsTrue(assessmentSection.HeightStructures.Calculations.Cast>() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !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.Piping.Calculations.Cast>() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null)); + Assert.IsTrue(assessmentSection.StabilityPointStructures.Calculations.Cast>() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + Assert.IsTrue(assessmentSection.StabilityStoneCover.Calculations.Cast() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + Assert.IsTrue(assessmentSection.WaveImpactAsphaltCover.Calculations.Cast() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + Assert.IsTrue(assessmentSection.MacroStabilityInwards.Calculations.Cast() + .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); + CollectionAssert.AreEquivalent(expectedAffectedItems, affectedItems); + } + + [Test] public void ClearFailureMechanismCalculationOutputs_AssessmentSectionNull_ThrowsArgumentNullException() { // Call @@ -246,139 +379,6 @@ } [Test] - public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_AssessmentSectionNull_ThrowsArgumentNullException() - { - // Call - void Call() => RiskeerDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(null, Enumerable.Empty()); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("assessmentSection", exception.ParamName); - } - - [Test] - public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_HydraulicBoundaryLocationsNull_ThrowsArgumentNullException() - { - // Setup - AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); - - // Call - void Call() => RiskeerDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(assessmentSection, null); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("hydraulicBoundaryLocations", exception.ParamName); - } - - [Test] - public void ClearAllCalculationOutputAndHydraulicBoundaryLocations_VariousCalculations_ClearsHydraulicBoundaryLocationAndCalculationsAndReturnsAffectedObjects() - { - // Setup - AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); - IEnumerable hydraulicBoundaryLocations = assessmentSection.HydraulicBoundaryData.GetLocations(); - - var expectedAffectedItems = new List(); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - 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)); - - // Call - IEnumerable affectedItems = RiskeerDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations( - assessmentSection, hydraulicBoundaryLocations); - - // 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(assessmentSection.ClosingStructures.Calculations.Cast>() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); - Assert.IsTrue(assessmentSection.GrassCoverErosionInwards.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); - Assert.IsTrue(assessmentSection.GrassCoverErosionOutwards.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); - Assert.IsTrue(assessmentSection.HeightStructures.Calculations.Cast>() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !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.Piping.Calculations.Cast>() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null)); - Assert.IsTrue(assessmentSection.StabilityPointStructures.Calculations.Cast>() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); - Assert.IsTrue(assessmentSection.StabilityStoneCover.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); - Assert.IsTrue(assessmentSection.WaveImpactAsphaltCover.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); - Assert.IsTrue(assessmentSection.MacroStabilityInwards.Calculations.Cast() - .All(c => c.InputParameters.HydraulicBoundaryLocation == null && !c.HasOutput)); - CollectionAssert.AreEquivalent(expectedAffectedItems, affectedItems); - } - - [Test] public void ClearHydraulicBoundaryLocationCalculationOutput_AssessmentSectionNull_ThrowsArgumentNullException() { // Call @@ -889,7 +889,7 @@ } [Test] - public void ClearReferenceLine_AssessmentSectionNull_ThrowArgumentNullException() + public void ClearReferenceLineDependentData_AssessmentSectionNull_ThrowArgumentNullException() { // Call void Call() => RiskeerDataSynchronizationService.ClearReferenceLineDependentData(null); @@ -900,7 +900,7 @@ } [Test] - public void ClearReferenceLine_FullyConfiguredAssessmentSection_AllReferenceLineDependentDataCleared() + public void ClearReferenceLineDependentData_FullyConfiguredAssessmentSection_AllReferenceLineDependentDataCleared() { // Setup AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); @@ -1000,7 +1000,7 @@ } [Test] - public void ClearReferenceLine_FullyConfiguredAssessmentSection_ClearResultsContainAllAffectedObjectsAndAllRemovedObjects() + public void ClearReferenceLineDependentData_FullyConfiguredAssessmentSection_ClearResultsContainAllAffectedObjectsAndAllRemovedObjects() { // Setup AssessmentSection assessmentSection = TestDataGenerator.GetAssessmentSectionWithAllCalculationConfigurations(); @@ -1018,24 +1018,24 @@ } [Test] - public void RemoveForeshoreProfile_StabilityStoneCoverFailureMechanismNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_HeightStructuresFailureMechanismNull_ThrowsArgumentNullException() { // Setup ForeshoreProfile profile = new TestForeshoreProfile(); // Call - void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((StabilityStoneCoverFailureMechanism) null, profile); + void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((HeightStructuresFailureMechanism) null, profile); // Assert string paramName = Assert.Throws(Call).ParamName; Assert.AreEqual("failureMechanism", paramName); } [Test] - public void RemoveForeshoreProfile_StabilityStoneCoverFailureMechanismProfileNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_HeightStructuresFailureMechanismProfileNull_ThrowsArgumentNullException() { // Setup - var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var failureMechanism = new HeightStructuresFailureMechanism(); // Call void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile(failureMechanism, null); @@ -1046,18 +1046,18 @@ } [Test] - public void RemoveForeshoreProfile_FullyConfiguredStabilityStoneCoverFailureMechanism_RemoveProfileAndClearDependentData() + public void RemoveForeshoreProfile_FullyConfiguredHeightStructuresFailureMechanism_RemoveProfileAndClearDependentData() { // Setup - StabilityStoneCoverFailureMechanism failureMechanism = TestDataGenerator.GetStabilityStoneCoverFailureMechanismWithAllCalculationConfigurations(); + HeightStructuresFailureMechanism failureMechanism = TestDataGenerator.GetHeightStructuresFailureMechanismWithAlLCalculationConfigurations(); ForeshoreProfile profile = failureMechanism.ForeshoreProfiles[0]; - StabilityStoneCoverWaveConditionsCalculation[] calculationsWithForeshoreProfile = + StructuresCalculation[] calculationsWithForeshoreProfile = failureMechanism.Calculations - .Cast() + .Cast>() .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, profile)) .ToArray(); - StabilityStoneCoverWaveConditionsCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); + StructuresCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); // Precondition CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfile); @@ -1069,7 +1069,7 @@ // 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.DoesNotContain(failureMechanism.ForeshoreProfiles, profile); - foreach (StabilityStoneCoverWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) + foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); } @@ -1078,7 +1078,7 @@ int expectedAffectedObjectCount = 1 + calculationsWithOutput.Length + calculationsWithForeshoreProfile.Length; Assert.AreEqual(expectedAffectedObjectCount, array.Length); CollectionAssert.Contains(array, failureMechanism.ForeshoreProfiles); - foreach (StabilityStoneCoverWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) + foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); CollectionAssert.Contains(array, calculation.InputParameters); @@ -1092,24 +1092,24 @@ } [Test] - public void RemoveForeshoreProfile_WaveImpactAsphaltCoverFailureMechanismNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_ClosingStructuresFailureMechanismNull_ThrowsArgumentNullException() { // Setup ForeshoreProfile profile = new TestForeshoreProfile(); // Call - void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((WaveImpactAsphaltCoverFailureMechanism) null, profile); + void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((ClosingStructuresFailureMechanism) null, profile); // Assert string paramName = Assert.Throws(Call).ParamName; Assert.AreEqual("failureMechanism", paramName); } [Test] - public void RemoveForeshoreProfile_WaveImpactAsphaltCoverFailureMechanismProfileNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_ClosingStructuresFailureMechanismProfileNull_ThrowsArgumentNullException() { // Setup - var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); + var failureMechanism = new ClosingStructuresFailureMechanism(); // Call void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile(failureMechanism, null); @@ -1120,18 +1120,18 @@ } [Test] - public void RemoveForeshoreProfile_FullyConfiguredWaveImpactAsphaltCoverFailureMechanism_RemoveProfileAndClearDependentData() + public void RemoveForeshoreProfile_FullyConfiguredClosingStructuresFailureMechanism_RemoveProfileAndClearDependentData() { // Setup - WaveImpactAsphaltCoverFailureMechanism failureMechanism = TestDataGenerator.GetWaveImpactAsphaltCoverFailureMechanismWithAllCalculationConfigurations(); + ClosingStructuresFailureMechanism failureMechanism = TestDataGenerator.GetClosingStructuresFailureMechanismWithAllCalculationConfigurations(); ForeshoreProfile profile = failureMechanism.ForeshoreProfiles[0]; - WaveImpactAsphaltCoverWaveConditionsCalculation[] calculationsWithForeshoreProfile = + StructuresCalculation[] calculationsWithForeshoreProfile = failureMechanism.Calculations - .Cast() + .Cast>() .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, profile)) .ToArray(); - WaveImpactAsphaltCoverWaveConditionsCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); + StructuresCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); // Precondition CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfile); @@ -1143,7 +1143,7 @@ // 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.DoesNotContain(failureMechanism.ForeshoreProfiles, profile); - foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) + foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); } @@ -1152,7 +1152,7 @@ int expectedAffectedObjectCount = 1 + calculationsWithOutput.Length + calculationsWithForeshoreProfile.Length; Assert.AreEqual(expectedAffectedObjectCount, array.Length); CollectionAssert.Contains(array, failureMechanism.ForeshoreProfiles); - foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) + foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); CollectionAssert.Contains(array, calculation.InputParameters); @@ -1166,24 +1166,24 @@ } [Test] - public void RemoveForeshoreProfile_GrassCoverErosionOutwardsFailureMechanismNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_StabilityPointStructuresFailureMechanismNull_ThrowsArgumentNullException() { // Setup ForeshoreProfile profile = new TestForeshoreProfile(); // Call - void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((GrassCoverErosionOutwardsFailureMechanism) null, profile); + void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((StabilityPointStructuresFailureMechanism) null, profile); // Assert string paramName = Assert.Throws(Call).ParamName; Assert.AreEqual("failureMechanism", paramName); } [Test] - public void RemoveForeshoreProfile_GrassCoverErosionOutwardsFailureMechanismProfileNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_StabilityPointStructuresFailureMechanismProfileNull_ThrowsArgumentNullException() { // Setup - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var failureMechanism = new StabilityPointStructuresFailureMechanism(); // Call void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile(failureMechanism, null); @@ -1194,17 +1194,18 @@ } [Test] - public void RemoveForeshoreProfile_FullyConfiguredGrassCoverErosionOutwardsFailureMechanism_RemoveProfileAndClearDependentData() + public void RemoveForeshoreProfile_FullyConfiguredStabilityPointStructuresFailureMechanism_RemoveProfileAndClearDependentData() { // Setup - GrassCoverErosionOutwardsFailureMechanism failureMechanism = TestDataGenerator.GetGrassCoverErosionOutwardsFailureMechanismWithAllCalculationConfigurations(); + StabilityPointStructuresFailureMechanism failureMechanism = TestDataGenerator.GetStabilityPointStructuresFailureMechanismWithAllCalculationConfigurations(); ForeshoreProfile profile = failureMechanism.ForeshoreProfiles[0]; - GrassCoverErosionOutwardsWaveConditionsCalculation[] calculationsWithForeshoreProfile = - failureMechanism.Calculations.Cast() + StructuresCalculation[] calculationsWithForeshoreProfile = + failureMechanism.Calculations + .Cast>() .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, profile)) .ToArray(); - GrassCoverErosionOutwardsWaveConditionsCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); + StructuresCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); // Precondition CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfile); @@ -1216,7 +1217,7 @@ // 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.DoesNotContain(failureMechanism.ForeshoreProfiles, profile); - foreach (GrassCoverErosionOutwardsWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) + foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); } @@ -1225,7 +1226,7 @@ int expectedAffectedObjectCount = 1 + calculationsWithOutput.Length + calculationsWithForeshoreProfile.Length; Assert.AreEqual(expectedAffectedObjectCount, array.Length); CollectionAssert.Contains(array, failureMechanism.ForeshoreProfiles); - foreach (GrassCoverErosionOutwardsWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) + foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); CollectionAssert.Contains(array, calculation.InputParameters); @@ -1239,24 +1240,24 @@ } [Test] - public void RemoveForeshoreProfile_HeightStructuresFailureMechanismNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_StabilityStoneCoverFailureMechanismNull_ThrowsArgumentNullException() { // Setup ForeshoreProfile profile = new TestForeshoreProfile(); // Call - void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((HeightStructuresFailureMechanism) null, profile); + void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((StabilityStoneCoverFailureMechanism) null, profile); // Assert string paramName = Assert.Throws(Call).ParamName; Assert.AreEqual("failureMechanism", paramName); } [Test] - public void RemoveForeshoreProfile_HeightStructuresFailureMechanismProfileNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_StabilityStoneCoverFailureMechanismProfileNull_ThrowsArgumentNullException() { // Setup - var failureMechanism = new HeightStructuresFailureMechanism(); + var failureMechanism = new StabilityStoneCoverFailureMechanism(); // Call void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile(failureMechanism, null); @@ -1267,18 +1268,18 @@ } [Test] - public void RemoveForeshoreProfile_FullyConfiguredHeightStructuresFailureMechanism_RemoveProfileAndClearDependentData() + public void RemoveForeshoreProfile_FullyConfiguredStabilityStoneCoverFailureMechanism_RemoveProfileAndClearDependentData() { // Setup - HeightStructuresFailureMechanism failureMechanism = TestDataGenerator.GetHeightStructuresFailureMechanismWithAlLCalculationConfigurations(); + StabilityStoneCoverFailureMechanism failureMechanism = TestDataGenerator.GetStabilityStoneCoverFailureMechanismWithAllCalculationConfigurations(); ForeshoreProfile profile = failureMechanism.ForeshoreProfiles[0]; - StructuresCalculation[] calculationsWithForeshoreProfile = + StabilityStoneCoverWaveConditionsCalculation[] calculationsWithForeshoreProfile = failureMechanism.Calculations - .Cast>() + .Cast() .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, profile)) .ToArray(); - StructuresCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); + StabilityStoneCoverWaveConditionsCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); // Precondition CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfile); @@ -1290,7 +1291,7 @@ // 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.DoesNotContain(failureMechanism.ForeshoreProfiles, profile); - foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) + foreach (StabilityStoneCoverWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); } @@ -1299,7 +1300,7 @@ int expectedAffectedObjectCount = 1 + calculationsWithOutput.Length + calculationsWithForeshoreProfile.Length; Assert.AreEqual(expectedAffectedObjectCount, array.Length); CollectionAssert.Contains(array, failureMechanism.ForeshoreProfiles); - foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) + foreach (StabilityStoneCoverWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); CollectionAssert.Contains(array, calculation.InputParameters); @@ -1313,24 +1314,24 @@ } [Test] - public void RemoveForeshoreProfile_ClosingStructuresFailureMechanismNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_WaveImpactAsphaltCoverFailureMechanismNull_ThrowsArgumentNullException() { // Setup ForeshoreProfile profile = new TestForeshoreProfile(); // Call - void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((ClosingStructuresFailureMechanism) null, profile); + void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((WaveImpactAsphaltCoverFailureMechanism) null, profile); // Assert string paramName = Assert.Throws(Call).ParamName; Assert.AreEqual("failureMechanism", paramName); } [Test] - public void RemoveForeshoreProfile_ClosingStructuresFailureMechanismProfileNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_WaveImpactAsphaltCoverFailureMechanismProfileNull_ThrowsArgumentNullException() { // Setup - var failureMechanism = new ClosingStructuresFailureMechanism(); + var failureMechanism = new WaveImpactAsphaltCoverFailureMechanism(); // Call void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile(failureMechanism, null); @@ -1341,18 +1342,18 @@ } [Test] - public void RemoveForeshoreProfile_FullyConfiguredClosingStructuresFailureMechanism_RemoveProfileAndClearDependentData() + public void RemoveForeshoreProfile_FullyConfiguredWaveImpactAsphaltCoverFailureMechanism_RemoveProfileAndClearDependentData() { // Setup - ClosingStructuresFailureMechanism failureMechanism = TestDataGenerator.GetClosingStructuresFailureMechanismWithAllCalculationConfigurations(); + WaveImpactAsphaltCoverFailureMechanism failureMechanism = TestDataGenerator.GetWaveImpactAsphaltCoverFailureMechanismWithAllCalculationConfigurations(); ForeshoreProfile profile = failureMechanism.ForeshoreProfiles[0]; - StructuresCalculation[] calculationsWithForeshoreProfile = + WaveImpactAsphaltCoverWaveConditionsCalculation[] calculationsWithForeshoreProfile = failureMechanism.Calculations - .Cast>() + .Cast() .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, profile)) .ToArray(); - StructuresCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); + WaveImpactAsphaltCoverWaveConditionsCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); // Precondition CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfile); @@ -1364,7 +1365,7 @@ // 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.DoesNotContain(failureMechanism.ForeshoreProfiles, profile); - foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) + foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); } @@ -1373,7 +1374,7 @@ int expectedAffectedObjectCount = 1 + calculationsWithOutput.Length + calculationsWithForeshoreProfile.Length; Assert.AreEqual(expectedAffectedObjectCount, array.Length); CollectionAssert.Contains(array, failureMechanism.ForeshoreProfiles); - foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) + foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); CollectionAssert.Contains(array, calculation.InputParameters); @@ -1387,24 +1388,24 @@ } [Test] - public void RemoveForeshoreProfile_StabilityPointStructuresFailureMechanismNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_GrassCoverErosionOutwardsFailureMechanismNull_ThrowsArgumentNullException() { // Setup ForeshoreProfile profile = new TestForeshoreProfile(); // Call - void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((StabilityPointStructuresFailureMechanism) null, profile); + void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile((GrassCoverErosionOutwardsFailureMechanism) null, profile); // Assert string paramName = Assert.Throws(Call).ParamName; Assert.AreEqual("failureMechanism", paramName); } [Test] - public void RemoveForeshoreProfile_StabilityPointStructuresFailureMechanismProfileNull_ThrowsArgumentNullException() + public void RemoveForeshoreProfile_GrassCoverErosionOutwardsFailureMechanismProfileNull_ThrowsArgumentNullException() { // Setup - var failureMechanism = new StabilityPointStructuresFailureMechanism(); + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); // Call void Call() => RiskeerDataSynchronizationService.RemoveForeshoreProfile(failureMechanism, null); @@ -1415,18 +1416,17 @@ } [Test] - public void RemoveForeshoreProfile_FullyConfiguredStabilityPointStructuresFailureMechanism_RemoveProfileAndClearDependentData() + public void RemoveForeshoreProfile_FullyConfiguredGrassCoverErosionOutwardsFailureMechanism_RemoveProfileAndClearDependentData() { // Setup - StabilityPointStructuresFailureMechanism failureMechanism = TestDataGenerator.GetStabilityPointStructuresFailureMechanismWithAllCalculationConfigurations(); + GrassCoverErosionOutwardsFailureMechanism failureMechanism = TestDataGenerator.GetGrassCoverErosionOutwardsFailureMechanismWithAllCalculationConfigurations(); ForeshoreProfile profile = failureMechanism.ForeshoreProfiles[0]; - StructuresCalculation[] calculationsWithForeshoreProfile = - failureMechanism.Calculations - .Cast>() + GrassCoverErosionOutwardsWaveConditionsCalculation[] calculationsWithForeshoreProfile = + failureMechanism.Calculations.Cast() .Where(c => ReferenceEquals(c.InputParameters.ForeshoreProfile, profile)) .ToArray(); - StructuresCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); + GrassCoverErosionOutwardsWaveConditionsCalculation[] calculationsWithOutput = calculationsWithForeshoreProfile.Where(c => c.HasOutput).ToArray(); // Precondition CollectionAssert.IsNotEmpty(calculationsWithForeshoreProfile); @@ -1438,7 +1438,7 @@ // 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.DoesNotContain(failureMechanism.ForeshoreProfiles, profile); - foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) + foreach (GrassCoverErosionOutwardsWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); } @@ -1447,7 +1447,7 @@ int expectedAffectedObjectCount = 1 + calculationsWithOutput.Length + calculationsWithForeshoreProfile.Length; Assert.AreEqual(expectedAffectedObjectCount, array.Length); CollectionAssert.Contains(array, failureMechanism.ForeshoreProfiles); - foreach (StructuresCalculation calculation in calculationsWithForeshoreProfile) + foreach (GrassCoverErosionOutwardsWaveConditionsCalculation calculation in calculationsWithForeshoreProfile) { Assert.IsNull(calculation.InputParameters.ForeshoreProfile); CollectionAssert.Contains(array, calculation.InputParameters); @@ -1461,6 +1461,70 @@ } [Test] + public void RemoveDikeProfile_GrassCoverErosionInwardsFailureMechanismNull_ThrowsArgumentNullException() + { + // Setup + DikeProfile profile = DikeProfileTestFactory.CreateDikeProfile(); + + // Call + void Call() => RiskeerDataSynchronizationService.RemoveDikeProfile(null, profile); + + // Assert + string paramName = Assert.Throws(Call).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void RemoveDikeProfile_GrassCoverErosionInwardsFailureMechanismProfileNull_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); + + // Call + void Call() => RiskeerDataSynchronizationService.RemoveDikeProfile(failureMechanism, null); + + // Assert + string paramName = Assert.Throws(Call).ParamName; + Assert.AreEqual("profile", paramName); + } + + [Test] + public void RemoveDikeProfile_FullyConfiguredGrassCoverErosionInwardsFailureMechanism_RemoveProfileAndClearDependentData() + { + // Setup + GrassCoverErosionInwardsFailureMechanism failureMechanism = TestDataGenerator.GetGrassCoverErosionInwardsFailureMechanismWithAllCalculationConfigurations(); + DikeProfile profile = failureMechanism.DikeProfiles[0]; + GrassCoverErosionInwardsCalculation[] calculations = failureMechanism.Calculations.Cast() + .Where(c => ReferenceEquals(c.InputParameters.DikeProfile, profile)) + .ToArray(); + + // Precondition + CollectionAssert.IsNotEmpty(calculations); + + // Call + IEnumerable observables = RiskeerDataSynchronizationService.RemoveDikeProfile(failureMechanism, profile); + + // 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.DoesNotContain(failureMechanism.DikeProfiles, profile); + foreach (GrassCoverErosionInwardsCalculation calculation in calculations) + { + Assert.IsNull(calculation.InputParameters.DikeProfile); + } + + IObservable[] array = observables.ToArray(); + Assert.AreEqual(1 + (calculations.Length * 2), array.Length); + CollectionAssert.Contains(array, failureMechanism.DikeProfiles); + foreach (GrassCoverErosionInwardsCalculation calculation in calculations) + { + CollectionAssert.Contains(array, calculation); + CollectionAssert.Contains(array, calculation.InputParameters); + Assert.IsFalse(calculation.HasOutput); + } + } + + [Test] public void RemoveAllForeshoreProfiles_CalculationsNull_ThrowsArgumentNullException() { // Call @@ -1533,70 +1597,6 @@ CollectionAssert.AreEquivalent(expectedAffectedObjects, affectedObjects); } - [Test] - public void RemoveDikeProfile_GrassCoverErosionInwardsFailureMechanismNull_ThrowsArgumentNullException() - { - // Setup - DikeProfile profile = DikeProfileTestFactory.CreateDikeProfile(); - - // Call - void Call() => RiskeerDataSynchronizationService.RemoveDikeProfile(null, profile); - - // Assert - string paramName = Assert.Throws(Call).ParamName; - Assert.AreEqual("failureMechanism", paramName); - } - - [Test] - public void RemoveDikeProfile_GrassCoverErosionInwardsFailureMechanismProfileNull_ThrowsArgumentNullException() - { - // Setup - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - - // Call - void Call() => RiskeerDataSynchronizationService.RemoveDikeProfile(failureMechanism, null); - - // Assert - string paramName = Assert.Throws(Call).ParamName; - Assert.AreEqual("profile", paramName); - } - - [Test] - public void RemoveDikeProfile_FullyConfiguredGrassCoverErosionInwardsFailureMechanism_RemoveProfileAndClearDependentData() - { - // Setup - GrassCoverErosionInwardsFailureMechanism failureMechanism = TestDataGenerator.GetGrassCoverErosionInwardsFailureMechanismWithAllCalculationConfigurations(); - DikeProfile profile = failureMechanism.DikeProfiles[0]; - GrassCoverErosionInwardsCalculation[] calculations = failureMechanism.Calculations.Cast() - .Where(c => ReferenceEquals(c.InputParameters.DikeProfile, profile)) - .ToArray(); - - // Precondition - CollectionAssert.IsNotEmpty(calculations); - - // Call - IEnumerable observables = RiskeerDataSynchronizationService.RemoveDikeProfile(failureMechanism, profile); - - // 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.DoesNotContain(failureMechanism.DikeProfiles, profile); - foreach (GrassCoverErosionInwardsCalculation calculation in calculations) - { - Assert.IsNull(calculation.InputParameters.DikeProfile); - } - - IObservable[] array = observables.ToArray(); - Assert.AreEqual(1 + (calculations.Length * 2), array.Length); - CollectionAssert.Contains(array, failureMechanism.DikeProfiles); - foreach (GrassCoverErosionInwardsCalculation calculation in calculations) - { - CollectionAssert.Contains(array, calculation); - CollectionAssert.Contains(array, calculation.InputParameters); - Assert.IsFalse(calculation.HasOutput); - } - } - private static IEnumerable GetWaterLevelCalculationsForNormTargetProbabilitiesWithOutput(IAssessmentSection assessmentSection) { return assessmentSection.WaterLevelCalculationsForSignalFloodingProbability