Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs =================================================================== diff -u -rc0849c80b8bab9023c7df1e8402aa380891496d2 -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision c0849c80b8bab9023c7df1e8402aa380891496d2) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) @@ -173,11 +173,6 @@ return data.FailureMechanism.ClosingStructures; } - public void PropertyChanged() - { - // TODO WTI-973 - } - protected override void AfterSettingStructure() { StructuresHelper.Update(data.FailureMechanism.SectionResults, data.Calculation); @@ -224,7 +219,7 @@ set { data.WrappedData.FactorStormDurationOpenStructure = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -268,7 +263,7 @@ set { data.WrappedData.InflowModelType = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -319,6 +314,7 @@ set { SetProbabilityValue(value, data.WrappedData, (wrappedData, parsedValue) => wrappedData.FailureProbabilityOpenStructure = parsedValue); + ClearOutputAndNotifyPropertyChanged(); } } @@ -335,6 +331,7 @@ set { SetProbabilityValue(value, data.WrappedData, (wrappedData, parsedValue) => wrappedData.FailureProbabilityReparation = parsedValue); + ClearOutputAndNotifyPropertyChanged(); } } @@ -351,7 +348,7 @@ set { data.WrappedData.IdenticalApertures = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -385,6 +382,7 @@ set { SetProbabilityValue(value, data.WrappedData, (wrappedData, parsedValue) => wrappedData.ProbabilityOrFrequencyOpenStructureBeforeFlooding = parsedValue); + ClearOutputAndNotifyPropertyChanged(); } } Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs =================================================================== diff -u -rc0849c80b8bab9023c7df1e8402aa380891496d2 -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision c0849c80b8bab9023c7df1e8402aa380891496d2) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) @@ -40,6 +40,7 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.Properties; using Ringtoets.Common.Forms.UITypeEditors; +using Ringtoets.Common.Service; namespace Ringtoets.Common.Forms.PropertyClasses { @@ -174,23 +175,21 @@ /// /// The type of the wrapped data to set a probability value for. /// The probability value to set. - /// The wrapped data to set a probability value for. + /// The wrapped data to set a probability value for. /// The action that sets the probability value to a specific property of the wrapped data. /// Thrown when equals null. /// Thrown when cannot be parsed into a double. - /// After correctly setting the to the wrapped data, observers will be notified. - protected static void SetProbabilityValue(string value, - T wrappedData, - Action setValueAction) - where T : IObservable + protected static void SetProbabilityValue(string value, + TStructureInput structureInput, + Action setValueAction) { if (value == null) { throw new ArgumentNullException("value", Resources.FailureProbability_Value_cannot_be_null); } try { - setValueAction(wrappedData, (RoundedDouble) double.Parse(value)); + setValueAction(structureInput, (RoundedDouble) double.Parse(value)); } catch (OverflowException) { @@ -200,7 +199,6 @@ { throw new ArgumentException(Resources.FailureProbability_Could_not_parse_string_to_double_value); } - wrappedData.NotifyObservers(); } private static string GetMemberName(Expression, object>> expression) @@ -318,7 +316,7 @@ { data.WrappedData.Structure = value; AfterSettingStructure(); - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -350,7 +348,7 @@ set { data.WrappedData.StructureNormalOrientation = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -379,7 +377,10 @@ { get { - return new VariationCoefficientNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.WidthFlowApertures }; @@ -395,7 +396,10 @@ { get { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.StorageStructureArea }; @@ -427,7 +431,10 @@ { get { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.CriticalOvertoppingDischarge }; @@ -447,6 +454,7 @@ set { SetProbabilityValue(value, data.WrappedData, (wrappedData, parsedValue) => wrappedData.FailureProbabilityStructureWithErosion = parsedValue); + ClearOutputAndNotifyPropertyChanged(); } } @@ -464,7 +472,7 @@ set { data.WrappedData.ForeshoreProfile = value; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -516,7 +524,7 @@ set { data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation; - data.WrappedData.NotifyObservers(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -529,7 +537,10 @@ { get { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.CoefficientOfVariation, data.WrappedData) + return new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.CoefficientOfVariation, + data.WrappedData, + this) { Data = data.WrappedData.StormDuration }; @@ -540,7 +551,22 @@ public void PropertyChanged() { - // TODO WTI-969/WTI-970/WTI-971/WTI-973 + ClearCalculationOutput(); } + + protected void ClearOutputAndNotifyPropertyChanged() + { + ClearCalculationOutput(); + data.WrappedData.NotifyObservers(); + } + + private void ClearCalculationOutput() + { + IEnumerable affectedCalculation = RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(data.Calculation); + foreach (var calculation in affectedCalculation) + { + calculation.NotifyObservers(); + } + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientDistributionPropertiesBase.cs =================================================================== diff -u -r8805f03189f521994b42a519bbca7561bf12eb68 -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientDistributionPropertiesBase.cs (.../VariationCoefficientDistributionPropertiesBase.cs) (revision 8805f03189f521994b42a519bbca7561bf12eb68) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientDistributionPropertiesBase.cs (.../VariationCoefficientDistributionPropertiesBase.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) @@ -40,7 +40,8 @@ private readonly string variationCoefficientDisplayName; private readonly bool isMeanReadOnly; private readonly bool isVariationCoefficientReadOnly; - private readonly IObservable observerable; + private readonly IObservable observable; + private readonly IPropertyChangeHandler changeHandler; /// /// Initializes a new instance of the class. @@ -49,10 +50,13 @@ /// marked as read-only. /// The object to be notified of changes to properties. /// Can be null if all properties are marked as read-only by . + /// Optional handler that is used to handle property changes. /// Thrown when /// is null and any number of properties in this class is editable. - protected VariationCoefficientDistributionPropertiesBase(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly, - IObservable observable) + protected VariationCoefficientDistributionPropertiesBase( + VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly, + IObservable observable, + IPropertyChangeHandler handler) { if (observable == null && !propertiesReadOnly.HasFlag(VariationCoefficientDistributionPropertiesReadOnly.All)) { @@ -65,7 +69,8 @@ meanDisplayName = TypeUtils.GetMemberName>(d => d.Mean); variationCoefficientDisplayName = TypeUtils.GetMemberName>(d => d.CoefficientOfVariation); - observerable = observable; + this.observable = observable; + changeHandler = handler; } [PropertyOrder(1)] @@ -89,7 +94,7 @@ throw new InvalidOperationException("Mean is set to be read-only."); } data.Mean = value; - observerable.NotifyObservers(); + NotifyPropertyChanged(); } } @@ -109,7 +114,7 @@ throw new InvalidOperationException("CoefficientOfVariation is set to be read-only."); } data.CoefficientOfVariation = value; - observerable.NotifyObservers(); + NotifyPropertyChanged(); } } @@ -133,5 +138,17 @@ string.Format("{0} ({1} = {2})", Mean, Resources.Distribution_VariationCoefficient_DisplayName, CoefficientOfVariation); } + + /// + /// Sends notifications due to a change of a property. + /// + protected void NotifyPropertyChanged() + { + if (changeHandler != null) + { + changeHandler.PropertyChanged(); + } + observable.NotifyObservers(); + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientLogNormalDistributionProperties.cs =================================================================== diff -u -r7d6e4c28a40fb056c182d0691dda2b2e88aeebfd -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientLogNormalDistributionProperties.cs (.../VariationCoefficientLogNormalDistributionProperties.cs) (revision 7d6e4c28a40fb056c182d0691dda2b2e88aeebfd) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientLogNormalDistributionProperties.cs (.../VariationCoefficientLogNormalDistributionProperties.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) @@ -37,7 +37,7 @@ /// /// Creates a new read-only instance of . /// - public VariationCoefficientLogNormalDistributionProperties() : this(VariationCoefficientDistributionPropertiesReadOnly.All, null) {} + public VariationCoefficientLogNormalDistributionProperties() : this(VariationCoefficientDistributionPropertiesReadOnly.All, null, null) {} /// /// Creates a new instance of . @@ -46,10 +46,14 @@ /// marked as read-only. /// The object to be notified of changes to properties. /// Can be null if all properties are marked as read-only by . + /// Optional handler that is used to handle property changes. /// Thrown when /// is null and any number of properties in this class is editable. - public VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly, IObservable observable) - : base(propertiesReadOnly, observable) {} + public VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly, + IObservable observable, + IPropertyChangeHandler handler) + : base(propertiesReadOnly, observable, handler) {} public override string DistributionType { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientNormalDistributionProperties.cs =================================================================== diff -u -r7d6e4c28a40fb056c182d0691dda2b2e88aeebfd -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientNormalDistributionProperties.cs (.../VariationCoefficientNormalDistributionProperties.cs) (revision 7d6e4c28a40fb056c182d0691dda2b2e88aeebfd) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/VariationCoefficientNormalDistributionProperties.cs (.../VariationCoefficientNormalDistributionProperties.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) @@ -38,7 +38,7 @@ /// /// Creates a new read-only instance of . /// - public VariationCoefficientNormalDistributionProperties() : this(VariationCoefficientDistributionPropertiesReadOnly.All, null) {} + public VariationCoefficientNormalDistributionProperties() : this(VariationCoefficientDistributionPropertiesReadOnly.All, null, null) {} /// /// Creates a new instance of . @@ -47,10 +47,14 @@ /// marked as read-only. /// The object to be notified of changes to properties. /// Can be null if all properties are marked as read-only by . + /// Optional handler that is used to handle property changes. /// Thrown when /// is null and any number of properties in this class is editable. - public VariationCoefficientNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly, IObservable observable) - : base(propertiesReadOnly, observable) {} + public VariationCoefficientNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly, + IObservable observable, + IPropertyChangeHandler handler) + : base(propertiesReadOnly, observable, handler) {} public override string DistributionType { Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/VariationCoefficientDistributionPropertiesBaseTest.cs =================================================================== diff -u -r7d6e4c28a40fb056c182d0691dda2b2e88aeebfd -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/VariationCoefficientDistributionPropertiesBaseTest.cs (.../VariationCoefficientDistributionPropertiesBaseTest.cs) (revision 7d6e4c28a40fb056c182d0691dda2b2e88aeebfd) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/VariationCoefficientDistributionPropertiesBaseTest.cs (.../VariationCoefficientDistributionPropertiesBaseTest.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) @@ -42,7 +42,7 @@ var readOnlyFlags = VariationCoefficientDistributionPropertiesReadOnly.All; // Call - var properties = new SimpleVariationCoefficientDistributionProperties(readOnlyFlags, null); + var properties = new SimpleVariationCoefficientDistributionProperties(readOnlyFlags, null, null); // Assert Assert.IsInstanceOf>(properties); @@ -57,7 +57,7 @@ VariationCoefficientDistributionPropertiesReadOnly flags) { // Call - TestDelegate call = () => new SimpleVariationCoefficientDistributionProperties(flags, null); + TestDelegate call = () => new SimpleVariationCoefficientDistributionProperties(flags, null, null); // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Observable must be specified unless no property can be set."); @@ -77,7 +77,7 @@ var observable = mocks.Stub(); mocks.ReplayAll(); - var properties = new SimpleVariationCoefficientDistributionProperties(flags, observable); + var properties = new SimpleVariationCoefficientDistributionProperties(flags, observable, null); // Call bool isMeanReadonly = properties.DynamicReadOnlyValidationMethod("Mean"); @@ -93,7 +93,7 @@ public void DynamicReadOnlyValidationMethod_AllOtherCases_ReturnFalse() { // Setup - var properties = new SimpleVariationCoefficientDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.All, null); + var properties = new SimpleVariationCoefficientDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.All, null, null); // Call bool isReadonly = properties.DynamicReadOnlyValidationMethod(null); @@ -112,7 +112,7 @@ distribution.CoefficientOfVariation = new RoundedDouble(4, 5.6789); mocks.ReplayAll(); - var properties = new SimpleVariationCoefficientDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.All, null); + var properties = new SimpleVariationCoefficientDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.All, null, null); // Call properties.Data = distribution; @@ -135,7 +135,7 @@ var observable = mocks.Stub(); mocks.ReplayAll(); - var properties = new SimpleVariationCoefficientDistributionProperties(flags, observable) + var properties = new SimpleVariationCoefficientDistributionProperties(flags, observable, null) { Data = distribution }; @@ -150,17 +150,25 @@ } [Test] - public void Mean_SetValue_ValueChangedAndObservableNotifies() + [TestCase(true)] + [TestCase(false)] + public void Mean_SetValue_ValueChangedAndObservableNotifies(bool withHandler) { // Setup var mocks = new MockRepository(); + IPropertyChangeHandler handler = null; + if (withHandler) + { + handler = mocks.StrictMock(); + handler.Expect(o => o.PropertyChanged()); + } var distribution = mocks.Stub(); var observable = mocks.StrictMock(); observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); var properties = new SimpleVariationCoefficientDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.None, observable) + VariationCoefficientDistributionPropertiesReadOnly.None, observable, handler) { Data = distribution }; @@ -187,7 +195,7 @@ var observable = mocks.Stub(); mocks.ReplayAll(); - var properties = new SimpleVariationCoefficientDistributionProperties(flags, observable) + var properties = new SimpleVariationCoefficientDistributionProperties(flags, observable, null) { Data = distribution }; @@ -202,17 +210,25 @@ } [Test] - public void CoefficientOfVariation_SetValue_ValueChangedAndObservableNotifies() + [TestCase(true)] + [TestCase(false)] + public void CoefficientOfVariation_SetValue_ValueChangedAndObservableNotifies(Boolean withHandler) { // Setup var mocks = new MockRepository(); + IPropertyChangeHandler handler = null; + if (withHandler) + { + handler = mocks.StrictMock(); + handler.Expect(o => o.PropertyChanged()); + } var distribution = mocks.Stub(); var observable = mocks.StrictMock(); observable.Expect(o => o.NotifyObservers()); mocks.ReplayAll(); var properties = new SimpleVariationCoefficientDistributionProperties( - VariationCoefficientDistributionPropertiesReadOnly.None, observable) + VariationCoefficientDistributionPropertiesReadOnly.None, observable, handler) { Data = distribution }; @@ -242,7 +258,7 @@ mocks.ReplayAll(); // Call - var properties = new SimpleVariationCoefficientDistributionProperties(flags, observable) + var properties = new SimpleVariationCoefficientDistributionProperties(flags, observable, null) { Data = distribution }; @@ -279,7 +295,7 @@ public void ToString_DataIsNull_ReturnEmptyString() { // Setup - var properties = new SimpleVariationCoefficientDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.All, null); + var properties = new SimpleVariationCoefficientDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.All, null, null); // Precondition Assert.IsNull(properties.Data); @@ -302,7 +318,7 @@ distribution.CoefficientOfVariation = new RoundedDouble(2, 4.56); mocks.ReplayAll(); - var properties = new SimpleVariationCoefficientDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.All, null) + var properties = new SimpleVariationCoefficientDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.All, null, null) { Data = distribution }; @@ -320,7 +336,11 @@ private class SimpleVariationCoefficientDistributionProperties : VariationCoefficientDistributionPropertiesBase { - public SimpleVariationCoefficientDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly, IObservable observable) : base(propertiesReadOnly, observable) {} + public SimpleVariationCoefficientDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly, + IObservable observable, + IPropertyChangeHandler handler) + : base(propertiesReadOnly, observable, handler) {} public override string DistributionType { Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/VariationCoefficientLogNormalDistributionPropertiesTest.cs =================================================================== diff -u -r5c5df51bc14a7e25692abf1db5a7476e5036b13f -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/VariationCoefficientLogNormalDistributionPropertiesTest.cs (.../VariationCoefficientLogNormalDistributionPropertiesTest.cs) (revision 5c5df51bc14a7e25692abf1db5a7476e5036b13f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/VariationCoefficientLogNormalDistributionPropertiesTest.cs (.../VariationCoefficientLogNormalDistributionPropertiesTest.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) @@ -56,7 +56,10 @@ var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var properties = new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, observerableMock); + var properties = new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + observerableMock, + null); // Assert Assert.IsNull(properties.Data); @@ -71,7 +74,7 @@ public void Constructor_EditableFieldsAndWithoutObervable_ThrowArgumentException(VariationCoefficientDistributionPropertiesReadOnly flags) { // Call - TestDelegate call = () => new VariationCoefficientLogNormalDistributionProperties(flags, null); + TestDelegate call = () => new VariationCoefficientLogNormalDistributionProperties(flags, null, null); // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Observable must be specified unless no property can be set."); @@ -91,7 +94,7 @@ var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var properties = new VariationCoefficientLogNormalDistributionProperties(propertiesReadOnly, observerableMock); + var properties = new VariationCoefficientLogNormalDistributionProperties(propertiesReadOnly, observerableMock, null); var meanPropertyName = TypeUtils.GetMemberName(lndvp => lndvp.Mean); var variationCoefficientPropertyName = TypeUtils.GetMemberName(lndvp => lndvp.CoefficientOfVariation); @@ -116,7 +119,7 @@ var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var properties = new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, observerableMock); + var properties = new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, observerableMock, null); var distribution = new VariationCoefficientLogNormalDistribution(2); // Call @@ -134,14 +137,18 @@ [Test] [TestCase(VariationCoefficientDistributionPropertiesReadOnly.All)] [TestCase(VariationCoefficientDistributionPropertiesReadOnly.Mean)] - public void SetProperties_ReadOnlyMeanWithObserverable_ThrowsArgumentException(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly) + public void Mean_ReadOnlyWithObserverable_ThrowsArgumentException(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly) { // Setup var mockRepository = new MockRepository(); + IPropertyChangeHandler handler = mockRepository.StrictMock(); var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var properties = new VariationCoefficientLogNormalDistributionProperties(propertiesReadOnly, observerableMock) + var properties = new VariationCoefficientLogNormalDistributionProperties( + propertiesReadOnly, + observerableMock, + handler) { Data = new VariationCoefficientLogNormalDistribution(2) }; @@ -156,15 +163,20 @@ } [Test] - public void SetProperties_MeanWithObserverable_ValueSetNotifyObservers() + public void Mean_WithObserverable_ValueSetNotifyObservers() { // Setup var mockRepository = new MockRepository(); + IPropertyChangeHandler handler = mockRepository.StrictMock(); + handler.Expect(o => o.PropertyChanged()); var observerableMock = mockRepository.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()); mockRepository.ReplayAll(); - var properties = new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, observerableMock) + var properties = new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + observerableMock, + handler) { Data = new VariationCoefficientLogNormalDistribution(2) }; @@ -181,14 +193,15 @@ [Test] [TestCase(VariationCoefficientDistributionPropertiesReadOnly.All)] [TestCase(VariationCoefficientDistributionPropertiesReadOnly.CoefficientOfVariation)] - public void SetProperties_ReadOnlyVariationCoefficientWithoutObserverable_ThrowsArgumentException(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly) + public void CoefficientOfVariation_ReadOnlyWithoutObserverable_ThrowsArgumentException(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly) { // Setup - var mocks = new MockRepository(); - var observable = mocks.Stub(); - mocks.ReplayAll(); + var mockRepository = new MockRepository(); + IPropertyChangeHandler handler = mockRepository.StrictMock(); + var observable = mockRepository.Stub(); + mockRepository.ReplayAll(); - var properties = new VariationCoefficientLogNormalDistributionProperties(propertiesReadOnly, observable) + var properties = new VariationCoefficientLogNormalDistributionProperties(propertiesReadOnly, observable, handler) { Data = new VariationCoefficientLogNormalDistribution(2) }; @@ -199,19 +212,24 @@ // Assert string message = Assert.Throws(test).Message; Assert.AreEqual("CoefficientOfVariation is set to be read-only.", message); - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] - public void SetProperties_VariationCoefficientWithObserverable_ValueSetNotifyObservers() + public void CoefficientOfVariation_WithObserverable_ValueSetNotifyObservers() { // Setup var mockRepository = new MockRepository(); + IPropertyChangeHandler handler = mockRepository.StrictMock(); + handler.Expect(o => o.PropertyChanged()); var observerableMock = mockRepository.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); mockRepository.ReplayAll(); - var properties = new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, observerableMock) + var properties = new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + observerableMock, + handler) { Data = new VariationCoefficientLogNormalDistribution(2) }; @@ -238,7 +256,7 @@ mockRepository.ReplayAll(); // Call - var properties = new VariationCoefficientLogNormalDistributionProperties(propertiesReadOnly, observerableMock) + var properties = new VariationCoefficientLogNormalDistributionProperties(propertiesReadOnly, observerableMock, null) { Data = new VariationCoefficientLogNormalDistribution(2) }; Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/VariationCoefficientNormalDistributionPropertiesTest.cs =================================================================== diff -u -r5c5df51bc14a7e25692abf1db5a7476e5036b13f -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/VariationCoefficientNormalDistributionPropertiesTest.cs (.../VariationCoefficientNormalDistributionPropertiesTest.cs) (revision 5c5df51bc14a7e25692abf1db5a7476e5036b13f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/VariationCoefficientNormalDistributionPropertiesTest.cs (.../VariationCoefficientNormalDistributionPropertiesTest.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) @@ -56,7 +56,10 @@ var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var properties = new VariationCoefficientNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, observerableMock); + var properties = new VariationCoefficientNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + observerableMock, + null); // Assert Assert.IsNull(properties.Data); @@ -71,7 +74,7 @@ public void Constructor_EditableFieldsAndWithoutObervable_ThrowArgumentException(VariationCoefficientDistributionPropertiesReadOnly flags) { // Call - TestDelegate call = () => new VariationCoefficientNormalDistributionProperties(flags, null); + TestDelegate call = () => new VariationCoefficientNormalDistributionProperties(flags, null, null); // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Observable must be specified unless no property can be set."); @@ -91,7 +94,7 @@ var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var properties = new VariationCoefficientNormalDistributionProperties(propertiesReadOnly, observerableMock); + var properties = new VariationCoefficientNormalDistributionProperties(propertiesReadOnly, observerableMock, null); var meanPropertyName = TypeUtils.GetMemberName(ndvp => ndvp.Mean); var variationCoefficientPropertyName = TypeUtils.GetMemberName(ndvp => ndvp.CoefficientOfVariation); @@ -116,7 +119,10 @@ var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); - var properties = new VariationCoefficientNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, observerableMock); + var properties = new VariationCoefficientNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + observerableMock, + null); var distribution = new VariationCoefficientNormalDistribution(2) { Mean = (RoundedDouble) 2 @@ -137,15 +143,18 @@ [Test] [TestCase(VariationCoefficientDistributionPropertiesReadOnly.All)] [TestCase(VariationCoefficientDistributionPropertiesReadOnly.Mean)] - public void SetProperties_ReadOnlyMeanWithObserverable_ThrowsArgumentException(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly) + public void Mean_ReadOnlyWithObserverable_ThrowsArgumentException(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly) { // Setup var mockRepository = new MockRepository(); + IPropertyChangeHandler handler = mockRepository.StrictMock(); var observerableMock = mockRepository.StrictMock(); - observerableMock.Expect(o => o.NotifyObservers()).Repeat.Never(); mockRepository.ReplayAll(); - var properties = new VariationCoefficientNormalDistributionProperties(propertiesReadOnly, observerableMock) + var properties = new VariationCoefficientNormalDistributionProperties( + propertiesReadOnly, + observerableMock, + handler) { Data = new VariationCoefficientNormalDistribution(2) }; @@ -160,16 +169,20 @@ } [Test] - public void SetProperties_MeanWithObserverable_ValueSetNotifyObservers() + public void Mean_WithObserverable_ValueSetNotifyObservers() { // Setup var mockRepository = new MockRepository(); + IPropertyChangeHandler handler = mockRepository.StrictMock(); + handler.Expect(o => o.PropertyChanged()); var observerableMock = mockRepository.StrictMock(); - observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - + observerableMock.Expect(o => o.NotifyObservers()); mockRepository.ReplayAll(); - var properties = new VariationCoefficientNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, observerableMock) + var properties = new VariationCoefficientNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + observerableMock, + handler) { Data = new VariationCoefficientNormalDistribution(2) }; @@ -186,14 +199,15 @@ [Test] [TestCase(VariationCoefficientDistributionPropertiesReadOnly.All)] [TestCase(VariationCoefficientDistributionPropertiesReadOnly.CoefficientOfVariation)] - public void SetProperties_ReadOnlyVariationCoefficientWithoutObserverable_ThrowsArgumentException(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly) + public void CoefficientOfVariation_ReadOnlyWithoutObserverable_ThrowsArgumentException(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly) { // Setup - var mocks = new MockRepository(); - var observable = mocks.Stub(); - mocks.ReplayAll(); + var mockRepository = new MockRepository(); + IPropertyChangeHandler handler = mockRepository.StrictMock(); + var observable = mockRepository.Stub(); + mockRepository.ReplayAll(); - var properties = new VariationCoefficientNormalDistributionProperties(propertiesReadOnly, observable) + var properties = new VariationCoefficientNormalDistributionProperties(propertiesReadOnly, observable, handler) { Data = new VariationCoefficientNormalDistribution(2) }; @@ -204,20 +218,24 @@ // Assert string message = Assert.Throws(test).Message; Assert.AreEqual("CoefficientOfVariation is set to be read-only.", message); - mocks.VerifyAll(); + mockRepository.VerifyAll(); } [Test] - public void SetProperties_VariationCoefficientWithObserverable_ValueSetNotifyObservers() + public void CoefficientOfVariation_WithObserverable_ValueSetNotifyObservers() { // Setup var mockRepository = new MockRepository(); + IPropertyChangeHandler handler = mockRepository.StrictMock(); + handler.Expect(o => o.PropertyChanged()); var observerableMock = mockRepository.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - mockRepository.ReplayAll(); - var properties = new VariationCoefficientNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, observerableMock) + var properties = new VariationCoefficientNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + observerableMock, + handler) { Data = new VariationCoefficientNormalDistribution(2) { @@ -247,7 +265,7 @@ mockRepository.ReplayAll(); // Call - var properties = new VariationCoefficientNormalDistributionProperties(propertiesReadOnly, observerableMock) + var properties = new VariationCoefficientNormalDistributionProperties(propertiesReadOnly, observerableMock, null) { Data = new VariationCoefficientNormalDistribution(2) }; Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs =================================================================== diff -u -rc0849c80b8bab9023c7df1e8402aa380891496d2 -rdbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision c0849c80b8bab9023c7df1e8402aa380891496d2) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision dbfba4c1829b1d42f4d99a88f7d8699bc3beeb2a) @@ -403,7 +403,10 @@ { get { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.ConstructiveStrengthLinearLoadModel }; @@ -420,7 +423,10 @@ { get { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.ConstructiveStrengthQuadraticLoadModel }; @@ -437,7 +443,10 @@ { get { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.StabilityLinearLoadModel }; @@ -454,7 +463,10 @@ { get { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.StabilityQuadraticLoadModel }; @@ -474,6 +486,7 @@ set { SetProbabilityValue(value, data.WrappedData, (wrappedData, parsedValue) => wrappedData.FailureProbabilityRepairClosure = parsedValue); + data.WrappedData.NotifyObservers(); } } @@ -486,7 +499,10 @@ { get { - return new VariationCoefficientLogNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientLogNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.FailureCollisionEnergy }; @@ -502,7 +518,10 @@ { get { - return new VariationCoefficientNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.ShipMass }; @@ -518,7 +537,10 @@ { get { - return new VariationCoefficientNormalDistributionProperties(VariationCoefficientDistributionPropertiesReadOnly.None, data.WrappedData) + return new VariationCoefficientNormalDistributionProperties( + VariationCoefficientDistributionPropertiesReadOnly.None, + data.WrappedData, + this) { Data = data.WrappedData.ShipVelocity }; @@ -555,6 +577,7 @@ set { SetProbabilityValue(value, data.WrappedData, (wrappedData, parsedValue) => wrappedData.ProbabilityCollisionSecondaryStructure = parsedValue); + data.WrappedData.NotifyObservers(); } }