Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs =================================================================== diff -u -ra8ffe20fbe684f5020f5158354b33fad488baac9 -rc3294111adba59fbf4a19757d1b945ec7045a19f --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision a8ffe20fbe684f5020f5158354b33fad488baac9) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.Test/ClosingStructuresInputTest.cs (.../ClosingStructuresInputTest.cs) (revision c3294111adba59fbf4a19757d1b945ec7045a19f) @@ -20,11 +20,14 @@ // All rights reserved. using System; +using System.Collections.Generic; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.HydraRing.Data; @@ -47,6 +50,13 @@ Assert.IsNull(input.HydraulicBoundaryLocation); Assert.IsNull(input.ClosingStructure); + Assert.IsNull(input.ForeshoreProfile); + 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); + AssertEqualValues(1.1, input.ModelFactorSuperCriticalFlow.Mean); AssertEqualValues(0.03, input.ModelFactorSuperCriticalFlow.StandardDeviation); AssertEqualValues(0.1, input.ThresholdHeightOpenWeir.StandardDeviation); @@ -93,6 +103,107 @@ } [Test] + [Combinatorial] + public void ForeshoreProfile_SetNewValue_InputSyncedAccordingly( + [Values(true, false)] bool withBreakWater, + [Values(true, false)] bool withValidForeshore) + { + // Setup + var input = new ClosingStructuresInput(); + BreakWaterType originalBreakWaterType = input.BreakWater.Type; + RoundedDouble originalBreakWaterHeight = input.BreakWater.Height; + HydraulicBoundaryLocation originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation; + + var foreshoreGeometry = new List + { + new Point2D(2.2, 3.3) + }; + + if (withValidForeshore) + { + foreshoreGeometry.Add(new Point2D(4.4, 5.5)); + } + + BreakWater breakWater = null; + if (withBreakWater) + { + var nonDefaultBreakWaterType = BreakWaterType.Wall; + var nonDefaultBreakWaterHeight = 5.5; + + // Precondition + Assert.AreNotEqual(nonDefaultBreakWaterType, input.BreakWater.Type); + Assert.AreNotEqual(nonDefaultBreakWaterHeight, input.BreakWater.Height); + + breakWater = new BreakWater(nonDefaultBreakWaterType, nonDefaultBreakWaterHeight); + } + + double orientation = 96; + var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + foreshoreGeometry.ToArray(), + breakWater, + new ForeshoreProfile.ConstructionProperties + { + Orientation = orientation + }); + + // Call + input.ForeshoreProfile = foreshoreProfile; + + // Assert + Assert.AreSame(foreshoreProfile, input.ForeshoreProfile); + Assert.AreEqual(withBreakWater, input.UseBreakWater); + Assert.AreEqual(withBreakWater ? foreshoreProfile.BreakWater.Type : originalBreakWaterType, input.BreakWater.Type); + Assert.AreEqual(withBreakWater ? foreshoreProfile.BreakWater.Height : originalBreakWaterHeight, input.BreakWater.Height); + Assert.AreEqual(withValidForeshore, input.UseForeshore); + CollectionAssert.AreEqual(foreshoreProfile.Geometry, input.ForeshoreGeometry); + Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + } + + [Test] + public void Foreshore_SetNullValue_InputSyncedToDefaults() + { + // Setup + var input = new ClosingStructuresInput(); + BreakWaterType originalBreakWaterType = input.BreakWater.Type; + RoundedDouble originalBreakWaterHeight = input.BreakWater.Height; + HydraulicBoundaryLocation originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation; + + var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(3.3, 4.4), + new Point2D(5.5, 6.6) + }, + new BreakWater(BreakWaterType.Caisson, 2.2), + new ForeshoreProfile.ConstructionProperties + { + Orientation = 96 + }); + + input.ForeshoreProfile = foreshoreProfile; + + // Precondition + Assert.AreSame(foreshoreProfile, input.ForeshoreProfile); + Assert.IsTrue(input.UseBreakWater); + Assert.AreNotEqual(originalBreakWaterType, input.BreakWater.Type); + Assert.AreNotEqual(originalBreakWaterHeight, input.BreakWater.Height); + Assert.IsTrue(input.UseForeshore); + CollectionAssert.IsNotEmpty(input.ForeshoreGeometry); + Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + + // Call + input.ForeshoreProfile = null; + + // Assert + Assert.IsFalse(input.UseBreakWater); + Assert.AreEqual(originalBreakWaterType, input.BreakWater.Type); + Assert.AreEqual(originalBreakWaterHeight, input.BreakWater.Height); + Assert.IsFalse(input.UseForeshore); + CollectionAssert.IsEmpty(input.ForeshoreGeometry); + Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation); + } + + [Test] public void Properties_StructureNormalOrientation_ExpectedValues() { // Setup