Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs =================================================================== diff -u -rcf913a00f5768780ab2f8bd8d5145069581a8068 -r2db39265f9c9dd2cff6320bd9bc7f5e4bf0faa2f --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision cf913a00f5768780ab2f8bd8d5145069581a8068) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsInputTest.cs (.../GrassCoverErosionInwardsInputTest.cs) (revision 2db39265f9c9dd2cff6320bd9bc7f5e4bf0faa2f) @@ -21,6 +21,7 @@ using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Probabilistics; @@ -39,7 +40,16 @@ // Assert Assert.IsInstanceOf(input); Assert.IsInstanceOf(input); + + Assert.IsNull(input.DikeProfile); + Assert.AreEqual(new RoundedDouble(2), input.Orientation); + Assert.IsFalse(input.UseBreakWater); + Assert.AreEqual(BreakWaterType.Dam, input.BreakWater.Type); + Assert.AreEqual(new RoundedDouble(2), input.BreakWater.Height); + Assert.IsFalse(input.UseForeshore); + CollectionAssert.IsEmpty(input.ForeshoreGeometry); CollectionAssert.IsEmpty(input.DikeGeometry); + Assert.AreEqual(new RoundedDouble(2), input.DikeHeight); Assert.IsNull(input.HydraulicBoundaryLocation); var criticalFlowRate = new LogNormalDistribution(4) @@ -52,37 +62,114 @@ } [Test] - public void Properties_ExpectedValues() + [Combinatorial] + public void DikeProfile_SetNewValue_InputSyncedAccordingly( + [Values(true, false)] bool withBreakWater, + [Values(true, false)] bool withForeshore) { // Setup var input = new GrassCoverErosionInwardsInput(); - var orientation = new RoundedDouble(2, 1.18); - var logNormal = new LogNormalDistribution(2); - const bool useForeshore = true; - var breakWater = new BreakWater(BreakWaterType.Caisson, 2.2); - const bool useBreakWater = true; - RoundedDouble dikeHeight = new RoundedDouble(input.DikeHeight.NumberOfDecimalPlaces, 1.1); + var originalBreakWaterType = input.BreakWater.Type; + var originalBreakWaterHeight = input.BreakWater.Height; + var originalCriticalFlowRate = input.CriticalFlowRate; + var originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation; + var dikeProfile = new DikeProfile(new Point2D(0, 0)) + { + Orientation = (RoundedDouble) 1.1, + DikeGeometry = + { + new RoughnessPoint(new Point2D(2.2, 3.3), 0.6) + }, + CrestLevel = (RoundedDouble) 4.4 + }; + + if (withBreakWater) + { + var nonDefaultBreakWaterType = BreakWaterType.Wall; + var nonDefaultBreakWaterHeight = 5.5; + + // Precondition + Assert.AreNotEqual(nonDefaultBreakWaterType, input.BreakWater.Type); + Assert.AreNotEqual(nonDefaultBreakWaterHeight, input.BreakWater.Height); + + dikeProfile.BreakWater = new BreakWater(nonDefaultBreakWaterType, nonDefaultBreakWaterHeight); + } + + if (withForeshore) + { + dikeProfile.ForeshoreGeometry.Add(new Point2D(6.6, 7.7)); + } + // Call - input.Orientation = orientation; - input.CriticalFlowRate = logNormal; - input.DikeHeight = dikeHeight; - input.UseForeshore = useForeshore; - input.BreakWater.Type = breakWater.Type; - input.BreakWater.Height = breakWater.Height; - input.UseBreakWater = useBreakWater; + input.DikeProfile = dikeProfile; // Assert - Assert.AreEqual(dikeHeight, input.DikeHeight); - Assert.AreEqual(orientation, input.Orientation); - Assert.AreEqual(logNormal.Mean, input.CriticalFlowRate.Mean); - Assert.AreEqual(logNormal.StandardDeviation, input.CriticalFlowRate.StandardDeviation); - Assert.AreEqual(useForeshore, input.UseForeshore); - Assert.AreEqual(breakWater.Type, input.BreakWater.Type); - Assert.AreEqual(breakWater.Height, input.BreakWater.Height); - Assert.AreEqual(useBreakWater, input.UseBreakWater); - CollectionAssert.IsEmpty(input.DikeGeometry); + Assert.AreSame(dikeProfile, input.DikeProfile); + Assert.AreEqual(dikeProfile.Orientation, input.Orientation); + Assert.AreEqual(withBreakWater, input.UseBreakWater); + Assert.AreEqual(withBreakWater ? dikeProfile.BreakWater.Type : originalBreakWaterType, input.BreakWater.Type); + Assert.AreEqual(withBreakWater ? dikeProfile.BreakWater.Height : originalBreakWaterHeight, input.BreakWater.Height); + Assert.AreEqual(withForeshore, input.UseForeshore); + Assert.AreSame(dikeProfile.ForeshoreGeometry, input.ForeshoreGeometry); + Assert.AreSame(dikeProfile.DikeGeometry, input.DikeGeometry); + Assert.AreEqual(dikeProfile.CrestLevel, input.DikeHeight); + Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + Assert.AreEqual(originalCriticalFlowRate, input.CriticalFlowRate); + } + + [Test] + [Combinatorial] + public void DikeProfile_SetNullValue_InputSyncedToDefaults() + { + // Setup + var input = new GrassCoverErosionInwardsInput(); + var originalBreakWaterType = input.BreakWater.Type; + var originalBreakWaterHeight = input.BreakWater.Height; + var originalCriticalFlowRate = input.CriticalFlowRate; + var originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation; + + var dikeProfile = new DikeProfile(new Point2D(0, 0)) + { + Orientation = (RoundedDouble) 1.1, + BreakWater = new BreakWater(BreakWaterType.Caisson, 2.2), + ForeshoreGeometry = { new Point2D(3.3, 4.4) }, + DikeGeometry = + { + new RoughnessPoint(new Point2D(5.5, 6.6), 0.7) + }, + CrestLevel = (RoundedDouble) 8.8 + }; + + input.DikeProfile = dikeProfile; + + // Precondition + Assert.AreSame(dikeProfile, input.DikeProfile); + Assert.AreNotEqual(new RoundedDouble(0), input.Orientation); + Assert.IsTrue(input.UseBreakWater); + Assert.AreNotEqual(originalBreakWaterType, input.BreakWater.Type); + Assert.AreNotEqual(originalBreakWaterHeight, input.BreakWater.Height); + Assert.IsTrue(input.UseForeshore); + CollectionAssert.IsNotEmpty(input.ForeshoreGeometry); + CollectionAssert.IsNotEmpty(input.DikeGeometry); + Assert.AreNotEqual(new RoundedDouble(0), input.DikeHeight); + Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + Assert.AreEqual(originalCriticalFlowRate, input.CriticalFlowRate); + + // Call + input.DikeProfile = null; + + // Assert + Assert.AreEqual(new RoundedDouble(0), input.Orientation); + Assert.IsFalse(input.UseBreakWater); + Assert.AreEqual(originalBreakWaterType, input.BreakWater.Type); + Assert.AreEqual(originalBreakWaterHeight, input.BreakWater.Height); + Assert.IsFalse(input.UseForeshore); CollectionAssert.IsEmpty(input.ForeshoreGeometry); + CollectionAssert.IsEmpty(input.DikeGeometry); + Assert.AreEqual(new RoundedDouble(0), input.DikeHeight); + Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + Assert.AreEqual(originalCriticalFlowRate, input.CriticalFlowRate); } } } \ No newline at end of file