Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanism.cs =================================================================== diff -u -r246af7a8627ba80b1e693b6df77c69a44478d576 -r94d4a8c842278686ba4974fd35b40898d11d79af --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanism.cs (.../GrassCoverErosionOutwardsFailureMechanism.cs) (revision 246af7a8627ba80b1e693b6df77c69a44478d576) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Data/GrassCoverErosionOutwardsFailureMechanism.cs (.../GrassCoverErosionOutwardsFailureMechanism.cs) (revision 94d4a8c842278686ba4974fd35b40898d11d79af) @@ -134,7 +134,7 @@ /// /// Gets the water level calculations corresponding to the mechanism specific factorized signaling norm. /// - private IEnumerable WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm + public IEnumerable WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm { get { @@ -145,7 +145,7 @@ /// /// Gets the water level calculations corresponding to the mechanism specific signaling norm. /// - private IEnumerable WaterLevelCalculationsForMechanismSpecificSignalingNorm + public IEnumerable WaterLevelCalculationsForMechanismSpecificSignalingNorm { get { @@ -156,7 +156,7 @@ /// /// Gets the water level calculations corresponding to the mechanism specific lower limit norm. /// - private IEnumerable WaterLevelCalculationsForMechanismSpecificLowerLimitNorm + public IEnumerable WaterLevelCalculationsForMechanismSpecificLowerLimitNorm { get { @@ -167,7 +167,7 @@ /// /// Gets the wave height calculations corresponding to the mechanism specific factorized signaling norm. /// - private IEnumerable WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm + public IEnumerable WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm { get { @@ -178,7 +178,7 @@ /// /// Gets the wave height calculations corresponding to the mechanism specific signaling norm. /// - private IEnumerable WaveHeightCalculationsForMechanismSpecificSignalingNorm + public IEnumerable WaveHeightCalculationsForMechanismSpecificSignalingNorm { get { @@ -189,7 +189,7 @@ /// /// Gets the wave height calculations corresponding to the mechanism specific lower limit norm. /// - private IEnumerable WaveHeightCalculationsForMechanismSpecificLowerLimitNorm + public IEnumerable WaveHeightCalculationsForMechanismSpecificLowerLimitNorm { get { Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismTest.cs =================================================================== diff -u -rfc8446fc65eb82bb381278d8a94fd061e6278bbe -r94d4a8c842278686ba4974fd35b40898d11d79af --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismTest.cs (.../GrassCoverErosionOutwardsFailureMechanismTest.cs) (revision fc8446fc65eb82bb381278d8a94fd061e6278bbe) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Data.Test/GrassCoverErosionOutwardsFailureMechanismTest.cs (.../GrassCoverErosionOutwardsFailureMechanismTest.cs) (revision 94d4a8c842278686ba4974fd35b40898d11d79af) @@ -19,13 +19,15 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.Linq; using Core.Common.Base.Geometry; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; namespace Ringtoets.GrassCoverErosionOutwards.Data.Test @@ -51,6 +53,13 @@ CollectionAssert.IsEmpty(failureMechanism.ForeshoreProfiles); CollectionAssert.IsEmpty(failureMechanism.Sections); CollectionAssert.IsEmpty(failureMechanism.Calculations); + + CollectionAssert.IsEmpty(failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm); + CollectionAssert.IsEmpty(failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm); + CollectionAssert.IsEmpty(failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm); + CollectionAssert.IsEmpty(failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm); + CollectionAssert.IsEmpty(failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm); + CollectionAssert.IsEmpty(failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm); } [Test] @@ -125,5 +134,100 @@ Assert.IsTrue(calculations.All(c => c is GrassCoverErosionOutwardsWaveConditionsCalculation)); mocks.VerifyAll(); } + + [Test] + public void SetHydraulicBoundaryLocationCalculations_HydraulicBoundaryLocationsNull_ThrowsArgumentNullException() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + TestDelegate test = () => failureMechanism.SetHydraulicBoundaryLocationCalculations(null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("hydraulicBoundaryLocations", paramName); + } + + [Test] + public void SetHydraulicBoundaryLocationCalculations_Always_PreviousCalculationsCleared() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + failureMechanism.SetHydraulicBoundaryLocationCalculations(new HydraulicBoundaryLocation[] + { + new TestHydraulicBoundaryLocation() + }); + + // Precondition + CollectionAssert.IsNotEmpty(failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm); + CollectionAssert.IsNotEmpty(failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm); + CollectionAssert.IsNotEmpty(failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm); + CollectionAssert.IsNotEmpty(failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm); + CollectionAssert.IsNotEmpty(failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm); + CollectionAssert.IsNotEmpty(failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm); + + // Call + failureMechanism.SetHydraulicBoundaryLocationCalculations(Enumerable.Empty()); + + // Assert + CollectionAssert.IsEmpty(failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm); + CollectionAssert.IsEmpty(failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm); + CollectionAssert.IsEmpty(failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm); + CollectionAssert.IsEmpty(failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm); + CollectionAssert.IsEmpty(failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm); + CollectionAssert.IsEmpty(failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm); + } + + [Test] + public void SetHydraulicBoundaryLocationCalculations_MultipleHydraulicBoundaryLocations_SetsExpectedCalculations() + { + // Setup + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var hydraulicBoundaryLocation1 = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryLocation2 = new TestHydraulicBoundaryLocation(); + var hydraulicBoundaryLocations = new[] + { + hydraulicBoundaryLocation1, + hydraulicBoundaryLocation2 + }; + + // Call + failureMechanism.SetHydraulicBoundaryLocationCalculations(hydraulicBoundaryLocations); + + // Assert + AssertNumberOfHydraulicBoundaryLocationCalculations(failureMechanism, 2); + AssertDefaultHydraulicBoundaryLocationCalculations(failureMechanism, 0, hydraulicBoundaryLocation1); + AssertDefaultHydraulicBoundaryLocationCalculations(failureMechanism, 1, hydraulicBoundaryLocation2); + } + + private static void AssertNumberOfHydraulicBoundaryLocationCalculations(GrassCoverErosionOutwardsFailureMechanism failureMechanism, int expectedNumberOfCalculations) + { + Assert.AreEqual(expectedNumberOfCalculations, failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm.Count()); + Assert.AreEqual(expectedNumberOfCalculations, failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm.Count()); + Assert.AreEqual(expectedNumberOfCalculations, failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm.Count()); + Assert.AreEqual(expectedNumberOfCalculations, failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm.Count()); + Assert.AreEqual(expectedNumberOfCalculations, failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm.Count()); + Assert.AreEqual(expectedNumberOfCalculations, failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm.Count()); + } + + private static void AssertDefaultHydraulicBoundaryLocationCalculations(GrassCoverErosionOutwardsFailureMechanism failureMechanism, int index, HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + AssertDefaultHydraulicBoundaryLocationCalculation(failureMechanism.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm.ElementAt(index), hydraulicBoundaryLocation); + AssertDefaultHydraulicBoundaryLocationCalculation(failureMechanism.WaterLevelCalculationsForMechanismSpecificSignalingNorm.ElementAt(index), hydraulicBoundaryLocation); + AssertDefaultHydraulicBoundaryLocationCalculation(failureMechanism.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm.ElementAt(index), hydraulicBoundaryLocation); + AssertDefaultHydraulicBoundaryLocationCalculation(failureMechanism.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm.ElementAt(index), hydraulicBoundaryLocation); + AssertDefaultHydraulicBoundaryLocationCalculation(failureMechanism.WaveHeightCalculationsForMechanismSpecificSignalingNorm.ElementAt(index), hydraulicBoundaryLocation); + AssertDefaultHydraulicBoundaryLocationCalculation(failureMechanism.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm.ElementAt(index), hydraulicBoundaryLocation); + } + + private static void AssertDefaultHydraulicBoundaryLocationCalculation(HydraulicBoundaryLocationCalculation hydraulicBoundaryLocationCalculation, + HydraulicBoundaryLocation hydraulicBoundaryLocation) + { + Assert.AreSame(hydraulicBoundaryLocation, hydraulicBoundaryLocationCalculation.HydraulicBoundaryLocation); + Assert.IsNull(hydraulicBoundaryLocationCalculation.Output); + Assert.IsFalse(hydraulicBoundaryLocationCalculation.InputParameters.ShouldIllustrationPointsBeCalculated); + } } } \ No newline at end of file