Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -227,8 +227,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.FactorStormDurationOpenStructure = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.FactorStormDurationOpenStructure = value); } } @@ -271,8 +270,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.InflowModelType = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.InflowModelType = value); } } @@ -325,12 +323,10 @@ set { ChangePropertyAndNotify( - (input, newValue) => - SetProbabilityValue( - newValue, - data.WrappedData, - (wrappedData, parsedValue) => wrappedData.FailureProbabilityOpenStructure = parsedValue), - value); + () => SetProbabilityValue( + value, + data.WrappedData, + (wrappedData, parsedValue) => wrappedData.FailureProbabilityOpenStructure = parsedValue)); } } @@ -347,12 +343,10 @@ set { ChangePropertyAndNotify( - (input, newValue) => - SetProbabilityValue( - newValue, - data.WrappedData, - (wrappedData, parsedValue) => wrappedData.FailureProbabilityReparation = parsedValue), - value); + () => SetProbabilityValue( + value, + data.WrappedData, + (wrappedData, parsedValue) => wrappedData.FailureProbabilityReparation = parsedValue)); } } @@ -368,8 +362,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.IdenticalApertures = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.IdenticalApertures = value); } } @@ -404,12 +397,10 @@ set { ChangePropertyAndNotify( - (input, newValue) => - SetProbabilityValue( - newValue, - data.WrappedData, - (wrappedData, parsedValue) => wrappedData.ProbabilityOrFrequencyOpenStructureBeforeFlooding = parsedValue), - value); + () => SetProbabilityValue( + value, + data.WrappedData, + (wrappedData, parsedValue) => wrappedData.ProbabilityOrFrequencyOpenStructureBeforeFlooding = parsedValue)); } } Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Plugin/ClosingStructuresPlugin.cs (.../ClosingStructuresPlugin.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -70,7 +70,9 @@ yield return new PropertyInfo(); yield return new PropertyInfo { - CreateInstance = context => new ClosingStructuresInputContextProperties(context, new ObservablePropertyChangeHandler(context.Calculation)) + CreateInstance = context => new ClosingStructuresInputContextProperties( + context, + new ObservablePropertyChangeHandler(context.Calculation, context.WrappedData)) }; } Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresInputContextPropertiesTest.cs (.../ClosingStructuresInputContextPropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -526,116 +526,103 @@ { RoundedDouble factor = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.FactorStormDurationOpenStructure = factor, - factor); + properties => properties.FactorStormDurationOpenStructure = factor); } [Test] public void InflowModelType_Always_InputChangedAndObsevablesNotified() { var inflowModelType = new Random(21).NextEnumValue(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.InflowModelType = inflowModelType, - inflowModelType); + properties => properties.InflowModelType = inflowModelType); } [Test] public void ProbabilityOrFrequencyOpenStructureBeforeFlooding_Always_InputChangedAndObsevablesNotified() { string probability = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ProbabilityOrFrequencyOpenStructureBeforeFlooding = probability, - probability); + properties => properties.ProbabilityOrFrequencyOpenStructureBeforeFlooding = probability); } [Test] public void FailureProbabilityOpenStructure_Always_InputChangedAndObsevablesNotified() { string probability = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.FailureProbabilityOpenStructure = probability, - probability); + properties => properties.FailureProbabilityOpenStructure = probability); } [Test] public void FailureProbabilityReparation_Always_InputChangedAndObsevablesNotified() { string probability = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.FailureProbabilityReparation = probability, - probability); + properties => properties.FailureProbabilityReparation = probability); } [Test] public void IdenticalApertures_Always_InputChangedAndObsevablesNotified() { int propertiesIdenticalApertures = new Random(21).Next(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.IdenticalApertures = propertiesIdenticalApertures, - propertiesIdenticalApertures); + properties => properties.IdenticalApertures = propertiesIdenticalApertures); } [Test] public void InsideWaterLevel_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.InsideWaterLevel.Mean = newMean, - newMean); + properties => properties.InsideWaterLevel.Mean = newMean); } [Test] public void ModelFactorSuperCriticalFlow_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ModelFactorSuperCriticalFlow.Mean = newMean, - newMean); + properties => properties.ModelFactorSuperCriticalFlow.Mean = newMean); } [Test] public void WidthFlowApertures_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.WidthFlowApertures.Mean = newMean, - newMean); + properties => properties.WidthFlowApertures.Mean = newMean); } [Test] public void ThresholdHeightOpenWeir_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ThresholdHeightOpenWeir.Mean = newMean, - newMean); + properties => properties.ThresholdHeightOpenWeir.Mean = newMean); } [Test] public void AreaFlowApertures_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.AreaFlowApertures.Mean = newMean, - newMean); + properties => properties.AreaFlowApertures.Mean = newMean); } [Test] public void DrainCoefficient_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.DrainCoefficient.Mean = newMean, - newMean); + properties => properties.DrainCoefficient.Mean = newMean); } [Test] public void LevelCrestStructureNotClosing_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.LevelCrestStructureNotClosing.Mean = newMean, - newMean); + properties => properties.LevelCrestStructureNotClosing.Mean = newMean); } [Test] @@ -658,10 +645,7 @@ const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newProbabilityString, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -693,10 +677,7 @@ assessmentSectionStub); string newProbabilityString = newValue.ToString("r", CultureInfo.CurrentCulture); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newProbabilityString, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -726,10 +707,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newValue, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -757,10 +735,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - null, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -793,10 +768,7 @@ const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newProbabilityString, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -826,10 +798,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newValue, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -857,10 +826,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - null, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -893,10 +859,7 @@ const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newProbabilityString, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -926,10 +889,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newValue, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -957,10 +917,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - null, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); // Call @@ -988,10 +945,7 @@ assessmentSectionStub); var newStructure = new TestClosingStructure(); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newStructure, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new ClosingStructuresInputContextProperties(inputContext, handler); failureMechanism.AddSection(new FailureMechanismSection("Section", new List @@ -1143,9 +1097,7 @@ Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); } - private void SetPropertyAndVerifyNotifcationsAndOutput( - Action setProperty, - TPropertyValue expectedValueSet) + private void SetPropertyAndVerifyNotifcationsAndOutput(Action setProperty) { // Setup var observable = mockRepository.StrictMock(); @@ -1157,10 +1109,7 @@ ClosingStructuresInput input = calculation.InputParameters; input.ForeshoreProfile = new TestForeshoreProfile(); - var customHandler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, - expectedValueSet, - new[] + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observable }); Index: Ringtoets/Common/src/Ringtoets.Common.Forms/ChangeHandlers/ObservablePropertyChangeHandler.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/src/Ringtoets.Common.Forms/ChangeHandlers/ObservablePropertyChangeHandler.cs (.../ObservablePropertyChangeHandler.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/ChangeHandlers/ObservablePropertyChangeHandler.cs (.../ObservablePropertyChangeHandler.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -37,26 +37,24 @@ public class ObservablePropertyChangeHandler : IObservablePropertyChangeHandler { private readonly ICalculation calculation; + private readonly ICalculationInput calculationInput; - public ObservablePropertyChangeHandler(ICalculation calculation) + public ObservablePropertyChangeHandler(ICalculation calculation, ICalculationInput calculationInput) { if (calculation == null) { throw new ArgumentNullException(nameof(calculation)); } - this.calculation = calculation; - } - - public IEnumerable SetPropertyValueAfterConfirmation( - TPropertyOwner calculationInput, - TValue value, - SetObservablePropertyValueDelegate setValue) - where TPropertyOwner : IObservable - { if (calculationInput == null) { throw new ArgumentNullException(nameof(calculationInput)); } + this.calculation = calculation; + this.calculationInput = calculationInput; + } + + public IEnumerable SetPropertyValueAfterConfirmation(SetObservablePropertyValueDelegate setValue) + { if (setValue == null) { throw new ArgumentNullException(nameof(setValue)); @@ -68,15 +66,15 @@ { if (ConfirmPropertyChange()) { - setValue(calculationInput, value); + setValue(); PropertyChanged(calculation); changedObjects.Add(calculation); changedObjects.Add(calculationInput); } } else { - setValue(calculationInput, value); + setValue(); changedObjects.Add(calculationInput); } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingDistributionPropertiesBase.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingDistributionPropertiesBase.cs (.../ConfirmingDistributionPropertiesBase.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingDistributionPropertiesBase.cs (.../ConfirmingDistributionPropertiesBase.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -104,7 +104,7 @@ throw new InvalidOperationException("Mean is set to be read-only."); } - ChangePropertyAndNotify((input, newValue) => data.Mean = newValue, value); + ChangePropertyAndNotify(() => data.Mean = value); } } @@ -124,7 +124,7 @@ throw new InvalidOperationException("StandardDeviation is set to be read-only."); } - ChangePropertyAndNotify((input, newValue) => data.StandardDeviation = newValue, value); + ChangePropertyAndNotify(() => data.StandardDeviation = value); } } @@ -142,12 +142,9 @@ return $"{Mean} ({RingtoetsCommonFormsResources.NormalDistribution_StandardDeviation_DisplayName} = {StandardDeviation})"; } - private void ChangePropertyAndNotify(SetObservablePropertyValueDelegate setPropertyValue, - RoundedDouble value) + private void ChangePropertyAndNotify(SetObservablePropertyValueDelegate setPropertyValue) { - IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(propertyOwner, - value, - setPropertyValue); + IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(setPropertyValue); NotifyAffectedObjects(affectedObjects); } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingNormalDistributionProperties.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingNormalDistributionProperties.cs (.../ConfirmingNormalDistributionProperties.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingNormalDistributionProperties.cs (.../ConfirmingNormalDistributionProperties.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -24,7 +24,6 @@ using Core.Common.Base.Data; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; -using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Forms.Properties; Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingVariationCoefficientDistributionPropertiesBase.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingVariationCoefficientDistributionPropertiesBase.cs (.../ConfirmingVariationCoefficientDistributionPropertiesBase.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ConfirmingVariationCoefficientDistributionPropertiesBase.cs (.../ConfirmingVariationCoefficientDistributionPropertiesBase.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -105,7 +105,7 @@ throw new InvalidOperationException("Mean is set to be read-only."); } - ChangePropertyAndNotify((input, newValue) => data.Mean = newValue, value); + ChangePropertyAndNotify(() => data.Mean = value); } } @@ -125,7 +125,7 @@ throw new InvalidOperationException($"{nameof(CoefficientOfVariation)} is set to be read-only."); } - ChangePropertyAndNotify((input, newValue) => data.CoefficientOfVariation = newValue, value); + ChangePropertyAndNotify(() => data.CoefficientOfVariation = value); } } @@ -149,12 +149,9 @@ $"{Mean} ({Resources.Distribution_VariationCoefficient_DisplayName} = {CoefficientOfVariation})"; } - private void ChangePropertyAndNotify(SetObservablePropertyValueDelegate setPropertyValue, - RoundedDouble value) + private void ChangePropertyAndNotify(SetObservablePropertyValueDelegate setPropertyValue) { - IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(propertyOwner, - value, - setPropertyValue); + IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(setPropertyValue); NotifyAffectedObjects(affectedObjects); } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IObservablePropertyChangeHandler.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IObservablePropertyChangeHandler.cs (.../IObservablePropertyChangeHandler.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IObservablePropertyChangeHandler.cs (.../IObservablePropertyChangeHandler.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -22,20 +22,14 @@ using System; using System.Collections.Generic; using Core.Common.Base; -using Ringtoets.Common.Data.Calculation; namespace Ringtoets.Common.Forms.PropertyClasses { /// - /// Action in which a property of the is set to the given . + /// Action in which a property is set to its new value. /// - /// The type of the owner of the property that is passed as argument. - /// The type of the value that is set on a property of the calculation input. - /// The calculation for which the property will be set. - /// The new value of the calculation input property. /// Thrown when setting the property value results in an exception being thrown. - public delegate void SetObservablePropertyValueDelegate(TPropertyOwner calculationInput, TValue value) - where TPropertyOwner : IObservable; + public delegate void SetObservablePropertyValueDelegate(); /// /// Interface for an object that can properly handle data model changes due @@ -48,21 +42,10 @@ /// the confirmation is obtained, after which the property is set if confirmation is given. If no confirmation /// was required, the value will be set for the property. /// - /// The type of the value that is set on a property of the calculation input. - /// The type of the owner of the property that is passed as argument. - /// The calculation input for which the property is supposed to be set. - /// The new value of the calculation input property. - /// The operation which is performed to set the new property - /// on the . /// All objects that are affected by setting the calculation input property. - /// Thrown when - /// or is null. + /// Thrown when is null. /// Thrown when calling results in an exception being /// thrown. - IEnumerable SetPropertyValueAfterConfirmation( - TPropertyOwner propertyOwner, - TValue value, - SetObservablePropertyValueDelegate setValue) - where TPropertyOwner : IObservable; + IEnumerable SetPropertyValueAfterConfirmation(SetObservablePropertyValueDelegate setValue); } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -216,14 +216,9 @@ /// protected abstract void AfterSettingStructure(); - protected void ChangePropertyAndNotify( - SetObservablePropertyValueDelegate setPropertyValue, - TValue value) + protected void ChangePropertyAndNotify(SetObservablePropertyValueDelegate setPropertyValue) { - IEnumerable affectedObjects = PropertyChangeHandler.SetPropertyValueAfterConfirmation( - data.WrappedData, - value, - setPropertyValue); + IEnumerable affectedObjects = PropertyChangeHandler.SetPropertyValueAfterConfirmation(setPropertyValue); NotifyAffectedObjects(affectedObjects); } @@ -344,12 +339,11 @@ } set { - ChangePropertyAndNotify((input, newValue) => - { - data.WrappedData.Structure = newValue; - AfterSettingStructure(); - }, - value); + ChangePropertyAndNotify(() => + { + data.WrappedData.Structure = value; + AfterSettingStructure(); + }); } } @@ -380,8 +374,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.StructureNormalOrientation = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.StructureNormalOrientation = value); } } @@ -483,12 +476,11 @@ set { ChangePropertyAndNotify( - (input, newValue) => - SetProbabilityValue( - newValue, - data.WrappedData, - (wrappedData, parsedValue) => wrappedData.FailureProbabilityStructureWithErosion = parsedValue) - , value); + () => SetProbabilityValue( + value, + data.WrappedData, + (wrappedData, parsedValue) => wrappedData.FailureProbabilityStructureWithErosion = parsedValue) + ); } } @@ -505,8 +497,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.ForeshoreProfile = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.ForeshoreProfile = value); } } @@ -558,8 +549,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.HydraulicBoundaryLocation = newValue.HydraulicBoundaryLocation, value); + ChangePropertyAndNotify(() => data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation); } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/UseBreakWaterProperties.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/UseBreakWaterProperties.cs (.../UseBreakWaterProperties.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/UseBreakWaterProperties.cs (.../UseBreakWaterProperties.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -86,10 +86,7 @@ } set { - IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation( - data, - value, - (input, d) => data.UseBreakWater = d); + IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(() => data.UseBreakWater = value); NotifyAffectedObjects(affectedObjects); } } @@ -109,10 +106,7 @@ { if (value.HasValue) { - IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation( - data, - value.Value, - (input, d) => data.BreakWater.Type = d); + IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(() => data.BreakWater.Type = value.Value); NotifyAffectedObjects(affectedObjects); } } @@ -131,10 +125,7 @@ } set { - IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation( - data, - value, - (input, d) => data.BreakWater.Height = d); + IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(() => data.BreakWater.Height = value); NotifyAffectedObjects(affectedObjects); } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/UseForeshoreProperties.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/UseForeshoreProperties.cs (.../UseForeshoreProperties.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/UseForeshoreProperties.cs (.../UseForeshoreProperties.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -78,10 +78,7 @@ } set { - IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation( - data, - value, - (input, d) => data.UseForeshore = d); + IEnumerable affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(() => data.UseForeshore = value); NotifyAffectedObjects(affectedObjects); } } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/ChangeHandlers/ObservablePropertyChangeHandlerTest.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/ChangeHandlers/ObservablePropertyChangeHandlerTest.cs (.../ObservablePropertyChangeHandlerTest.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/ChangeHandlers/ObservablePropertyChangeHandlerTest.cs (.../ObservablePropertyChangeHandlerTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -38,7 +38,7 @@ public void Constructor_WithCalculation_Expectedvalues() { // Call - var changeHandler = new ObservablePropertyChangeHandler(new TestCalculation()); + var changeHandler = new ObservablePropertyChangeHandler(new TestCalculation(), new TestCalculationInput()); // Assert Assert.IsInstanceOf(changeHandler); @@ -48,21 +48,18 @@ public void Constructor_CalculationNull_ThrowArgumentNullException() { // Call - TestDelegate test = () => new ObservablePropertyChangeHandler(null); + TestDelegate test = () => new ObservablePropertyChangeHandler(null, new TestCalculationInput()); // Assert var exception = Assert.Throws(test); Assert.AreEqual("calculation", exception.ParamName); } [Test] - public void SetPropertyValueAfterConfirmation_CalculationInputNull_ThrowArgumentNullException() + public void Constructor_CalculationInputNull_ThrowArgumentNullException() { - // Setup - var changeHandler = new ObservablePropertyChangeHandler(new TestCalculation()); - // Call - TestDelegate test = () => changeHandler.SetPropertyValueAfterConfirmation((TestCalculationInput)null, 3, (input, value) => { }); + TestDelegate test = () => new ObservablePropertyChangeHandler(new TestCalculation(), null); // Assert var exception = Assert.Throws(test); @@ -73,12 +70,10 @@ public void SetPropertyValueAfterConfirmation_SetValueNull_ThrowArgumentNullException() { // Setup - var changeHandler = new ObservablePropertyChangeHandler(new TestCalculation()); + var changeHandler = new ObservablePropertyChangeHandler(new TestCalculation(), new TestCalculationInput()); // Call - TestDelegate test = () => changeHandler.SetPropertyValueAfterConfirmation(new TestCalculationInput(), - 3, - null); + TestDelegate test = () => changeHandler.SetPropertyValueAfterConfirmation(null); // Assert var exception = Assert.Throws(test); @@ -109,16 +104,13 @@ var calculationInput = new TestCalculationInput(); var propertySet = 0; - var changeHandler = new ObservablePropertyChangeHandler(testCase.Calculation); + var changeHandler = new ObservablePropertyChangeHandler(testCase.Calculation, calculationInput); // Precondition Assert.AreEqual(dialogBoxWillBeShown, testCase.Calculation.HasOutput); // Call - var affectedObjects = changeHandler.SetPropertyValueAfterConfirmation( - calculationInput, - 3, - (f, v) => propertySet++); + var affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(() => propertySet++); // Assert var expectedAffectedObjects = new List(); @@ -153,16 +145,13 @@ var propertySet = 0; - var changeHandler = new ObservablePropertyChangeHandler(calculation); + var changeHandler = new ObservablePropertyChangeHandler(calculation, new TestCalculationInput()); // Precondition Assert.IsTrue(calculation.HasOutput); // Call - var affectedObjects = changeHandler.SetPropertyValueAfterConfirmation( - new TestCalculationInput(), - 3, - (f, v) => propertySet++); + var affectedObjects = changeHandler.SetPropertyValueAfterConfirmation(() => propertySet++); // Assert Assert.AreEqual(0, propertySet); @@ -182,14 +171,11 @@ TestCalculation calculation = CalculationTestHelper.CreateCalculationWithOutput(); - var changeHandler = new ObservablePropertyChangeHandler(calculation); + var changeHandler = new ObservablePropertyChangeHandler(calculation, new TestCalculationInput()); var expectedException = new Exception(); // Call - TestDelegate test = () => changeHandler.SetPropertyValueAfterConfirmation( - new TestCalculationInput(), - 3, - (f, v) => { throw expectedException; }); + TestDelegate test = () => changeHandler.SetPropertyValueAfterConfirmation(() => { throw expectedException; }); // Assert var exception = Assert.Throws(test); @@ -202,14 +188,11 @@ // Setup TestCalculation calculation = CalculationTestHelper.CreateCalculationWithoutOutput(); - var changeHandler = new ObservablePropertyChangeHandler(calculation); + var changeHandler = new ObservablePropertyChangeHandler(calculation, new TestCalculationInput()); var expectedException = new Exception(); // Call - TestDelegate test = () => changeHandler.SetPropertyValueAfterConfirmation( - new TestCalculationInput(), - 3, - (f, v) => { throw expectedException; }); + TestDelegate test = () => changeHandler.SetPropertyValueAfterConfirmation(() => { throw expectedException; }); // Assert var exception = Assert.Throws(test); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingDistributionPropertiesBaseTest.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingDistributionPropertiesBaseTest.cs (.../ConfirmingDistributionPropertiesBaseTest.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingDistributionPropertiesBaseTest.cs (.../ConfirmingDistributionPropertiesBaseTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -46,7 +46,7 @@ mocks.ReplayAll(); // Call - var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.All, distribution, null, null, null); + var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.All, distribution, null, null); // Assert Assert.IsInstanceOf>(properties); @@ -62,7 +62,7 @@ DistributionPropertiesReadOnly flags) { // Call - TestDelegate call = () => new SimpleDistributionProperties(flags, null, null, null, null); + TestDelegate call = () => new SimpleDistributionProperties(flags, null, null, null); // Assert string paramName = Assert.Throws(call).ParamName; @@ -79,11 +79,10 @@ // Setup var mocks = new MockRepository(); var distribution = mocks.Stub(); - var calculation = mocks.Stub(); mocks.ReplayAll(); // Call - TestDelegate call = () => new SimpleDistributionProperties(flags, distribution, calculation, null, null); + TestDelegate call = () => new SimpleDistributionProperties(flags, distribution, null, null); // Assert var message = "PropertyOwner required if changes are possible."; @@ -102,12 +101,11 @@ // Setup var mocks = new MockRepository(); var distribution = mocks.Stub(); - var calculation = mocks.Stub(); var input = mocks.Stub(); mocks.ReplayAll(); // Call - TestDelegate call = () => new SimpleDistributionProperties(flags, distribution, calculation, input, null); + TestDelegate call = () => new SimpleDistributionProperties(flags, distribution, input, null); // Assert var message = "Change handler required if changes are possible."; @@ -126,13 +124,12 @@ // Setup var mocks = new MockRepository(); var distribution = mocks.Stub(); - var calculation = mocks.Stub(); var input = mocks.Stub(); var handler = mocks.Stub(); mocks.ReplayAll(); // Call - var properties = new SimpleDistributionProperties(propertiesReadOnly, distribution, calculation, input, handler); + var properties = new SimpleDistributionProperties(propertiesReadOnly, distribution, input, handler); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -171,12 +168,11 @@ // Setup var mocks = new MockRepository(); var distribution = mocks.Stub(); - var calculation = mocks.Stub(); var input = mocks.Stub(); var handler = mocks.Stub(); mocks.ReplayAll(); - var properties = new SimpleDistributionProperties(propertiesReadOnly, distribution, calculation, input, handler); + var properties = new SimpleDistributionProperties(propertiesReadOnly, distribution, input, handler); // Call bool meanIsReadOnly = properties.DynamicReadOnlyValidationMethod("Mean"); @@ -199,13 +195,12 @@ distribution.Mean = new RoundedDouble(1, 1.1); distribution.StandardDeviation = new RoundedDouble(2, 2.2); - var calculation = mocks.Stub(); var input = mocks.Stub(); var handler = mocks.Stub(); mocks.ReplayAll(); // Call - var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.None, distribution, calculation, input, handler); + var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.None, distribution, input, handler); // Assert Assert.AreEqual(distribution.Mean, properties.Mean); @@ -224,15 +219,13 @@ // Setup var mocks = new MockRepository(); var distribution = mocks.Stub(); - var calculation = mocks.Stub(); var input = mocks.Stub(); var handler = mocks.Stub(); mocks.ReplayAll(); var properties = new SimpleDistributionProperties( DistributionPropertiesReadOnly.All, distribution, - calculation, input, handler); @@ -252,23 +245,20 @@ // Setup var mocks = new MockRepository(); var distribution = mocks.Stub(); - var calculation = mocks.Stub(); var input = mocks.Stub(); var observerableMock = mocks.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); var newMeanValue = new RoundedDouble(3, 20); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, newMeanValue, new[] + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observerableMock }); var properties = new SimpleDistributionProperties( DistributionPropertiesReadOnly.None, distribution, - calculation, input, handler); @@ -288,15 +278,13 @@ // Setup var mocks = new MockRepository(); var distribution = mocks.Stub(); - var calculation = mocks.Stub(); var input = mocks.Stub(); var handler = mocks.Stub(); mocks.ReplayAll(); var properties = new SimpleDistributionProperties( propertiesReadOnly, distribution, - calculation, input, handler); @@ -316,23 +304,20 @@ // Setup var mocks = new MockRepository(); var distribution = mocks.Stub(); - var calculation = mocks.Stub(); var input = mocks.Stub(); var observerableMock = mocks.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); var newStandardDeviationValue = new RoundedDouble(3, 20); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, newStandardDeviationValue, new[] + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observerableMock }); var properties = new SimpleDistributionProperties( DistributionPropertiesReadOnly.None, distribution, - calculation, input, handler); @@ -347,8 +332,9 @@ private class SimpleDistributionProperties : ConfirmingDistributionPropertiesBase { public SimpleDistributionProperties(DistributionPropertiesReadOnly propertiesReadOnly, - IDistribution distribution, ICalculation calculation, - ICalculationInput input, IObservablePropertyChangeHandler handler) + IDistribution distribution, + ICalculationInput input, + IObservablePropertyChangeHandler handler) : base(propertiesReadOnly, distribution, input, handler) {} public override string DistributionType Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingVariationCoefficientDistributionPropertiesBaseTest.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingVariationCoefficientDistributionPropertiesBaseTest.cs (.../ConfirmingVariationCoefficientDistributionPropertiesBaseTest.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ConfirmingVariationCoefficientDistributionPropertiesBaseTest.cs (.../ConfirmingVariationCoefficientDistributionPropertiesBaseTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -253,8 +253,7 @@ mocks.ReplayAll(); var newMeanValue = new RoundedDouble(3, 20); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, newMeanValue, new[] + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observerableMock }); @@ -309,8 +308,7 @@ mocks.ReplayAll(); var newCoefficientOfVariation = new RoundedDouble(3, 20); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, newCoefficientOfVariation, new[] + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observerableMock }); @@ -332,7 +330,8 @@ { public SimpleDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly, IVariationCoefficientDistribution distribution, - ICalculationInput input, IObservablePropertyChangeHandler handler) + ICalculationInput input, + IObservablePropertyChangeHandler handler) : base(propertiesReadOnly, distribution, input, handler) {} public override string DistributionType Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -560,7 +560,7 @@ var newStructure = new SimpleStructure(new Point2D(0, 190)); - ObservableSetPropertyValueAfterConfirmationParameterTester customHandler = + CalculationInputSetPropertyValueAfterConfirmationParameterTester customHandler = CreateCustomHandlerForCalculationReturningNoObservables(calculation, newStructure); var properties = new SimpleStructuresInputProperties( @@ -616,7 +616,7 @@ var properties = new SimpleStructuresInputProperties( inputContext, new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(), - new ObservablePropertyChangeHandler(inputContext.Calculation)); + new ObservablePropertyChangeHandler(inputContext.Calculation, calculation.InputParameters)); inputContext.Attach(observerMock); @@ -649,125 +649,111 @@ { var structure = new SimpleStructure(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.Structure = structure, - structure); + properties => properties.Structure = structure); } [Test] public void StructureNormalOrientation_Always_InputChangedAndObsevablesNotified() { RoundedDouble orientation = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.StructureNormalOrientation = orientation, - orientation); + properties => properties.StructureNormalOrientation = orientation); } [Test] public void FailureProbabilityStructureWithErosion_Always_InputChangedAndObsevablesNotified() { string failureProbability = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.FailureProbabilityStructureWithErosion = failureProbability, - failureProbability); + properties => properties.FailureProbabilityStructureWithErosion = failureProbability); } [Test] public void SelectedHydraulicBoundaryLocation_Always_InputChangedAndObsevablesNotified() { var location = new SelectableHydraulicBoundaryLocation(CreateHydraulicBoundaryLocation(), null); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.SelectedHydraulicBoundaryLocation = location, - location); + properties => properties.SelectedHydraulicBoundaryLocation = location); } [Test] public void ForeshoreProfile_Always_InputChangedAndObsevablesNotified() { var profile = new TestForeshoreProfile(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ForeshoreProfile = profile, - profile); + properties => properties.ForeshoreProfile = profile); } [Test] public void UseBreakWater_Always_InputChangedAndObsevablesNotified() { bool useBreakWater = new Random(21).NextBoolean(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.UseBreakWater.UseBreakWater = useBreakWater, - useBreakWater); + properties => properties.UseBreakWater.UseBreakWater = useBreakWater); } [Test] public void UseForeshore_Always_InputChangedAndObsevablesNotified() { bool useForeshore = new Random(21).NextBoolean(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.UseForeshore.UseForeshore = useForeshore, - useForeshore); + properties => properties.UseForeshore.UseForeshore = useForeshore); } [Test] public void ModelFactorSuperCriticalFlow_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ModelFactorSuperCriticalFlow.Mean = newMean, - newMean); + properties => properties.ModelFactorSuperCriticalFlow.Mean = newMean); } [Test] public void FlowWidthAtBottomProtection_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.FlowWidthAtBottomProtection.Mean = newMean, - newMean); + properties => properties.FlowWidthAtBottomProtection.Mean = newMean); } [Test] public void WidthFlowApertures_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.WidthFlowApertures.Mean = newMean, - newMean); + properties => properties.WidthFlowApertures.Mean = newMean); } [Test] public void StorageStructureArea_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.StorageStructureArea.Mean = newMean, - newMean); + properties => properties.StorageStructureArea.Mean = newMean); } [Test] public void AllowedLevelIncreaseStorage_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.AllowedLevelIncreaseStorage.Mean = newMean, - newMean); + properties => properties.AllowedLevelIncreaseStorage.Mean = newMean); } [Test] public void CriticalOvertoppingDischarge_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.CriticalOvertoppingDischarge.Mean = newMean, - newMean); + properties => properties.CriticalOvertoppingDischarge.Mean = newMean); } [Test] public void StormDuration_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.StormDuration.Mean = newMean, - newMean); + properties => properties.StormDuration.Mean = newMean); } [Test] @@ -842,7 +828,7 @@ assessmentSection); string newStringValue = newValue.ToString(CultureInfo.InvariantCulture); - ObservableSetPropertyValueAfterConfirmationParameterTester customHandler = + CalculationInputSetPropertyValueAfterConfirmationParameterTester customHandler = CreateCustomHandlerForCalculationReturningNoObservables(calculation, newStringValue); var properties = new SimpleStructuresInputProperties( @@ -874,7 +860,7 @@ failureMechanism, assessmentSection); - ObservableSetPropertyValueAfterConfirmationParameterTester customHandler = + CalculationInputSetPropertyValueAfterConfirmationParameterTester customHandler = CreateCustomHandlerForCalculationReturningNoObservables(calculation, newValue); var properties = new SimpleStructuresInputProperties( @@ -904,7 +890,7 @@ failureMechanism, assessmentSection); - ObservableSetPropertyValueAfterConfirmationParameterTester customHandler = + CalculationInputSetPropertyValueAfterConfirmationParameterTester customHandler = CreateCustomHandlerForCalculationReturningNoObservables(calculation, null); var properties = new SimpleStructuresInputProperties( @@ -922,13 +908,10 @@ mockRepository.VerifyAll(); } - private static ObservableSetPropertyValueAfterConfirmationParameterTester CreateCustomHandlerForCalculationReturningNoObservables( + private static CalculationInputSetPropertyValueAfterConfirmationParameterTester CreateCustomHandlerForCalculationReturningNoObservables( StructuresCalculation calculation, T expectedValue) { - return new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - expectedValue, - Enumerable.Empty()); + return new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); } private static StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties GetRandomConstructionProperties() @@ -1040,9 +1023,7 @@ : base(wrappedData, calculation, failureMechanism, assessmentSection) {} } - private void SetPropertyAndVerifyNotifcationsAndOutput( - Action setProperty, - TPropertyValue expectedValueSet) + private void SetPropertyAndVerifyNotifcationsAndOutput(Action setProperty) { // Setup var observable = mockRepository.StrictMock(); @@ -1053,10 +1034,7 @@ SimpleStructureInput input = calculation.InputParameters; input.ForeshoreProfile = new TestForeshoreProfile(); - var customHandler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, - expectedValueSet, - new[] + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observable }); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseBreakWaterPropertiesTest.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseBreakWaterPropertiesTest.cs (.../UseBreakWaterPropertiesTest.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseBreakWaterPropertiesTest.cs (.../UseBreakWaterPropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -202,7 +202,6 @@ { var breakWaterHeight = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.BreakWaterHeight = breakWaterHeight, - breakWaterHeight, new TestUseBreakWater()); } @@ -211,7 +210,6 @@ { var type = new Random(21).NextEnumValue(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.BreakWaterType = type, - type, new TestUseBreakWater()); } @@ -220,7 +218,6 @@ { var useBreakWater = new Random(21).NextBoolean(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.UseBreakWater = useBreakWater, - useBreakWater, new TestUseBreakWater()); } @@ -235,9 +232,8 @@ public BreakWater BreakWater { get; set; } } - private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation( + private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation( Action> setProperty, - TPropertyValue expectedValueSet, TestUseBreakWater input) { // Setup @@ -246,13 +242,10 @@ observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, - expectedValueSet, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); var properties = new UseBreakWaterProperties(input, handler); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseForeshorePropertiesTest.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseForeshorePropertiesTest.cs (.../UseForeshorePropertiesTest.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseForeshorePropertiesTest.cs (.../UseForeshorePropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -180,13 +180,11 @@ { var useForeshore = new Random(21).NextBoolean(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.UseForeshore = useForeshore, - useForeshore, new TestUseForeshore()); } - private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation( + private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation( Action> setProperty, - TPropertyValue expectedValueSet, TestUseForeshore input) { // Setup @@ -195,10 +193,7 @@ observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, - expectedValueSet, - new[] + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observable }); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/CalculationInputSetPropertyValueAfterConfirmationParameterTesterTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/CalculationInputSetPropertyValueAfterConfirmationParameterTesterTest.cs (.../CalculationInputSetPropertyValueAfterConfirmationParameterTesterTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/CalculationInputSetPropertyValueAfterConfirmationParameterTesterTest.cs (.../CalculationInputSetPropertyValueAfterConfirmationParameterTesterTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -34,77 +34,28 @@ public void Constructructed_Always_PropertiesSet() { // Setup - const double value = 3.0; - var testCalculationInput = new TestCalculationInput(); var returnedAffectedObjects = Enumerable.Empty(); // Call - var tester = new ObservableSetPropertyValueAfterConfirmationParameterTester( - testCalculationInput, value, returnedAffectedObjects); + var tester = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(returnedAffectedObjects); // Assert Assert.IsInstanceOf(tester); - Assert.AreSame(testCalculationInput, tester.ExpectedCalculationInput); - Assert.AreEqual(value, tester.ExpectedValue); Assert.AreSame(returnedAffectedObjects, tester.ReturnedAffectedObjects); Assert.IsFalse(tester.Called); } [Test] - public void SetPropertyValueAfterConfirmation_CalculationInputPassedNotSame_ThrowsAssertionException() - { - // Setup - const double value = 3.0; - var testCalculationInput = new TestCalculationInput(); - var passedCalculationInput = new TestCalculationInput(); - var returnedAffectedObjects = Enumerable.Empty(); - - var tester = new ObservableSetPropertyValueAfterConfirmationParameterTester( - testCalculationInput, value, returnedAffectedObjects); - - // Call - TestDelegate test = () => tester.SetPropertyValueAfterConfirmation(passedCalculationInput, value, (input, v) => { }); - - // Assert - Assert.Throws(test); - Assert.IsTrue(tester.Called); - } - - [Test] - public void SetPropertyValueAfterConfirmation_ValuePassedNotEqual_ThrowsAssertionException() - { - // Setup - const double expectedValue = 3.0; - const double passedValue = 2.0; - var testCalculationInput = new TestCalculationInput(); - var returnedAffectedObjects = Enumerable.Empty(); - - var tester = new ObservableSetPropertyValueAfterConfirmationParameterTester( - testCalculationInput, expectedValue, returnedAffectedObjects); - - // Call - TestDelegate test = () => tester.SetPropertyValueAfterConfirmation(testCalculationInput, passedValue, (input, v) => { }); - - // Assert - Assert.Throws(test); - Assert.IsTrue(tester.Called); - } - - [Test] public void SetPropertyValueAfterConfirmation_ParametersAreSameAndEqual_SetValueCalledReturnsGivenAffectedObjects() { // Setup - const double value = 3.0; - var returnedAffectedObjects = Enumerable.Empty(); - var testCalculationInput = new TestCalculationInput(); var called = 0; - var tester = new ObservableSetPropertyValueAfterConfirmationParameterTester( - testCalculationInput, value, returnedAffectedObjects); + var tester = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(returnedAffectedObjects); // Call - var affectedObjects = tester.SetPropertyValueAfterConfirmation(testCalculationInput, value, (m, v) => called++); + var affectedObjects = tester.SetPropertyValueAfterConfirmation(() => called++); // Assert Assert.AreEqual(1, called); @@ -116,18 +67,14 @@ public void SetPropertyValueAfterConfirmation_SetValueThrowsException_BubblesException() { // Setup - const double value = 3.0; - var returnedAffectedObjects = Enumerable.Empty(); - var testCalculationInput = new TestCalculationInput(); - var tester = new ObservableSetPropertyValueAfterConfirmationParameterTester( - testCalculationInput, value, returnedAffectedObjects); + var tester = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(returnedAffectedObjects); var expectedException = new Exception(); // Call - TestDelegate test = () => tester.SetPropertyValueAfterConfirmation(testCalculationInput, value, (input, v) => { throw expectedException; }); + TestDelegate test = () => tester.SetPropertyValueAfterConfirmation(() => { throw expectedException; }); // Assert var exception = Assert.Throws(test); Fisheye: Tag 277048d204ab4cfad4aa5de4d57ef38b56642c25 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/CalculationInputSetPropertyValueAfterConfirmationParameterTester.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/ObservableSetPropertyValueAfterConfirmationParameterTester.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/Ringtoets.Common.Forms.TestUtil.csproj =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/Ringtoets.Common.Forms.TestUtil.csproj (.../Ringtoets.Common.Forms.TestUtil.csproj) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/Ringtoets.Common.Forms.TestUtil.csproj (.../Ringtoets.Common.Forms.TestUtil.csproj) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -51,7 +51,7 @@ Properties\GlobalAssembly.cs - + Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -98,13 +98,13 @@ } set { - ChangePropertyAndNotify((input, v) => + ChangePropertyAndNotify(() => { - input.DikeProfile = v; + data.WrappedData.DikeProfile = value; GrassCoverErosionInwardsHelper.UpdateCalculationToSectionResultAssignments( data.FailureMechanism.SectionResults, data.FailureMechanism.Calculations.Cast()); - }, value); + }); } } @@ -136,8 +136,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => input.Orientation = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.Orientation = value); } } @@ -201,8 +200,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => input.DikeHeight = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.DikeHeight = value); } } @@ -219,8 +217,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => input.DikeHeightCalculationType = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.DikeHeightCalculationType = value); } } @@ -258,8 +255,7 @@ set { ChangePropertyAndNotify( - (input, newValue) => input.HydraulicBoundaryLocation = newValue, - value.HydraulicBoundaryLocation); + () => data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation); } } @@ -286,14 +282,9 @@ data.AvailableHydraulicBoundaryLocations, calculationLocation); } - private void ChangePropertyAndNotify( - SetObservablePropertyValueDelegate setPropertyValue, - TValue value) + private void ChangePropertyAndNotify(SetObservablePropertyValueDelegate setPropertyValue) { - IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( - data.WrappedData, - value, - setPropertyValue); + IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation(setPropertyValue); NotifyAffectedObjects(affectedObjects); } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/GrassCoverErosionInwardsPlugin.cs (.../GrassCoverErosionInwardsPlugin.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -70,7 +70,7 @@ { CreateInstance = context => new GrassCoverErosionInwardsInputContextProperties( context, - new ObservablePropertyChangeHandler(context.Calculation)) + new ObservablePropertyChangeHandler(context.Calculation, context.WrappedData)) }; yield return new PropertyInfo(); } Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -218,58 +218,57 @@ RoundedDouble orientation = new Random(21).NextRoundedDouble(); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.Orientation = orientation, orientation); + SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.Orientation = orientation); } [Test] public void DikeHeight_Always_InputChangedAndObsevablesNotified() { RoundedDouble dikeHeight = new Random(21).NextRoundedDouble(); - SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.DikeHeight = dikeHeight, dikeHeight); + SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.DikeHeight = dikeHeight); } [Test] public void DikeHeightCalculationType_Always_InputChangedAndObsevablesNotified() { var dikeHeightCalculationType = new Random(21).NextEnumValue(); - SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.DikeHeightCalculationType = dikeHeightCalculationType, dikeHeightCalculationType); + SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.DikeHeightCalculationType = dikeHeightCalculationType); } [Test] public void DikeProfile_Always_InputChangedAndObsevablesNotified() { var dikeProfile = new TestDikeProfile(); - SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.DikeProfile = dikeProfile, dikeProfile); + SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.DikeProfile = dikeProfile); } [Test] public void SelectedHydraulicBoundaryLocation_Always_InputChangedAndObsevablesNotified() { var selectableLocation = new SelectableHydraulicBoundaryLocation(new TestHydraulicBoundaryLocation(), new Point2D(0, 0)); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.SelectedHydraulicBoundaryLocation = selectableLocation, - selectableLocation.HydraulicBoundaryLocation); + properties => properties.SelectedHydraulicBoundaryLocation = selectableLocation); } [Test] public void BreakWater_UseBreakWaterChangedAlways_InputChangedAndObsevablesNotified() { bool useBreakWater = new Random(21).NextBoolean(); - SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.BreakWater.UseBreakWater = useBreakWater, useBreakWater); + SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.BreakWater.UseBreakWater = useBreakWater); } [Test] public void UseForeshore_Always_InputChangedAndObsevablesNotified() { bool useForeshore = new Random(21).NextBoolean(); - SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.Foreshore.UseForeshore = useForeshore, useForeshore); + SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.Foreshore.UseForeshore = useForeshore); } [Test] public void CriticalFlowRate_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble criticalFlowMean = new Random(21).NextRoundedDouble(); - SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.CriticalFlowRate.Mean = criticalFlowMean, criticalFlowMean); + SetPropertyAndVerifyNotifcationsAndOutput(properties => properties.CriticalFlowRate.Mean = criticalFlowMean); } [Test] @@ -519,7 +518,7 @@ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); var inputContext = new GrassCoverErosionInwardsInputContext(input, calculation, failureMechanism, assessmentSection); - var customHandler = new ObservableSetPropertyValueAfterConfirmationParameterTester(input, otherProfile, Enumerable.Empty()); + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new GrassCoverErosionInwardsInputContextProperties(inputContext, customHandler); IEnumerable originalList = @@ -670,9 +669,7 @@ mockRepository.VerifyAll(); } - private void SetPropertyAndVerifyNotifcationsAndOutput( - Action setProperty, - TPropertyValue expectedValueSet) + private void SetPropertyAndVerifyNotifcationsAndOutput(Action setProperty) { // Setup var observable = mockRepository.StrictMock(); @@ -685,13 +682,10 @@ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var customHandler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, - expectedValueSet, - new[] - { - observable - }); + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); var inputContext = new GrassCoverErosionInwardsInputContext(input, calculation, failureMechanism, assessmentSection); var properties = new GrassCoverErosionInwardsInputContextProperties(inputContext, customHandler); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsInputContextPropertiesIntegrationTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsInputContextPropertiesIntegrationTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesIntegrationTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Integration.Test/GrassCoverErosionInwardsInputContextPropertiesIntegrationTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesIntegrationTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -87,7 +87,7 @@ var inputContext = new GrassCoverErosionInwardsInputContext(calculation.InputParameters, calculation, failureMechanism, assessmentSection); - var customHandler = new ObservableSetPropertyValueAfterConfirmationParameterTester(calculation.InputParameters, dikeProfile2, Enumerable.Empty()); + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new GrassCoverErosionInwardsInputContextProperties(inputContext, customHandler); // Call @@ -150,7 +150,7 @@ var inputContext = new GrassCoverErosionInwardsInputContext(calculation1.InputParameters, calculation1, failureMechanism, assessmentSection); - var customHandler = new ObservableSetPropertyValueAfterConfirmationParameterTester(calculation1.InputParameters, dikeProfile2, Enumerable.Empty()); + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new GrassCoverErosionInwardsInputContextProperties(inputContext, customHandler); // Call Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -87,7 +87,9 @@ yield return new PropertyInfo { - CreateInstance = context => new GrassCoverErosionOutwardsWaveConditionsInputContextProperties(context, new ObservablePropertyChangeHandler(context.Calculation)) + CreateInstance = context => new GrassCoverErosionOutwardsWaveConditionsInputContextProperties( + context, + new ObservablePropertyChangeHandler(context.Calculation, context.WrappedData)) }; yield return new PropertyInfo(); Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresPlugin.cs (.../HeightStructuresPlugin.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -70,7 +70,9 @@ yield return new PropertyInfo(); yield return new PropertyInfo { - CreateInstance = context => new HeightStructuresInputContextProperties(context, new ObservablePropertyChangeHandler(context.Calculation)) + CreateInstance = context => new HeightStructuresInputContextProperties( + context, + new ObservablePropertyChangeHandler(context.Calculation, context.WrappedData)) }; } Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -267,10 +267,7 @@ assessmentSectionStub); var newStructure = new TestHeightStructure(); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newStructure, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new HeightStructuresInputContextProperties(inputContext, handler); failureMechanism.AddSection(new FailureMechanismSection("Section", new List @@ -293,13 +290,10 @@ { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.LevelCrestStructure.Mean = newMean, - newMean); + properties => properties.LevelCrestStructure.Mean = newMean); } - private void SetPropertyAndVerifyNotifcationsAndOutput( - Action setProperty, - TPropertyValue expectedValueSet) + private void SetPropertyAndVerifyNotifcationsAndOutput(Action setProperty) { // Setup var observable = mockRepository.StrictMock(); @@ -312,10 +306,7 @@ HeightStructuresInput input = calculation.InputParameters; input.ForeshoreProfile = new TestForeshoreProfile(); - var customHandler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, - expectedValueSet, - new[] + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observable }); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -78,7 +78,7 @@ /// The handler responsible for handling effects of a property change. /// Thrown when any parameter is null. public PipingInputContextProperties(PipingInputContext data, - IObservablePropertyChangeHandler handler) + IObservablePropertyChangeHandler handler) { if (data == null) { @@ -174,8 +174,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => input.HydraulicBoundaryLocation = newValue, value.HydraulicBoundaryLocation); + ChangePropertyAndNotify(() => data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation); } } @@ -192,8 +191,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => input.AssessmentLevel = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.AssessmentLevel = value); } } @@ -209,8 +207,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => input.UseAssessmentLevelManualInput = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.UseAssessmentLevelManualInput = value); } } @@ -279,11 +276,11 @@ { if (!ReferenceEquals(value, data.WrappedData.SurfaceLine)) { - ChangePropertyAndNotify((input, v) => + ChangePropertyAndNotify(() => { - input.SurfaceLine = v; - PipingInputService.SetMatchingStochasticSoilModel(input, GetAvailableStochasticSoilModels()); - }, value); + data.WrappedData.SurfaceLine = value; + PipingInputService.SetMatchingStochasticSoilModel(data.WrappedData, GetAvailableStochasticSoilModels()); + }); } } } @@ -303,11 +300,11 @@ { if (!ReferenceEquals(value, data.WrappedData.StochasticSoilModel)) { - ChangePropertyAndNotify((input, v) => + ChangePropertyAndNotify(() => { - input.StochasticSoilModel = v; - PipingInputService.SyncStochasticSoilProfileWithStochasticSoilModel(input); - }, value); + data.WrappedData.StochasticSoilModel = value; + PipingInputService.SyncStochasticSoilProfileWithStochasticSoilModel(data.WrappedData); + }); } } } @@ -327,7 +324,7 @@ { if (!ReferenceEquals(value, data.WrappedData.StochasticSoilProfile)) { - ChangePropertyAndNotify((input, v) => input.StochasticSoilProfile = v, value); + ChangePropertyAndNotify(() => data.WrappedData.StochasticSoilProfile = value); } } } @@ -344,7 +341,7 @@ } set { - ChangePropertyAndNotify((input, v) => input.EntryPointL = v, value); + ChangePropertyAndNotify(() => data.WrappedData.EntryPointL = value); } } @@ -360,7 +357,7 @@ } set { - ChangePropertyAndNotify((input, v) => input.ExitPointL = v, value); + ChangePropertyAndNotify(() => data.WrappedData.ExitPointL = value); } } @@ -456,17 +453,11 @@ } } - #endregion - private void ChangePropertyAndNotify( - SetObservablePropertyValueDelegate setPropertyValue, - TValue value) + private void ChangePropertyAndNotify(SetObservablePropertyValueDelegate setPropertyValue) { - IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( - data.WrappedData, - value, - setPropertyValue); + IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation(setPropertyValue); NotifyAffectedObjects(affectedObjects); } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationRow.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationRow.cs (.../PipingCalculationRow.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationRow.cs (.../PipingCalculationRow.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -97,7 +97,7 @@ StochasticSoilModel valueToSet = value?.WrappedObject; if (!ReferenceEquals(PipingCalculation.InputParameters.StochasticSoilModel, valueToSet)) { - ChangePropertyValueAndNotifyAffectedObjects((input, v) => input.StochasticSoilModel = v, valueToSet); + ChangePropertyValueAndNotifyAffectedObjects(() => PipingCalculation.InputParameters.StochasticSoilModel = valueToSet); } } } @@ -116,7 +116,7 @@ StochasticSoilProfile valueToSet = value?.WrappedObject; if (!ReferenceEquals(PipingCalculation.InputParameters.StochasticSoilProfile, valueToSet)) { - ChangePropertyValueAndNotifyAffectedObjects((input, v) => input.StochasticSoilProfile = v, valueToSet); + ChangePropertyValueAndNotifyAffectedObjects(() => PipingCalculation.InputParameters.StochasticSoilProfile = valueToSet); } } } @@ -155,7 +155,7 @@ HydraulicBoundaryLocation valueToSet = value?.WrappedObject?.HydraulicBoundaryLocation; if (!ReferenceEquals(PipingCalculation.InputParameters.HydraulicBoundaryLocation, valueToSet)) { - ChangePropertyValueAndNotifyAffectedObjects((input, v) => input.HydraulicBoundaryLocation = v, valueToSet); + ChangePropertyValueAndNotifyAffectedObjects(() => PipingCalculation.InputParameters.HydraulicBoundaryLocation = valueToSet); } } } @@ -173,7 +173,7 @@ { if (!PipingCalculation.InputParameters.DampingFactorExit.Mean.Equals(value)) { - ChangePropertyValueAndNotifyAffectedObjects((input, v) => input.DampingFactorExit.Mean = v, value); + ChangePropertyValueAndNotifyAffectedObjects(() => PipingCalculation.InputParameters.DampingFactorExit.Mean = value); } } } @@ -191,7 +191,7 @@ { if (!PipingCalculation.InputParameters.PhreaticLevelExit.Mean.Equals(value)) { - ChangePropertyValueAndNotifyAffectedObjects((input, v) => input.PhreaticLevelExit.Mean = v, value); + ChangePropertyValueAndNotifyAffectedObjects(() => PipingCalculation.InputParameters.PhreaticLevelExit.Mean = value); } } } @@ -209,7 +209,7 @@ { if (!PipingCalculation.InputParameters.EntryPointL.Equals(value)) { - ChangePropertyValueAndNotifyAffectedObjects((input, v) => input.EntryPointL = v, value); + ChangePropertyValueAndNotifyAffectedObjects(() => PipingCalculation.InputParameters.EntryPointL = value); } } } @@ -227,19 +227,14 @@ { if (!PipingCalculation.InputParameters.ExitPointL.Equals(value)) { - ChangePropertyValueAndNotifyAffectedObjects((input, v) => input.ExitPointL = v, value); + ChangePropertyValueAndNotifyAffectedObjects(() => PipingCalculation.InputParameters.ExitPointL = value); } } } - private void ChangePropertyValueAndNotifyAffectedObjects( - SetObservablePropertyValueDelegate setPropertyValue, - TValue value) + private void ChangePropertyValueAndNotifyAffectedObjects(SetObservablePropertyValueDelegate setPropertyValue) { - IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( - PipingCalculation.InputParameters, - value, - setPropertyValue); + IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation(setPropertyValue); NotifyAffectedObjects(affectedObjects); } Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -329,7 +329,7 @@ PrefillComboBoxListItemsAtColumnLevel(); - var dataSource = pipingCalculations.Select(pc => new PipingCalculationRow(pc, new ObservablePropertyChangeHandler(pc))).ToList(); + var dataSource = pipingCalculations.Select(pc => new PipingCalculationRow(pc, new ObservablePropertyChangeHandler(pc, pc.InputParameters))).ToList(); dataGridViewControl.SetDataSource(dataSource); dataGridViewControl.ClearCurrentCell(); Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs =================================================================== diff -u -r53cf7e65c1ee70a2ef0143eff830b650785bdf79 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 53cf7e65c1ee70a2ef0143eff830b650785bdf79) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingPlugin.cs (.../PipingPlugin.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -79,7 +79,7 @@ }; yield return new PropertyInfo { - CreateInstance = context => new PipingInputContextProperties(context, new ObservablePropertyChangeHandler(context.PipingCalculation)) + CreateInstance = context => new PipingInputContextProperties(context, new ObservablePropertyChangeHandler(context.PipingCalculation, context.WrappedData)) }; yield return new PropertyInfo(); yield return new PropertyInfo Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingInputContextPropertiesTest.cs (.../PipingInputContextPropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -166,7 +166,7 @@ failureMechanism, assessmentSection); - var handler = new ObservablePropertyChangeHandler(calculationItem); + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler) { @@ -338,7 +338,7 @@ failureMechanism, assessmentSection); - var handler = new ObservablePropertyChangeHandler(calculationItem); + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); // Call PipingInputContextProperties properties = new PipingInputContextProperties(context, handler) @@ -492,7 +492,7 @@ failureMechanism, assessmentSection); - var handler = new ObservablePropertyChangeHandler(calculationItem); + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); const double assessmentLevel = 0.36; @@ -547,7 +547,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(p => p.SurfaceLine = newSurfaceLine, newSurfaceLine, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(p => p.SurfaceLine = newSurfaceLine, calculation); } [Test] @@ -558,7 +558,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.StochasticSoilModel = newSoilModel, newSoilModel, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.StochasticSoilModel = newSoilModel, calculation); } [Test] @@ -569,7 +569,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.StochasticSoilProfile = newSoilProfile, newSoilProfile, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.StochasticSoilProfile = newSoilProfile, calculation); } [Test] @@ -586,7 +586,7 @@ }; // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.AssessmentLevel = newAssessmentLevel, newAssessmentLevel, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.AssessmentLevel = newAssessmentLevel, calculation); } [Test] @@ -597,7 +597,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.DampingFactorExit.Mean = mean, mean, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.DampingFactorExit.Mean = mean, calculation); } [Test] @@ -608,7 +608,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.DampingFactorExit.StandardDeviation = standardDeviation, standardDeviation, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.DampingFactorExit.StandardDeviation = standardDeviation, calculation); } [Test] @@ -619,7 +619,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.PhreaticLevelExit.Mean = mean, mean, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.PhreaticLevelExit.Mean = mean, calculation); } [Test] @@ -630,7 +630,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.PhreaticLevelExit.StandardDeviation = standardDeviation, standardDeviation, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.PhreaticLevelExit.StandardDeviation = standardDeviation, calculation); } [Test] @@ -641,7 +641,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.EntryPointL = newEntryPointL, newEntryPointL, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.EntryPointL = newEntryPointL, calculation); } [Test] @@ -652,7 +652,7 @@ var calculation = new PipingCalculationScenario(new GeneralPipingInput()); // Call & Assert - SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.ExitPointL = newExitPointL, newExitPointL, calculation); + SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.ExitPointL = newExitPointL, calculation); } [Test] @@ -663,7 +663,6 @@ // Call & Assert SetPropertyAndVerifyNotifcationsAndOutputForCalculation(properties => properties.UseAssessmentLevelManualInput = true, - true, calculation); } @@ -687,10 +686,8 @@ PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - PipingInput inputParameters = new PipingInput(new GeneralPipingInput()) - { - SurfaceLine = surfaceLine - }; + PipingInput inputParameters = calculationItem.InputParameters; + inputParameters.SurfaceLine = surfaceLine; inputParameters.Attach(inputObserver); var context = new PipingInputContext(inputParameters, @@ -700,7 +697,7 @@ failureMechanism, assessmentSection); - var handler = new ObservablePropertyChangeHandler(calculationItem); + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); // Call PipingInputContextProperties properties = new PipingInputContextProperties(context, handler) @@ -732,10 +729,8 @@ PipingCalculationScenario calculationItem = new PipingCalculationScenario(new GeneralPipingInput()); PipingFailureMechanism failureMechanism = new PipingFailureMechanism(); - PipingInput inputParameters = new PipingInput(new GeneralPipingInput()) - { - SurfaceLine = surfaceLine - }; + PipingInput inputParameters = calculationItem.InputParameters; + inputParameters.SurfaceLine = surfaceLine; inputParameters.Attach(inputObserver); var context = new PipingInputContext(inputParameters, @@ -745,7 +740,7 @@ failureMechanism, assessmentSection); - var handler = new ObservablePropertyChangeHandler(calculationItem); + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); // Call PipingInputContextProperties properties = new PipingInputContextProperties(context, handler) @@ -791,13 +786,10 @@ assessmentSection); RoundedDouble newExitPointL = (RoundedDouble) newExitPoint; - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - inputParameters, - newExitPointL, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -840,13 +832,10 @@ failureMechanism, assessmentSection); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - inputParameters, - entryPoint, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -889,13 +878,10 @@ RoundedDouble entryPointL = (RoundedDouble) (-15.0); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - inputParameters, - entryPointL, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -937,13 +923,10 @@ RoundedDouble exitPointL = (RoundedDouble) 10.0; - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - inputParameters, - exitPointL, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); var properties = new PipingInputContextProperties(context, handler); @@ -979,13 +962,10 @@ failureMechanism, assessmentSection); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculationItem.InputParameters, - hydraulicBoundaryLocation, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -1022,13 +1002,10 @@ failureMechanism, assessmentSection); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculationItem.InputParameters, - hydraulicBoundaryLocation, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -1065,7 +1042,7 @@ failureMechanism, assessmentSection); - var handler = new ObservablePropertyChangeHandler(calculationItem); + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler) { @@ -1115,13 +1092,10 @@ failureMechanism, assessmentSection); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - inputParameters, - testLevel, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -1161,7 +1135,7 @@ failureMechanism, assessmentSection); - var handler = new ObservablePropertyChangeHandler(calculationItem); + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -1210,10 +1184,7 @@ RingtoetsPipingSurfaceLine newSurfaceLine = ValidSurfaceLine(0, 2); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - inputParameters, - newSurfaceLine, - new IObservable[0]); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new IObservable[0]); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -1317,10 +1288,7 @@ RingtoetsPipingSurfaceLine newSurfaceLine = ValidSurfaceLine(0, 2); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - inputParameters, - newSurfaceLine, - new IObservable[0]); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new IObservable[0]); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -1374,13 +1342,10 @@ failureMechanism, assessmentSection); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - inputParameters, - stochasticSoilModel2, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); PipingInputContextProperties properties = new PipingInputContextProperties(context, handler); @@ -1412,7 +1377,7 @@ failureMechanism, assessmentSection); - var handler = new ObservablePropertyChangeHandler(calculationItem); + var handler = new ObservablePropertyChangeHandler(calculationItem, calculationItem.InputParameters); PipingInputContextProperties contextProperties = new PipingInputContextProperties(context, handler); inputParameters.HydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(1.0); @@ -1849,13 +1814,10 @@ var newSurfaceLine = ValidSurfaceLine(0.0, 5.0); newSurfaceLine.ReferenceLineIntersectionWorldPoint = new Point2D(0, 190); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newSurfaceLine, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); var properties = new PipingInputContextProperties(context, handler); @@ -2006,9 +1968,8 @@ Assert.IsFalse(result); } - private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation( + private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation( Action setProperty, - TPropertyValue expectedValueSet, PipingCalculationScenario calculation) { // Setup @@ -2029,13 +1990,10 @@ failureMechanism, assessmentSection); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - inputParameters, - expectedValueSet, - new[] - { - observable - }); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); var properties = new PipingInputContextProperties(context, handler); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs (.../PipingCalculationRowTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs (.../PipingCalculationRowTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -361,8 +361,7 @@ // Call & Assert const string expectedMessage = "Het uittredepunt moet landwaarts van het intredepunt liggen."; - SetPropertyToInvalidValueAndVerifyException(row => row.EntryPointL = entryPointL, - entryPointL, calculation, + SetPropertyToInvalidValueAndVerifyException(row => row.EntryPointL = entryPointL, calculation, expectedMessage); } @@ -376,8 +375,7 @@ // Call & Assert const string expectedMessage = "Het gespecificeerde punt moet op het profiel liggen (bereik [0,0, 1,0])."; - SetPropertyToInvalidValueAndVerifyException(row => row.EntryPointL = entryPointL, - entryPointL, calculation, + SetPropertyToInvalidValueAndVerifyException(row => row.EntryPointL = entryPointL, calculation, expectedMessage); } @@ -425,8 +423,7 @@ // Call & Assert const string expectedMessage = "Het uittredepunt moet landwaarts van het intredepunt liggen."; - SetPropertyToInvalidValueAndVerifyException(row => row.ExitPointL = exitPointL, - exitPointL, calculation, + SetPropertyToInvalidValueAndVerifyException(row => row.ExitPointL = exitPointL, calculation, expectedMessage); } @@ -440,8 +437,7 @@ // Call & Assert const string expectedMessage = "Het gespecificeerde punt moet op het profiel liggen (bereik [0,0, 1,0])."; - SetPropertyToInvalidValueAndVerifyException(row => row.ExitPointL = exitPointL, - exitPointL, calculation, + SetPropertyToInvalidValueAndVerifyException(row => row.ExitPointL = exitPointL, calculation, expectedMessage); } @@ -512,9 +508,8 @@ mockRepository.VerifyAll(); } - private static void SetPropertyToInvalidValueAndVerifyException( + private static void SetPropertyToInvalidValueAndVerifyException( Action setProperty, - TPropertyValue value, PipingCalculationScenario calculation, string expectedMessage) { @@ -523,10 +518,7 @@ var observable = mocks.StrictMock(); mocks.ReplayAll(); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - value, - new[] + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observable }); @@ -553,10 +545,7 @@ observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - value, - new[] + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] { observable }); Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -507,14 +507,9 @@ PipingFailureMechanism failureMechanism = ConfigureFailuremechanism(); CalculationGroup calculationGroup = ConfigureCalculationGroup(assessmentSection, failureMechanism); - PipingCalculationScenario calculation = (PipingCalculationScenario) calculationGroup.Children.First(); - RoundedDouble newRoundedvalue = (RoundedDouble) newValue; - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newRoundedvalue, - new IObservable[0]); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new IObservable[0]); using (ShowFullyConfiguredPipingCalculationsView(assessmentSection, failureMechanism, calculationGroup, handler)) { @@ -1074,10 +1069,7 @@ RoundedDouble value = (RoundedDouble) newValue; - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - value, - new Observable[] + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new Observable[] { calculation.InputParameters, calculation @@ -1123,12 +1115,7 @@ CalculationGroup calculationGroup = ConfigureCalculationGroup(assessmentSection, failureMechanism); PipingCalculationScenario calculation = (PipingCalculationScenario) calculationGroup.Children.First(); - RoundedDouble value = (RoundedDouble) newValue; - - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - value, - new Observable[] + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new Observable[] { calculation.InputParameters, calculation Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -127,7 +127,7 @@ } set { - ChangePropertyAndNotify((input, newValue) => input.UpperBoundaryRevetment = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.UpperBoundaryRevetment = value); } } @@ -143,7 +143,7 @@ } set { - ChangePropertyAndNotify((input, newValue) => input.LowerBoundaryRevetment = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.LowerBoundaryRevetment = value); } } @@ -159,7 +159,7 @@ } set { - ChangePropertyAndNotify((input, newValue) => input.UpperBoundaryWaterLevels = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.UpperBoundaryWaterLevels = value); } } @@ -175,7 +175,7 @@ } set { - ChangePropertyAndNotify((input, newValue) => input.LowerBoundaryWaterLevels = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.LowerBoundaryWaterLevels = value); } } @@ -192,7 +192,7 @@ } set { - ChangePropertyAndNotify((input, newValue) => input.StepSize = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.StepSize = value); } } @@ -236,7 +236,7 @@ } set { - ChangePropertyAndNotify((input, newValue) => input.Orientation = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.Orientation = value); } } @@ -287,7 +287,7 @@ } set { - ChangePropertyAndNotify((input, newValue) => input.ForeshoreProfile = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.ForeshoreProfile = value); } } @@ -308,7 +308,7 @@ } set { - ChangePropertyAndNotify((input, newValue) => input.HydraulicBoundaryLocation = newValue.HydraulicBoundaryLocation, value); + ChangePropertyAndNotify(() => data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation); } } @@ -324,14 +324,9 @@ data.HydraulicBoundaryLocations, referenceLocation); } - private void ChangePropertyAndNotify( - SetObservablePropertyValueDelegate setPropertyValue, - TValue value) + private void ChangePropertyAndNotify(SetObservablePropertyValueDelegate setPropertyValue) { - IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( - data.WrappedData, - value, - setPropertyValue); + IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation(setPropertyValue); NotifyAffectedObjects(affectedObjects); } Index: Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/Revetment/test/Ringtoets.Revetment.Forms.Test/PropertyClasses/WaveConditionsInputContextPropertiesTest.cs (.../WaveConditionsInputContextPropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -330,89 +330,79 @@ var propertiesSelectedHydraulicBoundaryLocation = new SelectableHydraulicBoundaryLocation( new TestHydraulicBoundaryLocation(), new Point2D(0, 0)); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.SelectedHydraulicBoundaryLocation = propertiesSelectedHydraulicBoundaryLocation, - propertiesSelectedHydraulicBoundaryLocation); + properties => properties.SelectedHydraulicBoundaryLocation = propertiesSelectedHydraulicBoundaryLocation); } [Test] public void ForeshoreProfile_Always_InputChangedAndObsevablesNotified() { var foreshoreProfile = new TestForeshoreProfile(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.ForeshoreProfile = foreshoreProfile, - foreshoreProfile); + properties => properties.ForeshoreProfile = foreshoreProfile); } [Test] public void LowerBoundaryRevetment_Always_InputChangedAndObsevablesNotified() { RoundedDouble lowerBoundaryRevetment = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.LowerBoundaryRevetment = lowerBoundaryRevetment, - lowerBoundaryRevetment); + properties => properties.LowerBoundaryRevetment = lowerBoundaryRevetment); } [Test] public void UpperBoundaryRevetment_Always_InputChangedAndObsevablesNotified() { RoundedDouble upperBoundaryRevetment = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.UpperBoundaryRevetment = upperBoundaryRevetment, - upperBoundaryRevetment); + properties => properties.UpperBoundaryRevetment = upperBoundaryRevetment); } [Test] public void LowerBoundaryWaterLevels_Always_InputChangedAndObsevablesNotified() { RoundedDouble lowerBoundaryWaterLevels = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.LowerBoundaryWaterLevels = lowerBoundaryWaterLevels, - lowerBoundaryWaterLevels); + properties => properties.LowerBoundaryWaterLevels = lowerBoundaryWaterLevels); } [Test] public void UpperBoundaryWaterLevels_Always_InputChangedAndObsevablesNotified() { RoundedDouble upperBoundaryWaterLevels = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.UpperBoundaryWaterLevels = upperBoundaryWaterLevels, - upperBoundaryWaterLevels); + properties => properties.UpperBoundaryWaterLevels = upperBoundaryWaterLevels); } [Test] public void StepSize_Always_InputChangedAndObsevablesNotified() { var waveConditionsInputStepSize = new Random(21).NextEnumValue(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.StepSize = waveConditionsInputStepSize, - waveConditionsInputStepSize); + properties => properties.StepSize = waveConditionsInputStepSize); } [Test] public void Orientation_Always_InputChangedAndObsevablesNotified() { RoundedDouble upperBoundaryDesignWaterLevel = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.Orientation = upperBoundaryDesignWaterLevel, - upperBoundaryDesignWaterLevel); + properties => properties.Orientation = upperBoundaryDesignWaterLevel); } [Test] public void UseBreakWater_Always_InputChangedAndObsevablesNotified() { bool breakWaterUseBreakWater = new Random(21).NextBoolean(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.BreakWater.UseBreakWater = breakWaterUseBreakWater, - breakWaterUseBreakWater); + properties => properties.BreakWater.UseBreakWater = breakWaterUseBreakWater); } [Test] public void UseForeshore_Always_InputChangedAndObsevablesNotified() { bool foreshoreGeometryUseForeshore = new Random(21).NextBoolean(); SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - properties => properties.ForeshoreGeometry.UseForeshore = foreshoreGeometryUseForeshore, - foreshoreGeometryUseForeshore); + properties => properties.ForeshoreGeometry.UseForeshore = foreshoreGeometryUseForeshore); } [Test] @@ -609,7 +599,7 @@ var inputContext = new TestWaveConditionsInputContext(input, calculation, new ForeshoreProfile[0], locations); var otherProfile = new TestForeshoreProfile(new Point2D(0, 190)); - var customHandler = new ObservableSetPropertyValueAfterConfirmationParameterTester(input, otherProfile, Enumerable.Empty()); + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new TestWaveConditionsInputContextProperties(inputContext, customHandler); IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations() @@ -652,10 +642,8 @@ // Assert Assert.AreSame(locations, availableForeshoreProfiles); } - - private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation( - Action setProperty, - TPropertyValue expectedValueSet) + + private void SetPropertyAndVerifyNotifcationsAndOutputForCalculation(Action setProperty) { // Setup var mocks = new MockRepository(); @@ -668,25 +656,22 @@ input.ForeshoreProfile = new TestForeshoreProfile(); var context = new TestWaveConditionsInputContext(input, - calculation, - new ForeshoreProfile[0], - new HydraulicBoundaryLocation[0]); + calculation, + new ForeshoreProfile[0], + new HydraulicBoundaryLocation[0]); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, - expectedValueSet, - new[] - { - observable - }); + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); - var properties = new TestWaveConditionsInputContextProperties(context, handler); + var properties = new TestWaveConditionsInputContextProperties(context, customHandler); // Call setProperty(properties); // Assert - Assert.IsTrue(handler.Called); + Assert.IsTrue(customHandler.Called); mocks.VerifyAll(); } Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs =================================================================== diff -u -rb41ef82a44c84f0211937d1b7f22794ad8a45941 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision b41ef82a44c84f0211937d1b7f22794ad8a45941) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -29,7 +29,6 @@ using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Structures; -using Ringtoets.Common.Forms.ChangeHandlers; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Utils; @@ -196,8 +195,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.VolumicWeightWater = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.VolumicWeightWater = value); } } @@ -278,8 +276,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.FactorStormDurationOpenStructure = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.FactorStormDurationOpenStructure = value); } } @@ -309,8 +306,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.InflowModelType = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.InflowModelType = value); } } @@ -327,8 +323,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.LoadSchematizationType = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.LoadSchematizationType = value); } } @@ -486,12 +481,10 @@ set { ChangePropertyAndNotify( - (input, newValue) => - SetProbabilityValue( - newValue, - data.WrappedData, - (wrappedData, parsedValue) => wrappedData.FailureProbabilityRepairClosure = parsedValue), - value); + () => SetProbabilityValue( + value, + data.WrappedData, + (wrappedData, parsedValue) => wrappedData.FailureProbabilityRepairClosure = parsedValue)); } } @@ -558,8 +551,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.LevellingCount = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.LevellingCount = value); } } @@ -576,12 +568,10 @@ set { ChangePropertyAndNotify( - (input, newValue) => - SetProbabilityValue( - newValue, - data.WrappedData, - (wrappedData, parsedValue) => wrappedData.ProbabilityCollisionSecondaryStructure = parsedValue), - value); + () => SetProbabilityValue( + value, + data.WrappedData, + (wrappedData, parsedValue) => wrappedData.ProbabilityCollisionSecondaryStructure = parsedValue)); } } @@ -614,8 +604,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.EvaluationLevel = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.EvaluationLevel = value); } } @@ -631,8 +620,7 @@ } set { - ChangePropertyAndNotify( - (input, newValue) => data.WrappedData.VerticalDistance = newValue, value); + ChangePropertyAndNotify(() => data.WrappedData.VerticalDistance = value); } } Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Plugin/StabilityPointStructuresPlugin.cs (.../StabilityPointStructuresPlugin.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -69,7 +69,7 @@ yield return new PropertyInfo(); yield return new PropertyInfo { - CreateInstance = context => new StabilityPointStructuresInputContextProperties(context, new ObservablePropertyChangeHandler(context.Calculation)) + CreateInstance = context => new StabilityPointStructuresInputContextProperties(context, new ObservablePropertyChangeHandler(context.Calculation, context.WrappedData)) }; } Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/PropertyClasses/StabilityPointStructuresInputContextPropertiesTest.cs (.../StabilityPointStructuresInputContextPropertiesTest.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -953,233 +953,207 @@ { RoundedDouble height = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.VolumicWeightWater = height, - height); + properties => properties.VolumicWeightWater = height); } [Test] public void FactorStormDurationOpenStructure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput() { RoundedDouble factor = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.FactorStormDurationOpenStructure = factor, - factor); + properties => properties.FactorStormDurationOpenStructure = factor); } [Test] public void InflowModelType_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput() { var type = new Random(21).NextEnumValue(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.InflowModelType = type, - type); + properties => properties.InflowModelType = type); } [Test] public void FailureProbabilityOpenStructure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput() { var type = new Random(21).NextEnumValue(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.LoadSchematizationType = type, - type); + properties => properties.LoadSchematizationType = type); } [Test] public void FailureProbabilityRepairClosure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput() { string probability = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.FailureProbabilityRepairClosure = probability, - probability); + properties => properties.FailureProbabilityRepairClosure = probability); } [Test] public void LevellingCount_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput() { int count = new Random(21).Next(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.LevellingCount = count, - count); + properties => properties.LevellingCount = count); } [Test] public void ProbabilityCollisionSecondaryStructure_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput() { string probability = new Random(21).NextDouble().ToString(CultureInfo.CurrentCulture); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ProbabilityCollisionSecondaryStructure = probability, - probability); + properties => properties.ProbabilityCollisionSecondaryStructure = probability); } [Test] public void EvaluationLevel_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput() { RoundedDouble evaluationLevel = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.EvaluationLevel = evaluationLevel, - evaluationLevel); + properties => properties.EvaluationLevel = evaluationLevel); } [Test] public void VerticalDistance_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput() { RoundedDouble verticalDistance = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.VerticalDistance = verticalDistance, - verticalDistance); + properties => properties.VerticalDistance = verticalDistance); } [Test] public void ModelFactorSuperCriticalFlow_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ModelFactorSuperCriticalFlow.Mean = newMean, - newMean); + properties => properties.ModelFactorSuperCriticalFlow.Mean = newMean); } [Test] public void WidthFlowApertures_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.WidthFlowApertures.Mean = newMean, - newMean); + properties => properties.WidthFlowApertures.Mean = newMean); } [Test] public void InsideWaterLevelFailureConstruction_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.InsideWaterLevelFailureConstruction.Mean = newMean, - newMean); + properties => properties.InsideWaterLevelFailureConstruction.Mean = newMean); } [Test] public void InsideWaterLevel_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.InsideWaterLevel.Mean = newMean, - newMean); + properties => properties.InsideWaterLevel.Mean = newMean); } [Test] public void DrainCoefficient_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.DrainCoefficient.Mean = newMean, - newMean); + properties => properties.DrainCoefficient.Mean = newMean); } [Test] public void LevelCrestStructure_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.LevelCrestStructure.Mean = newMean, - newMean); + properties => properties.LevelCrestStructure.Mean = newMean); } [Test] public void ThresholdHeightOpenWeir_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ThresholdHeightOpenWeir.Mean = newMean, - newMean); + properties => properties.ThresholdHeightOpenWeir.Mean = newMean); } [Test] public void FlowVelocityStructureClosable_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.FlowVelocityStructureClosable.Mean = newMean, - newMean); + properties => properties.FlowVelocityStructureClosable.Mean = newMean); } [Test] public void AreaFlowApertures_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.AreaFlowApertures.Mean = newMean, - newMean); + properties => properties.AreaFlowApertures.Mean = newMean); } [Test] public void ConstructiveStrengthLinearLoadModel_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ConstructiveStrengthLinearLoadModel.Mean = newMean, - newMean); + properties => properties.ConstructiveStrengthLinearLoadModel.Mean = newMean); } [Test] public void ConstructiveStrengthQuadraticLoadModel_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ConstructiveStrengthQuadraticLoadModel.Mean = newMean, - newMean); + properties => properties.ConstructiveStrengthQuadraticLoadModel.Mean = newMean); } [Test] public void StabilityLinearLoadModel_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.StabilityLinearLoadModel.Mean = newMean, - newMean); + properties => properties.StabilityLinearLoadModel.Mean = newMean); } [Test] public void StabilityQuadraticLoadModel_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.StabilityQuadraticLoadModel.Mean = newMean, - newMean); + properties => properties.StabilityQuadraticLoadModel.Mean = newMean); } [Test] public void FailureCollisionEnergy_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.FailureCollisionEnergy.Mean = newMean, - newMean); + properties => properties.FailureCollisionEnergy.Mean = newMean); } [Test] public void ShipMass_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ShipMass.Mean = newMean, - newMean); + properties => properties.ShipMass.Mean = newMean); } [Test] public void ShipVelocity_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.ShipVelocity.Mean = newMean, - newMean); + properties => properties.ShipVelocity.Mean = newMean); } [Test] public void BankWidth_MeanChanged_InputChangedAndObsevablesNotified() { RoundedDouble newMean = new Random(21).NextRoundedDouble(); SetPropertyAndVerifyNotifcationsAndOutput( - properties => properties.BankWidth.Mean = newMean, - newMean); + properties => properties.BankWidth.Mean = newMean); } [Test] @@ -1202,10 +1176,7 @@ const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newProbabilityString, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call @@ -1235,10 +1206,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newValue, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call @@ -1266,10 +1234,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - null, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call @@ -1302,10 +1267,7 @@ const int overflow = 1; string newProbabilityString = string.Concat(newValue.ToString("r", CultureInfo.CurrentCulture), overflow); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newProbabilityString, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call @@ -1335,10 +1297,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newValue, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call @@ -1366,10 +1325,7 @@ failureMechanism, assessmentSectionStub); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - null, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); // Call @@ -1397,10 +1353,7 @@ assessmentSectionStub); var newStructure = new TestStabilityPointStructure(); - var handler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - calculation.InputParameters, - newStructure, - Enumerable.Empty()); + var handler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty()); var properties = new StabilityPointStructuresInputContextProperties(inputContext, handler); failureMechanism.AddSection(new FailureMechanismSection("Section", new List @@ -1579,9 +1532,7 @@ Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); } - private void SetPropertyAndVerifyNotifcationsAndOutput( - Action setProperty, - TPropertyValue expectedValueSet) + private void SetPropertyAndVerifyNotifcationsAndOutput(Action setProperty) { // Setup var observable = mockRepository.StrictMock(); @@ -1593,13 +1544,10 @@ StabilityPointStructuresInput input = calculation.InputParameters; input.ForeshoreProfile = new TestForeshoreProfile(); - var customHandler = new ObservableSetPropertyValueAfterConfirmationParameterTester( - input, - expectedValueSet, - new[] - { - observable - }); + var customHandler = new CalculationInputSetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); var inputContext = new StabilityPointStructuresInputContext(input, calculation, Index: Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/StabilityStoneCover/src/Ringtoets.StabilityStoneCover.Plugin/StabilityStoneCoverPlugin.cs (.../StabilityStoneCoverPlugin.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -67,7 +67,9 @@ yield return new PropertyInfo(); yield return new PropertyInfo { - CreateInstance = context => new StabilityStoneCoverWaveConditionsInputContextProperties(context, new ObservablePropertyChangeHandler(context.Calculation)) + CreateInstance = context => new StabilityStoneCoverWaveConditionsInputContextProperties( + context, + new ObservablePropertyChangeHandler(context.Calculation, context.WrappedData)) }; } Index: Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs =================================================================== diff -u -r277048d204ab4cfad4aa5de4d57ef38b56642c25 -r37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79 --- Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 277048d204ab4cfad4aa5de4d57ef38b56642c25) +++ Ringtoets/WaveImpactAsphaltCover/src/Ringtoets.WaveImpactAsphaltCover.Plugin/WaveImpactAsphaltCoverPlugin.cs (.../WaveImpactAsphaltCoverPlugin.cs) (revision 37fc59cc0f3becb92e14b8263bd8e9fc71aa0e79) @@ -67,7 +67,9 @@ yield return new PropertyInfo(); yield return new PropertyInfo { - CreateInstance = context => new WaveImpactAsphaltCoverWaveConditionsInputContextProperties(context, new ObservablePropertyChangeHandler(context.Calculation)) + CreateInstance = context => new WaveImpactAsphaltCoverWaveConditionsInputContextProperties( + context, + new ObservablePropertyChangeHandler(context.Calculation, context.WrappedData)) }; }