Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsInputContextProperties.cs =================================================================== diff -u -rf00ef179f4b76ecd6fcfe67b1e6ea797e8525509 -r2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsInputContextProperties.cs (.../MacroStabilityInwardsInputContextProperties.cs) (revision f00ef179f4b76ecd6fcfe67b1e6ea797e8525509) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsInputContextProperties.cs (.../MacroStabilityInwardsInputContextProperties.cs) (revision 2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3) @@ -69,34 +69,38 @@ private const int settingsCategoryIndex = 3; private const int totalCategoryCount = 3; - private readonly RoundedDouble normativeAssessmentLevel; + private readonly Func getNormativeAssessmentLevelFunc; private readonly IObservablePropertyChangeHandler propertyChangeHandler; /// /// Creates a new instance of . /// /// The instance to show the properties for. - /// 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. public MacroStabilityInwardsInputContextProperties(MacroStabilityInwardsInputContext data, - RoundedDouble normativeAssessmentLevel, + Func getNormativeAssessmentLevelFunc, IObservablePropertyChangeHandler propertyChangeHandler) { if (data == null) { throw new ArgumentNullException(nameof(data)); } + if (getNormativeAssessmentLevelFunc == null) + { + throw new ArgumentNullException(nameof(getNormativeAssessmentLevelFunc)); + } + if (propertyChangeHandler == null) { throw new ArgumentNullException(nameof(this.propertyChangeHandler)); } Data = data; - this.normativeAssessmentLevel = normativeAssessmentLevel; + this.getNormativeAssessmentLevelFunc = getNormativeAssessmentLevelFunc; this.propertyChangeHandler = propertyChangeHandler; } @@ -197,7 +201,7 @@ { return data.WrappedData.UseAssessmentLevelManualInput ? data.WrappedData.AssessmentLevel - : normativeAssessmentLevel; + : getNormativeAssessmentLevelFunc(); } set { Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs =================================================================== diff -u -r7c037110f82f8b11269ece9edeef02c7f4d59c9b -r2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 7c037110f82f8b11269ece9edeef02c7f4d59c9b) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3) @@ -75,7 +75,7 @@ yield return new PropertyInfo { CreateInstance = context => new MacroStabilityInwardsInputContextProperties(context, - GetNormativeAssessmentLevel(context.AssessmentSection, context.MacroStabilityInwardsCalculation), + () => GetNormativeAssessmentLevel(context.AssessmentSection, context.MacroStabilityInwardsCalculation), new ObservablePropertyChangeHandler(context.MacroStabilityInwardsCalculation, context.WrappedData)) }; yield return new PropertyInfo Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs =================================================================== diff -u -rf00ef179f4b76ecd6fcfe67b1e6ea797e8525509 -r2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision f00ef179f4b76ecd6fcfe67b1e6ea797e8525509) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision 2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3) @@ -75,7 +75,7 @@ mocks.ReplayAll(); // Call - TestDelegate test = () => new MacroStabilityInwardsInputContextProperties(null, GetTestNormativeAssessmentLevel(), handler); + TestDelegate test = () => new MacroStabilityInwardsInputContextProperties(null, GetTestNormativeAssessmentLevel, handler); // Assert var exception = Assert.Throws(test); @@ -84,6 +84,34 @@ } [Test] + public void Constructor_GetAssessmentLevelFuncNull_ThrowArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var calculationItem = new MacroStabilityInwardsCalculationScenario(); + var failureMechanism = new MacroStabilityInwardsFailureMechanism(); + + var context = new MacroStabilityInwardsInputContext(calculationItem.InputParameters, + calculationItem, + Enumerable.Empty(), + Enumerable.Empty(), + failureMechanism, + assessmentSection); + + // Call + TestDelegate test = () => new MacroStabilityInwardsInputContextProperties(context, null, handler); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("getNormativeAssessmentLevelFunc", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] public void Constructor_PropertyChangeHandlerNull_ThrowArgumentNullException() { // Setup @@ -102,7 +130,7 @@ assessmentSection); // Call - TestDelegate test = () => new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), null); + TestDelegate test = () => new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, null); // Assert var exception = Assert.Throws(test); @@ -129,7 +157,7 @@ assessmentSection); // Call - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Assert Assert.IsInstanceOf>(properties); @@ -159,7 +187,7 @@ var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); // Call - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler) + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler) { UseAssessmentLevelManualInput = false }; @@ -302,7 +330,7 @@ var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); // Call - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler) + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler) { UseAssessmentLevelManualInput = useManualAssessmentLevelInput }; @@ -400,7 +428,7 @@ assessmentSection); // Call - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Assert RoundedDouble expectedAssessmentLevel = useManualAssessmentLevelInput @@ -449,7 +477,7 @@ assessmentSection); var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); var random = new Random(21); const double assessmentLevel = 0.36; @@ -624,7 +652,7 @@ var handler = new SetPropertyValueAfterConfirmationParameterTester(new IObservable[0]); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); MacroStabilityInwardsSoilProfile1D soilProfile = MacroStabilityInwardsSoilProfile1DTestFactory.CreateMacroStabilityInwardsSoilProfile1D(); inputParameters.StochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(0.0, soilProfile); @@ -678,7 +706,7 @@ failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call properties.SurfaceLine = testSurfaceLine; @@ -732,7 +760,7 @@ var handler = new SetPropertyValueAfterConfirmationParameterTester(new IObservable[0]); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call properties.SurfaceLine = newSurfaceLine; @@ -797,7 +825,7 @@ observable }); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call properties.StochasticSoilModel = stochasticSoilModel2; @@ -821,7 +849,7 @@ var context = new MacroStabilityInwardsInputContext(calculation.InputParameters, calculation, failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call IEnumerable surfaceLines = properties.GetAvailableSurfaceLines(); @@ -845,7 +873,7 @@ var context = new MacroStabilityInwardsInputContext(calculation.InputParameters, calculation, failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Precondition: Assert.IsNull(calculation.InputParameters.SurfaceLine); @@ -915,7 +943,7 @@ var context = new MacroStabilityInwardsInputContext(calculation.InputParameters, calculation, failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Precondition: Assert.IsNotNull(calculation.InputParameters.SurfaceLine); @@ -946,7 +974,7 @@ var context = new MacroStabilityInwardsInputContext(calculation.InputParameters, calculation, failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Precondition Assert.IsNull(calculation.InputParameters.StochasticSoilModel); @@ -985,7 +1013,7 @@ var context = new MacroStabilityInwardsInputContext(calculation.InputParameters, calculation, failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Precondition Assert.IsNotNull(calculation.InputParameters.StochasticSoilModel); @@ -1012,7 +1040,7 @@ var context = new MacroStabilityInwardsInputContext(calculation.InputParameters, calculation, failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null; @@ -1062,7 +1090,7 @@ failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // When IEnumerable availableHydraulicBoundaryLocations = @@ -1104,7 +1132,7 @@ var context = new MacroStabilityInwardsInputContext(calculation.InputParameters, calculation, failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call IEnumerable selectableHydraulicBoundaryLocations = @@ -1156,7 +1184,7 @@ var context = new MacroStabilityInwardsInputContext(calculation.InputParameters, calculation, failureMechanism.SurfaceLines, failureMechanism.StochasticSoilModels, failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call IEnumerable selectableHydraulicBoundaryLocations = @@ -1221,7 +1249,7 @@ observable }); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations() .ToList(); @@ -1271,7 +1299,7 @@ Enumerable.Empty(), failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call bool result = properties.DynamicReadOnlyValidationMethod("AssessmentLevel"); @@ -1298,7 +1326,7 @@ Enumerable.Empty(), failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call bool result = properties.DynamicReadOnlyValidationMethod("prop"); @@ -1334,7 +1362,7 @@ Enumerable.Empty(), failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call bool result = properties.DynamicVisibleValidationMethod("SelectedHydraulicBoundaryLocation"); @@ -1361,7 +1389,7 @@ Enumerable.Empty(), failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call bool result = properties.DynamicVisibleValidationMethod("prop"); @@ -1397,7 +1425,7 @@ observable }); - var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(context, GetTestNormativeAssessmentLevel, handler); // Call setProperty(properties); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs =================================================================== diff -u -rf00ef179f4b76ecd6fcfe67b1e6ea797e8525509 -r2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs) (revision f00ef179f4b76ecd6fcfe67b1e6ea797e8525509) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditorTest.cs) (revision 2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3) @@ -72,7 +72,7 @@ failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); var editor = new MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditor(); var someValue = new object(); @@ -141,7 +141,7 @@ failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, GetTestNormativeAssessmentLevel, handler); var editor = new MacroStabilityInwardsInputContextStochasticSoilModelSelectionEditor(); var someValue = new object(); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs =================================================================== diff -u -rf00ef179f4b76ecd6fcfe67b1e6ea797e8525509 -r2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision f00ef179f4b76ecd6fcfe67b1e6ea797e8525509) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditorTest.cs) (revision 2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3) @@ -73,7 +73,7 @@ failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(inputContext, GetTestNormativeAssessmentLevel, handler); var editor = new MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditor(); var someValue = new object(); @@ -142,7 +142,7 @@ failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, GetTestNormativeAssessmentLevel, handler); var editor = new MacroStabilityInwardsInputContextStochasticSoilProfileSelectionEditor(); var someValue = new object(); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextSurfaceLineSelectionEditorTest.cs =================================================================== diff -u -rf00ef179f4b76ecd6fcfe67b1e6ea797e8525509 -r2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextSurfaceLineSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextSurfaceLineSelectionEditorTest.cs) (revision f00ef179f4b76ecd6fcfe67b1e6ea797e8525509) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/UITypeEditors/MacroStabilityInwardsInputContextSurfaceLineSelectionEditorTest.cs (.../MacroStabilityInwardsInputContextSurfaceLineSelectionEditorTest.cs) (revision 2f0f4e0bd2be4afb1e2b8f5b2380c6a8abea8ad3) @@ -70,7 +70,7 @@ failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, GetTestNormativeAssessmentLevel, handler); var editor = new MacroStabilityInwardsInputContextSurfaceLineSelectionEditor(); var someValue = new object(); @@ -125,7 +125,7 @@ failureMechanism, assessmentSection); - var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, GetTestNormativeAssessmentLevel(), handler); + var properties = new MacroStabilityInwardsInputContextProperties(inputParametersContext, GetTestNormativeAssessmentLevel, handler); var editor = new MacroStabilityInwardsInputContextSurfaceLineSelectionEditor(); var someValue = new object();