Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs =================================================================== diff -u -rbb7d45597fde9aa9066da6454e833aebbea32908 -r68e845f5be49636a22c44bba2bf56396ed2d3034 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs (.../GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs) (revision bb7d45597fde9aa9066da6454e833aebbea32908) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs (.../GrassCoverErosionOutwardsWaveConditionsInputContextProperties.cs) (revision 68e845f5be49636a22c44bba2bf56396ed2d3034) @@ -46,7 +46,7 @@ public GrassCoverErosionOutwardsWaveConditionsInputContextProperties(GrassCoverErosionOutwardsWaveConditionsInputContext context, Func getNormativeAssessmentLevelFunc, IObservablePropertyChangeHandler propertyChangeHandler) - : base(context, getNormativeAssessmentLevelFunc(), propertyChangeHandler) {} + : base(context, getNormativeAssessmentLevelFunc, propertyChangeHandler) {} [ResourcesDisplayName(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsHydraulicBoundaryLocation_DesignWaterLevel_DisplayName))] [ResourcesDescription(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsWaveConditionsInputContextProperties_DesignWaterLevel_Description))] Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs =================================================================== diff -u -ra073f90798f50ba8c37b59664beddebf61db30b9 -r68e845f5be49636a22c44bba2bf56396ed2d3034 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision a073f90798f50ba8c37b59664beddebf61db30b9) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 68e845f5be49636a22c44bba2bf56396ed2d3034) @@ -69,33 +69,38 @@ private const int foreshoreGeometryPropertyIndex = 13; private const int revetmentTypePropertyIndex = 14; + private readonly Func getNormativeAssessmentLevelFunc; private readonly IObservablePropertyChangeHandler propertyChangeHandler; /// /// Creates a new instance of . /// /// The for which the properties are shown. - /// The normative assessment level. + /// for obtaining the normative assessment level. /// The handler responsible for handling effects of a property change. - /// Thrown when or - /// is null. + /// Thrown when any parameter is null. protected WaveConditionsInputContextProperties(T context, - RoundedDouble normativeAssessmentLevel, + Func getNormativeAssessmentLevelFunc, IObservablePropertyChangeHandler propertyChangeHandler) { if (context == null) { throw new ArgumentNullException(nameof(context)); } + if (getNormativeAssessmentLevelFunc == null) + { + throw new ArgumentNullException(nameof(getNormativeAssessmentLevelFunc)); + } + if (propertyChangeHandler == null) { throw new ArgumentNullException(nameof(propertyChangeHandler)); } Data = context; - AssessmentLevel = normativeAssessmentLevel; + this.getNormativeAssessmentLevelFunc = getNormativeAssessmentLevelFunc; this.propertyChangeHandler = propertyChangeHandler; } @@ -105,7 +110,10 @@ [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.AssessmentLevel_Description))] public virtual RoundedDouble AssessmentLevel { - get; + get + { + return getNormativeAssessmentLevelFunc(); + } } [PropertyOrder(upperBoundaryDesignWaterLevelPropertyIndex)] @@ -210,7 +218,7 @@ { get { - return data.WrappedData.GetWaterLevels(AssessmentLevel).ToArray(); + return data.WrappedData.GetWaterLevels(getNormativeAssessmentLevelFunc()).ToArray(); } } Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -ra073f90798f50ba8c37b59664beddebf61db30b9 -r68e845f5be49636a22c44bba2bf56396ed2d3034 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision a073f90798f50ba8c37b59664beddebf61db30b9) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 68e845f5be49636a22c44bba2bf56396ed2d3034) @@ -91,14 +91,31 @@ public void Constructor_DataNull_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new TestWaveConditionsInputContextProperties(null, GetTestNormativeAssessmentLevel(), handler); + TestDelegate test = () => new TestWaveConditionsInputContextProperties(null, GetTestNormativeAssessmentLevel, handler); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("context", paramName); } [Test] + public void Constructor_GetNormativeAssessmentLevelFuncNull_ThrowsArgumentNullException() + { + // Setup + var context = new TestWaveConditionsInputContext( + new WaveConditionsInput(), + Enumerable.Empty(), + Enumerable.Empty()); + + // Call + TestDelegate test = () => new TestWaveConditionsInputContextProperties(context, null, handler); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("getNormativeAssessmentLevelFunc", exception.ParamName); + } + + [Test] public void Constructor_PropertyChangeHandlerNull_ThrowsArgumentNullException() { // Setup @@ -108,7 +125,7 @@ Enumerable.Empty()); // Call - TestDelegate test = () => new TestWaveConditionsInputContextProperties(context, GetTestNormativeAssessmentLevel(), null); + TestDelegate test = () => new TestWaveConditionsInputContextProperties(context, GetTestNormativeAssessmentLevel, null); // Assert var exception = Assert.Throws(test); @@ -157,7 +174,7 @@ var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); // Call - var properties = new TestWaveConditionsInputContextProperties(inputContext, assessmentLevel, handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, () => assessmentLevel, handler); // Assert Assert.IsInstanceOf>(properties); @@ -210,7 +227,7 @@ }, new HydraulicBoundaryLocation[0]); // Call - var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -351,7 +368,7 @@ var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); // Call - var properties = new TestWaveConditionsInputContextProperties(inputContext, assessmentLevel, handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, () => assessmentLevel, handler); // Assert Assert.IsNotEmpty(properties.WaterLevels); @@ -445,7 +462,7 @@ var input = new WaveConditionsInput(); var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); - var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null; @@ -473,7 +490,7 @@ }; var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // Call IEnumerable availableHydraulicBoundaryLocations = @@ -503,7 +520,7 @@ ForeshoreProfile = new TestForeshoreProfile(new Point2D(200620.173572981, 503401.652985217)) }; var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], new HydraulicBoundaryLocation[0]); - var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // Call SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = properties.SelectedHydraulicBoundaryLocation; @@ -537,7 +554,7 @@ }; var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // When IEnumerable availableHydraulicBoundaryLocations = @@ -565,7 +582,7 @@ var input = new WaveConditionsInput(); var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // Call IEnumerable availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); @@ -597,7 +614,7 @@ }; var inputContext = new TestWaveConditionsInputContext(input, new ForeshoreProfile[0], locations); - var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // Call IEnumerable availableHydraulicBoundaryLocations = properties.GetSelectableHydraulicBoundaryLocations(); @@ -634,7 +651,7 @@ var otherProfile = new TestForeshoreProfile(new Point2D(0, 190)); var customHandler = new SetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); - var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), customHandler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, customHandler); IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations() .ToList(); @@ -668,7 +685,7 @@ var input = new WaveConditionsInput(); var inputContext = new TestWaveConditionsInputContext(input, locations, new HydraulicBoundaryLocation[0]); - var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new TestWaveConditionsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); // Call IEnumerable availableForeshoreProfiles = properties.GetAvailableForeshoreProfiles(); @@ -686,10 +703,8 @@ mocks.ReplayAll(); var calculation = new TestWaveConditionsCalculation(); - var input = new WaveConditionsInput - { - ForeshoreProfile = new TestForeshoreProfile() - }; + var input = new WaveConditionsInput(); + input.ForeshoreProfile = new TestForeshoreProfile(); var context = new TestWaveConditionsInputContext(input, calculation, @@ -702,7 +717,7 @@ observable }); - var properties = new TestWaveConditionsInputContextProperties(context, GetTestNormativeAssessmentLevel(), customHandler); + var properties = new TestWaveConditionsInputContextProperties(context, GetTestNormativeAssessmentLevel, customHandler); // Call setProperty(properties); @@ -720,9 +735,9 @@ private class TestWaveConditionsInputContextProperties : WaveConditionsInputContextProperties { public TestWaveConditionsInputContextProperties(WaveConditionsInputContext context, - RoundedDouble normativeAssessmentLevel, + Func getNormativeAssessmentLevelFunc, IObservablePropertyChangeHandler handler) - : base(context, normativeAssessmentLevel, handler) {} + : base(context, getNormativeAssessmentLevelFunc, handler) {} public override string RevetmentType { Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextProperties.cs =================================================================== diff -u -rbb7d45597fde9aa9066da6454e833aebbea32908 -r68e845f5be49636a22c44bba2bf56396ed2d3034 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextProperties.cs (.../StabilityStoneCoverWaveConditionsInputContextProperties.cs) (revision bb7d45597fde9aa9066da6454e833aebbea32908) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverWaveConditionsInputContextProperties.cs (.../StabilityStoneCoverWaveConditionsInputContextProperties.cs) (revision 68e845f5be49636a22c44bba2bf56396ed2d3034) @@ -45,7 +45,7 @@ public StabilityStoneCoverWaveConditionsInputContextProperties(StabilityStoneCoverWaveConditionsInputContext context, Func getNormativeAssessmentLevelFunc, IObservablePropertyChangeHandler propertyChangeHandler) - : base(context, getNormativeAssessmentLevelFunc(), propertyChangeHandler) {} + : base(context, getNormativeAssessmentLevelFunc, propertyChangeHandler) {} public override string RevetmentType { Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs =================================================================== diff -u -rbb7d45597fde9aa9066da6454e833aebbea32908 -r68e845f5be49636a22c44bba2bf56396ed2d3034 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs (.../WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs) (revision bb7d45597fde9aa9066da6454e833aebbea32908) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Forms/PropertyClasses/WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs (.../WaveImpactAsphaltCoverWaveConditionsInputContextProperties.cs) (revision 68e845f5be49636a22c44bba2bf56396ed2d3034) @@ -45,7 +45,7 @@ public WaveImpactAsphaltCoverWaveConditionsInputContextProperties(WaveImpactAsphaltCoverWaveConditionsInputContext context, Func getNormativeAssessmentLevelFunc, IObservablePropertyChangeHandler propertyChangeHandler) - : base(context, getNormativeAssessmentLevelFunc(), propertyChangeHandler) {} + : base(context, getNormativeAssessmentLevelFunc, propertyChangeHandler) {} public override string RevetmentType {