Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Service/GrassCoverErosionOutwardsDataSynchronizationService.cs =================================================================== diff -u -r87bd836d55d336e37e3d80f9a1521feb83ddc475 -rea8c156b28c2d2a1173f678aae5f0fb2804f0d81 --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Service/GrassCoverErosionOutwardsDataSynchronizationService.cs (.../GrassCoverErosionOutwardsDataSynchronizationService.cs) (revision 87bd836d55d336e37e3d80f9a1521feb83ddc475) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Service/GrassCoverErosionOutwardsDataSynchronizationService.cs (.../GrassCoverErosionOutwardsDataSynchronizationService.cs) (revision ea8c156b28c2d2a1173f678aae5f0fb2804f0d81) @@ -23,7 +23,6 @@ using System.Collections.Generic; using System.Linq; using Core.Common.Base; -using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Data.Calculation; using Riskeer.Common.Data.Hydraulics; using Riskeer.Common.Service; @@ -179,97 +178,6 @@ return affectedObjects; } - /// - /// Clears all the illustration point results for the design water level calculations that are relevant for the grass cover erosion - /// outwards failure mechanism. - /// - /// The to clear the - /// illustration point results for. - /// The the belongs to. - /// All objects that are affected by the operation. - /// Thrown when any parameter is null. - public static IEnumerable ClearIllustrationPointResultsForDesignWaterLevelCalculations(GrassCoverErosionOutwardsFailureMechanism failureMechanism, - IAssessmentSection assessmentSection) - { - if (failureMechanism == null) - { - throw new ArgumentNullException(nameof(failureMechanism)); - } - - if (assessmentSection == null) - { - throw new ArgumentNullException(nameof(assessmentSection)); - } - - var affectedObjects = new List(); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm)); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm)); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm)); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - assessmentSection.WaterLevelCalculationsForLowerLimitNorm)); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm)); - return affectedObjects; - } - - /// - /// Clears all the illustration point results for the wave height calculations that are relevant for the grass cover erosion - /// outwards failure mechanism. - /// - /// The to clear the - /// illustration point results for. - /// The the belongs to. - /// All objects that are affected by the operation. - /// Thrown when any parameter is null. - public static IEnumerable ClearIllustrationPointResultsForWaveHeightCalculations(GrassCoverErosionOutwardsFailureMechanism failureMechanism, - IAssessmentSection assessmentSection) - { - if (failureMechanism == null) - { - throw new ArgumentNullException(nameof(failureMechanism)); - } - - if (assessmentSection == null) - { - throw new ArgumentNullException(nameof(assessmentSection)); - } - - var affectedObjects = new List(); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm)); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm)); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm)); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - assessmentSection.WaveHeightCalculationsForLowerLimitNorm)); - affectedObjects.AddRange(RiskeerCommonDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationIllustrationPoints( - assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm)); - return affectedObjects; - } - - /// - /// Clears all the illustration point results for the design water level and wave height calculations that are relevant for the grass cover erosion - /// outwards failure mechanism. - /// - /// The to clear the - /// illustration point results for. - /// The the belongs to. - /// All objects that are affected by the operation. - /// Thrown when any parameter is null. - public static IEnumerable ClearIllustrationPointResultsForDesignWaterLevelAndWaveHeightCalculations(GrassCoverErosionOutwardsFailureMechanism failureMechanism, - IAssessmentSection assessmentSection) - { - var affectedObjects = new List(); - affectedObjects.AddRange(ClearIllustrationPointResultsForWaveHeightCalculations(failureMechanism, assessmentSection)); - affectedObjects.AddRange(ClearIllustrationPointResultsForDesignWaterLevelCalculations(failureMechanism, assessmentSection)); - - return affectedObjects; - } - private static IEnumerable ClearHydraulicBoundaryLocation(WaveConditionsInput input) { if (input.HydraulicBoundaryLocation != null) Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Service.Test/GrassCoverErosionOutwardsDataSynchronizationServiceTest.cs =================================================================== diff -u -r87bd836d55d336e37e3d80f9a1521feb83ddc475 -rea8c156b28c2d2a1173f678aae5f0fb2804f0d81 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Service.Test/GrassCoverErosionOutwardsDataSynchronizationServiceTest.cs (.../GrassCoverErosionOutwardsDataSynchronizationServiceTest.cs) (revision 87bd836d55d336e37e3d80f9a1521feb83ddc475) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Service.Test/GrassCoverErosionOutwardsDataSynchronizationServiceTest.cs (.../GrassCoverErosionOutwardsDataSynchronizationServiceTest.cs) (revision ea8c156b28c2d2a1173f678aae5f0fb2804f0d81) @@ -24,12 +24,9 @@ using System.Linq; using Core.Common.Base; using NUnit.Framework; -using Rhino.Mocks; -using Riskeer.Common.Data.AssessmentSection; using Riskeer.Common.Data.Calculation; using Riskeer.Common.Data.Hydraulics; using Riskeer.Common.Data.TestUtil; -using Riskeer.Common.Data.TestUtil.IllustrationPoints; using Riskeer.Common.Service; using Riskeer.GrassCoverErosionOutwards.Data; using Riskeer.GrassCoverErosionOutwards.Data.TestUtil; @@ -43,10 +40,10 @@ public void ClearWaveConditionsCalculation_CalculationNull_ThrowsArgumentNullException() { // Call - TestDelegate test = () => GrassCoverErosionOutwardsDataSynchronizationService.ClearWaveConditionsCalculationOutput(null); + void Call() => GrassCoverErosionOutwardsDataSynchronizationService.ClearWaveConditionsCalculationOutput(null); // Assert - var exception = Assert.Throws(test); + var exception = Assert.Throws(Call); Assert.AreEqual("calculation", exception.ParamName); } @@ -96,10 +93,10 @@ public void ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations_FailureMechanismNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => GrassCoverErosionOutwardsDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(null); + void Call() => GrassCoverErosionOutwardsDataSynchronizationService.ClearAllWaveConditionsCalculationOutputAndHydraulicBoundaryLocations(null); // Assert - var exception = Assert.Throws(call); + var exception = Assert.Throws(Call); Assert.AreEqual("failureMechanism", exception.ParamName); } @@ -136,10 +133,10 @@ public void ClearAllWaveConditionsCalculationOutput_FailureMechanismNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => GrassCoverErosionOutwardsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(null); + void Call() => GrassCoverErosionOutwardsDataSynchronizationService.ClearAllWaveConditionsCalculationOutput(null); // Assert - var exception = Assert.Throws(call); + var exception = Assert.Throws(Call); Assert.AreEqual("failureMechanism", exception.ParamName); } @@ -168,10 +165,10 @@ public void ClearReferenceLineDependentData_FailureMechanismNull_ThrowArgumentNullException() { // Call - TestDelegate call = () => GrassCoverErosionOutwardsDataSynchronizationService.ClearReferenceLineDependentData(null); + void Call() => GrassCoverErosionOutwardsDataSynchronizationService.ClearReferenceLineDependentData(null); // Assert - string paramName = Assert.Throws(call).ParamName; + string paramName = Assert.Throws(Call).ParamName; Assert.AreEqual("failureMechanism", paramName); } @@ -210,10 +207,10 @@ public void ClearHydraulicBoundaryLocationCalculationOutput_FailureMechanismNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => GrassCoverErosionOutwardsDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationOutput(null); + void Call() => GrassCoverErosionOutwardsDataSynchronizationService.ClearHydraulicBoundaryLocationCalculationOutput(null); // Assert - var exception = Assert.Throws(call); + var exception = Assert.Throws(Call); Assert.AreEqual("failureMechanism", exception.ParamName); } @@ -248,244 +245,6 @@ GrassCoverErosionOutwardsHydraulicBoundaryLocationsTestHelper.AssertHydraulicBoundaryLocationCalculationsHaveNoOutputs(failureMechanism); } - [Test] - public void ClearIllustrationPointResultsForDesignWaterLevelCalculations_FailureMechanismNull_ThrowsArgumentNullException() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - // Call - TestDelegate call = () => GrassCoverErosionOutwardsDataSynchronizationService.ClearIllustrationPointResultsForDesignWaterLevelCalculations(null, assessmentSection); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("failureMechanism", exception.ParamName); - mocks.VerifyAll(); - } - - [Test] - public void ClearIllustrationPointResultsForDesignWaterLevelCalculations_AssessmentSectionNull_ThrowsArgumentNullException() - { - // Call - TestDelegate call = () => - GrassCoverErosionOutwardsDataSynchronizationService.ClearIllustrationPointResultsForDesignWaterLevelCalculations(new GrassCoverErosionOutwardsFailureMechanism(), null); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("assessmentSection", exception.ParamName); - } - - [Test] - public void ClearIllustrationPointResultsForDesignWaterLevelCalculations_WithArguments_IllustrationPointsClearedAndAffectedItemsReturned() - { - // Setup - var assessmentSection = new AssessmentSectionStub(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - GrassCoverErosionOutwardsHydraulicBoundaryLocationsTestHelper.SetHydraulicBoundaryLocations(failureMechanism, assessmentSection, new[] - { - new TestHydraulicBoundaryLocation(), - new TestHydraulicBoundaryLocation(), - new TestHydraulicBoundaryLocation() - }); - - ConfigureHydraulicBoundaryLocationCalculationsWithIllustrationPointResults(assessmentSection, failureMechanism); - - HydraulicBoundaryLocationCalculation[] waterLevelCalculationsWithOutput = GetAllDesignWaterLevelCalculationsWithOutput(assessmentSection, failureMechanism).ToArray(); - HydraulicBoundaryLocationCalculation[] waterLevelCalculationsWithIllustrationPoints = waterLevelCalculationsWithOutput.Where(calc => calc.Output.HasGeneralResult) - .ToArray(); - - HydraulicBoundaryLocationCalculation[] waveHeightCalculationsWithOutput = GetAllWaveHeightCalculationsWithOutput(assessmentSection, failureMechanism).ToArray(); - HydraulicBoundaryLocationCalculation[] waveHeightCalculationsWithIllustrationPoints = waveHeightCalculationsWithOutput.Where(calc => calc.Output.HasGeneralResult) - .ToArray(); - - // Call - IEnumerable affectedObjects = GrassCoverErosionOutwardsDataSynchronizationService.ClearIllustrationPointResultsForDesignWaterLevelCalculations(failureMechanism, - 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_FailureMechanismNull_ThrowsArgumentNullException() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - // Call - TestDelegate call = () => GrassCoverErosionOutwardsDataSynchronizationService.ClearIllustrationPointResultsForWaveHeightCalculations(null, assessmentSection); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("failureMechanism", exception.ParamName); - mocks.VerifyAll(); - } - - [Test] - public void ClearIllustrationPointResultsForWaveHeightCalculations_AssessmentSectionNull_ThrowsArgumentNullException() - { - // Call - TestDelegate call = () => - GrassCoverErosionOutwardsDataSynchronizationService.ClearIllustrationPointResultsForWaveHeightCalculations(new GrassCoverErosionOutwardsFailureMechanism(), null); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("assessmentSection", exception.ParamName); - } - - [Test] - public void ClearIllustrationPointResultsForWaveHeightCalculations_WithArguments_IllustrationPointsClearedAndAffectedItemsReturned() - { - // Setup - var assessmentSection = new AssessmentSectionStub(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - GrassCoverErosionOutwardsHydraulicBoundaryLocationsTestHelper.SetHydraulicBoundaryLocations(failureMechanism, assessmentSection, new[] - { - new TestHydraulicBoundaryLocation(), - new TestHydraulicBoundaryLocation(), - new TestHydraulicBoundaryLocation() - }); - - ConfigureHydraulicBoundaryLocationCalculationsWithIllustrationPointResults(assessmentSection, failureMechanism); - - HydraulicBoundaryLocationCalculation[] waterLevelCalculationsWithOutput = GetAllDesignWaterLevelCalculationsWithOutput(assessmentSection, failureMechanism).ToArray(); - HydraulicBoundaryLocationCalculation[] waterLevelCalculationsWithIllustrationPoints = waterLevelCalculationsWithOutput.Where(calc => calc.Output.HasGeneralResult) - .ToArray(); - - HydraulicBoundaryLocationCalculation[] waveHeightCalculationsWithOutput = GetAllWaveHeightCalculationsWithOutput(assessmentSection, failureMechanism).ToArray(); - HydraulicBoundaryLocationCalculation[] waveHeightCalculationsWithIllustrationPoints = waveHeightCalculationsWithOutput.Where(calc => calc.Output.HasGeneralResult) - .ToArray(); - - // Call - IEnumerable affectedObjects = GrassCoverErosionOutwardsDataSynchronizationService.ClearIllustrationPointResultsForWaveHeightCalculations(failureMechanism, - 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 ClearIllustrationPointResultsForDesignWaterLevelAndWaveHeightCalculations_FailureMechanismNull_ThrowsArgumentNullException() - { - // Setup - var mocks = new MockRepository(); - var assessmentSection = mocks.Stub(); - mocks.ReplayAll(); - - // Call - TestDelegate call = () => GrassCoverErosionOutwardsDataSynchronizationService.ClearIllustrationPointResultsForDesignWaterLevelAndWaveHeightCalculations(null, assessmentSection); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("failureMechanism", exception.ParamName); - mocks.VerifyAll(); - } - - [Test] - public void ClearIllustrationPointResultsForDesignWaterLevelAndWaveHeightCalculations_AssessmentSectionNull_ThrowsArgumentNullException() - { - // Call - TestDelegate call = () => - GrassCoverErosionOutwardsDataSynchronizationService.ClearIllustrationPointResultsForDesignWaterLevelAndWaveHeightCalculations(new GrassCoverErosionOutwardsFailureMechanism(), null); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("assessmentSection", exception.ParamName); - } - - [Test] - public void ClearIllustrationPointResultsForDesignWaterLevelAndWaveHeightCalculations_WithArguments_IllustrationPointsClearedAndAffectedItemsReturned() - { - // Setup - var assessmentSection = new AssessmentSectionStub(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - GrassCoverErosionOutwardsHydraulicBoundaryLocationsTestHelper.SetHydraulicBoundaryLocations(failureMechanism, assessmentSection, new[] - { - new TestHydraulicBoundaryLocation(), - new TestHydraulicBoundaryLocation(), - new TestHydraulicBoundaryLocation() - }); - - ConfigureHydraulicBoundaryLocationCalculationsWithIllustrationPointResults(assessmentSection, failureMechanism); - - HydraulicBoundaryLocationCalculation[] calculationsWithOutput = GetAllDesignWaterLevelCalculationsWithOutput(assessmentSection, failureMechanism) - .Concat(GetAllWaveHeightCalculationsWithOutput(assessmentSection, failureMechanism)) - .ToArray(); - HydraulicBoundaryLocationCalculation[] calculationsWithIllustrationPoints = calculationsWithOutput.Where(calc => calc.Output.HasGeneralResult).ToArray(); - - // Call - IEnumerable affectedObjects = GrassCoverErosionOutwardsDataSynchronizationService.ClearIllustrationPointResultsForDesignWaterLevelAndWaveHeightCalculations(failureMechanism, - assessmentSection); - - // Assert - CollectionAssert.AreEquivalent(calculationsWithIllustrationPoints, affectedObjects); - - Assert.IsTrue(calculationsWithIllustrationPoints.All(calc => !calc.Output.HasGeneralResult)); - Assert.IsTrue(calculationsWithOutput.All(calc => calc.HasOutput)); - } - - private static IEnumerable GetAllDesignWaterLevelCalculationsWithOutput(IAssessmentSection assessmentSection, - GrassCoverErosionOutwardsFailureMechanism failureMechanism) - { - return failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm - .Concat(failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm) - .Concat(failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm) - .Concat(assessmentSection.WaterLevelCalculationsForLowerLimitNorm) - .Concat(assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm) - .Where(calc => calc.HasOutput); - } - - private static IEnumerable GetAllWaveHeightCalculationsWithOutput(IAssessmentSection assessmentSection, - GrassCoverErosionOutwardsFailureMechanism failureMechanism) - { - return failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm - .Concat(failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm) - .Concat(failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm) - .Concat(assessmentSection.WaveHeightCalculationsForLowerLimitNorm) - .Concat(assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm) - .Where(calc => calc.HasOutput); - } - - private static void ConfigureHydraulicBoundaryLocationCalculationsWithIllustrationPointResults(IAssessmentSection assessmentSection, - GrassCoverErosionOutwardsFailureMechanism failureMechanism) - { - SetHydraulicBoundaryLocationCalculationOutputConfigurations(failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm); - SetHydraulicBoundaryLocationCalculationOutputConfigurations(failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm); - SetHydraulicBoundaryLocationCalculationOutputConfigurations(failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm); - SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaterLevelCalculationsForLowerLimitNorm); - SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm); - - SetHydraulicBoundaryLocationCalculationOutputConfigurations(failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm); - SetHydraulicBoundaryLocationCalculationOutputConfigurations(failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm); - SetHydraulicBoundaryLocationCalculationOutputConfigurations(failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm); - SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaveHeightCalculationsForLowerLimitNorm); - SetHydraulicBoundaryLocationCalculationOutputConfigurations(assessmentSection.WaveHeightCalculationsForFactorizedLowerLimitNorm); - } - - private static void SetHydraulicBoundaryLocationCalculationOutputConfigurations(IObservableEnumerable calculations) - { - var random = new Random(21); - calculations.ElementAt(0).Output = null; - calculations.ElementAt(1).Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble()); - calculations.ElementAt(2).Output = new TestHydraulicBoundaryLocationCalculationOutput(random.NextDouble(), new TestGeneralResultSubMechanismIllustrationPoint()); - } - private static GrassCoverErosionOutwardsFailureMechanism CreateFullyConfiguredFailureMechanism() { var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();