Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs =================================================================== diff -u -r9a46b1398c3a83b8f5c06254ccb9808f33eb2531 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision 9a46b1398c3a83b8f5c06254ccb9808f33eb2531) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresInputContextProperties.cs (.../ClosingStructuresInputContextProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -30,6 +30,7 @@ using Ringtoets.ClosingStructures.Forms.PresentationObjects; using Ringtoets.ClosingStructures.Forms.Properties; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PropertyClasses; @@ -44,7 +45,9 @@ public class ClosingStructuresInputContextProperties : StructuresInputBaseProperties, - ClosingStructuresFailureMechanism> + ClosingStructuresFailureMechanism>, + DistributionPropertiesBase.IChangeHandler, + DistributionPropertiesBase.IChangeHandler { private const int hydraulicBoundaryLocationPropertyIndex = 1; private const int stormDurationPropertyIndex = 2; @@ -77,23 +80,23 @@ /// Creates a new instance of the class. /// public ClosingStructuresInputContextProperties() : base(new ConstructionProperties - { - StructurePropertyIndex = structurePropertyIndex, - StructureLocationPropertyIndex = structureLocationPropertyIndex, - StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex, - FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex, - WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex, - StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex, - AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex, - CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex, - FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex, - ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex, - UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex, - UseForeshorePropertyIndex = useForeshorePropertyIndex, - ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex, - HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex, - StormDurationPropertyIndex = stormDurationPropertyIndex - }) {} + { + StructurePropertyIndex = structurePropertyIndex, + StructureLocationPropertyIndex = structureLocationPropertyIndex, + StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex, + FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex, + WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex, + StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex, + AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex, + CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex, + FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex, + ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex, + UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex, + UseForeshorePropertyIndex = useForeshorePropertyIndex, + ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex, + HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex, + StormDurationPropertyIndex = stormDurationPropertyIndex + }) {} #region Hydraulic data @@ -107,7 +110,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.InsideWaterLevel }; @@ -171,6 +174,16 @@ return data.FailureMechanism.ClosingStructures; } + void DistributionPropertiesBase.IChangeHandler.PropertyChanged() + { + // TODO WTI-973 + } + + void DistributionPropertiesBase.IChangeHandler.PropertyChanged() + { + // TODO WTI-973 + } + protected override void AfterSettingStructure() { StructuresHelper.Update(data.FailureMechanism.SectionResults, data.Calculation); @@ -197,7 +210,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.StandardDeviation, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.StandardDeviation, data.WrappedData, this) { Data = data.WrappedData.DrainCoefficient }; @@ -275,7 +288,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.ThresholdHeightOpenWeir }; @@ -292,7 +305,7 @@ { get { - return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.AreaFlowApertures }; @@ -358,7 +371,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.LevelCrestStructureNotClosing }; Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionPropertiesBase.cs =================================================================== diff -u -r8805f03189f521994b42a519bbca7561bf12eb68 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionPropertiesBase.cs (.../DistributionPropertiesBase.cs) (revision 8805f03189f521994b42a519bbca7561bf12eb68) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionPropertiesBase.cs (.../DistributionPropertiesBase.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -41,6 +41,7 @@ private readonly bool isMeanReadOnly; private readonly bool isStandardDeviationReadOnly; private readonly IObservable observable; + private readonly IChangeHandler changeHandler; /// /// Initializes a new instance of the class. @@ -49,9 +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 . + /// The handler that is used to handle property changes. /// Thrown when /// is null and any number of properties in this class is editable. - protected DistributionPropertiesBase(DistributionPropertiesReadOnly propertiesReadOnly, IObservable observable) + protected DistributionPropertiesBase( + DistributionPropertiesReadOnly propertiesReadOnly, + IObservable observable, + IChangeHandler handler) { if (observable == null && !propertiesReadOnly.HasFlag(DistributionPropertiesReadOnly.All)) { @@ -65,6 +70,7 @@ standardDeviationPropertyName = TypeUtils.GetMemberName>(rd => rd.StandardDeviation); this.observable = observable; + changeHandler = handler; } [PropertyOrder(1)] @@ -88,7 +94,7 @@ throw new ArgumentException("Mean is set to be read-only."); } data.Mean = value; - observable.NotifyObservers(); + NotifyPropertyChanged(); } } @@ -108,7 +114,7 @@ throw new ArgumentException("StandardDeviation is set to be read-only."); } data.StandardDeviation = value; - observable.NotifyObservers(); + NotifyPropertyChanged(); } } @@ -132,5 +138,29 @@ string.Format("{0} ({1} = {2})", Mean, Resources.NormalDistribution_StandardDeviation_DisplayName, StandardDeviation); } + + /// + /// Sends notifications due to a change of a property. + /// + protected void NotifyPropertyChanged() + { + if (changeHandler != null) + { + changeHandler.PropertyChanged(); + } + observable.NotifyObservers(); + } + + /// + /// Interface defining the operations of handling a change of . + /// + public interface IChangeHandler + { + /// + /// Defines the action that is executed after a property of + /// has been changed. + /// + void PropertyChanged(); + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionProperties.cs =================================================================== diff -u -r7d6e4c28a40fb056c182d0691dda2b2e88aeebfd -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionProperties.cs (.../LogNormalDistributionProperties.cs) (revision 7d6e4c28a40fb056c182d0691dda2b2e88aeebfd) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionProperties.cs (.../LogNormalDistributionProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -38,7 +38,7 @@ /// /// Creates a new read-only instance of . /// - public LogNormalDistributionProperties() : this(DistributionPropertiesReadOnly.All, null) {} + public LogNormalDistributionProperties() : this(DistributionPropertiesReadOnly.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 . + /// The handler that is used to handle property changes. /// Thrown when /// is null and any number of properties in this class is editable. - public LogNormalDistributionProperties(DistributionPropertiesReadOnly propertiesReadOnly, IObservable observable) - : base(propertiesReadOnly, observable) {} + public LogNormalDistributionProperties( + DistributionPropertiesReadOnly propertiesReadOnly, + IObservable observable, + IChangeHandler handler) + : base(propertiesReadOnly, observable, handler) {} public override string DistributionType { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/NormalDistributionProperties.cs =================================================================== diff -u -r9050ad5f3a80e630b2fcc092942a40d6343286a0 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/NormalDistributionProperties.cs (.../NormalDistributionProperties.cs) (revision 9050ad5f3a80e630b2fcc092942a40d6343286a0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/NormalDistributionProperties.cs (.../NormalDistributionProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -38,7 +38,7 @@ /// /// Creates a new read-only instance of . /// - public NormalDistributionProperties() : this(DistributionPropertiesReadOnly.All, null) {} + public NormalDistributionProperties() : this(DistributionPropertiesReadOnly.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 . + /// The handler that is used to handle property changes. /// Thrown when /// is null and any number of properties in this class is editable. - public NormalDistributionProperties(DistributionPropertiesReadOnly propertiesReadOnly, IObservable observable) : - base(propertiesReadOnly, observable) {} + public NormalDistributionProperties( + DistributionPropertiesReadOnly propertiesReadOnly, + IObservable observable, + IChangeHandler handler) : + base(propertiesReadOnly, observable, handler) {} public override string DistributionType { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs =================================================================== diff -u -rbb80820ff4a4e09793da242cb7b36ca2bce59c32 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision bb80820ff4a4e09793da242cb7b36ca2bce59c32) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -35,6 +35,7 @@ using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; @@ -54,7 +55,10 @@ ObjectProperties>, IHasHydraulicBoundaryLocationProperty, IHasStructureProperty, - IHasForeshoreProfileProperty + IHasForeshoreProfileProperty, + UseBreakWaterProperties.IChangeHandler, + DistributionPropertiesBase.IChangeHandler, + DistributionPropertiesBase.IChangeHandler where TStructure : StructureBase where TStructureInput : StructuresInputBase where TCalculation : ICalculation @@ -135,7 +139,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.StandardDeviation, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.StandardDeviation, data.WrappedData, this) { Data = data.WrappedData.ModelFactorSuperCriticalFlow }; @@ -363,7 +367,7 @@ { get { - return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.FlowWidthAtBottomProtection }; @@ -411,7 +415,7 @@ { get { - return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.AllowedLevelIncreaseStorage }; @@ -479,7 +483,7 @@ { return data.WrappedData.ForeshoreProfile == null ? new UseBreakWaterProperties() : - new UseBreakWaterProperties(data.WrappedData, data.Calculation); + new UseBreakWaterProperties(data.WrappedData, this); } } @@ -537,5 +541,20 @@ } #endregion + + void UseBreakWaterProperties.IChangeHandler.PropertyChanged() + { + // TODO WTI-969/WTI-970/WTI-971 + } + + void DistributionPropertiesBase.IChangeHandler.PropertyChanged() + { + // TODO WTI-973 + } + + void DistributionPropertiesBase.IChangeHandler.PropertyChanged() + { + // TODO WTI-973 + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/TruncatedNormalDistributionProperties.cs =================================================================== diff -u -r71eba24cc0be4f2cfe3cca917430cd23510eaa4f -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/TruncatedNormalDistributionProperties.cs (.../TruncatedNormalDistributionProperties.cs) (revision 71eba24cc0be4f2cfe3cca917430cd23510eaa4f) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/TruncatedNormalDistributionProperties.cs (.../TruncatedNormalDistributionProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -39,7 +39,7 @@ /// /// Creates a new read-only instance of . /// - public TruncatedNormalDistributionProperties() : this(DistributionPropertiesReadOnly.All, null) {} + public TruncatedNormalDistributionProperties() : this(DistributionPropertiesReadOnly.All, null, null) {} /// /// Creates a new instance of . @@ -48,10 +48,11 @@ /// 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 . + /// The handler that is used to handle property changes. /// Thrown when /// is null and any number of properties in this class is editable. - public TruncatedNormalDistributionProperties(DistributionPropertiesReadOnly propertiesReadOnly, IObservable observable) : - base(propertiesReadOnly, observable) {} + public TruncatedNormalDistributionProperties(DistributionPropertiesReadOnly propertiesReadOnly, IObservable observable, IChangeHandler handler) : + base(propertiesReadOnly, observable, handler) {} public override string DistributionType { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/UseBreakWaterProperties.cs =================================================================== diff -u -r7918a30f6ddc1ba9067a5eb461a1d7a8cb5bc8a0 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/UseBreakWaterProperties.cs (.../UseBreakWaterProperties.cs) (revision 7918a30f6ddc1ba9067a5eb461a1d7a8cb5bc8a0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/UseBreakWaterProperties.cs (.../UseBreakWaterProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -20,19 +20,15 @@ // All rights reserved. using System; -using System.Collections.Generic; using System.ComponentModel; -using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Gui.Attributes; using Core.Common.Utils; using Core.Common.Utils.Attributes; using Core.Common.Utils.Reflection; -using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Forms.Properties; using Ringtoets.Common.Forms.TypeConverters; -using Ringtoets.Common.Service; namespace Ringtoets.Common.Forms.PropertyClasses { @@ -45,7 +41,7 @@ private const int breakWaterTypePropertyIndex = 2; private const int breakWaterHeightPropertyIndex = 3; private readonly IUseBreakWater data; - private ICalculation calculationToUpdate; + private readonly IChangeHandler changeHandler; /// /// Creates a new instance of , in which @@ -58,20 +54,16 @@ /// properties are editable. /// /// The data to use for the properties. - /// The calculationToUpdate that needs to be updated due to a property change. + /// The handler that is used to handle property changes. /// Thrown when any input parameter is null. - public UseBreakWaterProperties(IUseBreakWater useBreakWaterData, ICalculation calculation) + public UseBreakWaterProperties(IUseBreakWater useBreakWaterData, IChangeHandler handler) { if (useBreakWaterData == null) { throw new ArgumentNullException("useBreakWaterData"); } - if (calculation == null) - { - throw new ArgumentNullException("calculation"); - } data = useBreakWaterData; - calculationToUpdate = calculation; + changeHandler = handler; } [DynamicReadOnly] @@ -153,12 +145,23 @@ private void NotifyPropertyChanged() { - IEnumerable affectedCalculation = RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(calculationToUpdate); - foreach (var calculation in affectedCalculation) + if (changeHandler != null) { - calculation.NotifyObservers(); + changeHandler.PropertyChanged(); } data.NotifyObservers(); } + + /// + /// Interface defining the operations of handling a change of . + /// + public interface IChangeHandler + { + /// + /// Defines the action that is executed after a property of + /// has been changed. + /// + void PropertyChanged(); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/DistributionPropertiesBaseTest.cs =================================================================== diff -u -r7126410c2fc1844718e4592a6088282cc7415a79 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/DistributionPropertiesBaseTest.cs (.../DistributionPropertiesBaseTest.cs) (revision 7126410c2fc1844718e4592a6088282cc7415a79) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/DistributionPropertiesBaseTest.cs (.../DistributionPropertiesBaseTest.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -39,7 +39,7 @@ public void Constructor_WithParameters_ExpectedValues() { // Call - var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.All, null); + var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.All, null, null); // Assert Assert.IsInstanceOf>(properties); @@ -54,7 +54,7 @@ DistributionPropertiesReadOnly flags) { // Call - TestDelegate call = () => new SimpleDistributionProperties(flags, null); + TestDelegate call = () => new SimpleDistributionProperties(flags, null, null); // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Observable must be specified unless no property can be set."); @@ -65,14 +65,60 @@ [TestCase(DistributionPropertiesReadOnly.Mean, true, false)] [TestCase(DistributionPropertiesReadOnly.None, false, false)] [TestCase(DistributionPropertiesReadOnly.StandardDeviation, false, true)] + public void Constructor_Always_PropertiesHaveExpectedAttributesValues(DistributionPropertiesReadOnly propertiesReadOnly, bool expectMeanReadOnly, bool expectStandardDeviationReadOnly) + { + // Setup + var mocks = new MockRepository(); + var observable = mocks.Stub(); + var distribution = mocks.Stub(); + mocks.ReplayAll(); + + // Call + var properties = new SimpleDistributionProperties(propertiesReadOnly, observable, null) + { + Data = distribution + }; + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(3, dynamicProperties.Count); + + PropertyDescriptor distributionTypeProperty = dynamicProperties[0]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(distributionTypeProperty, + "Misc", + "Type verdeling", + "Het soort kansverdeling waarin deze parameter gedefinieerd wordt.", + true); + + PropertyDescriptor meanProperty = dynamicProperties[1]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(meanProperty, + "Misc", + "Verwachtingswaarde", + "", + expectMeanReadOnly); + + PropertyDescriptor standardDeviationProperty = dynamicProperties[2]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(standardDeviationProperty, + "Misc", + "Standaardafwijking", + "", + expectStandardDeviationReadOnly); + mocks.VerifyAll(); + } + + [Test] + [TestCase(DistributionPropertiesReadOnly.All, true, true)] + [TestCase(DistributionPropertiesReadOnly.Mean, true, false)] + [TestCase(DistributionPropertiesReadOnly.None, false, false)] + [TestCase(DistributionPropertiesReadOnly.StandardDeviation, false, true)] public void DynamicReadOnlyValidationMethod_VariousReadOnlySet_ExpectedValues(DistributionPropertiesReadOnly propertiesReadOnly, bool expectMeanReadOnly, bool expectStandardDeviationReadOnly) { // Setup var mocks = new MockRepository(); var observable = mocks.Stub(); mocks.ReplayAll(); - var properties = new SimpleDistributionProperties(propertiesReadOnly, observable); + var properties = new SimpleDistributionProperties(propertiesReadOnly, observable, null); // Call bool meanIsReadOnly = properties.DynamicReadOnlyValidationMethod("Mean"); @@ -97,7 +143,7 @@ distribution.StandardDeviation = new RoundedDouble(2, 2.2); mocks.ReplayAll(); - var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.None, observable); + var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.None, observable, null); // Call properties.Data = distribution; @@ -112,16 +158,47 @@ } [Test] - public void SetProperties_MeanWithObserverable_ValueSetNotifyObservers() + public void Mean_ReadOnlyWithObserverable_ThrowsArgumentException() { // Setup + var mocks = new MockRepository(); + var observable = mocks.Stub(); + var distribution = mocks.Stub(); + mocks.ReplayAll(); + + var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.All, observable, null) + { + Data = distribution + }; + + // Call + TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20); + + // Assert + const string expectedMessage = "Mean is set to be read-only."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + mocks.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Mean_WithObserverable_ValueSetNotifyObservers(bool withHandler) + { + // Setup var mockRepository = new MockRepository(); var observerableMock = mockRepository.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()); + DistributionPropertiesBase.IChangeHandler handler = null; + if (withHandler) + { + handler = mockRepository.StrictMock.IChangeHandler>(); + handler.Expect(o => o.PropertyChanged()); + } var distribution = mockRepository.Stub(); mockRepository.ReplayAll(); - var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock) + var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock, handler) { Data = distribution }; @@ -138,15 +215,15 @@ [Test] [TestCase(DistributionPropertiesReadOnly.All)] [TestCase(DistributionPropertiesReadOnly.StandardDeviation)] - public void SetProperties_ReadOnlyStandardDeviationWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) + public void StandardDeviation_ReadOnlyWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) { // Setup var mocks = new MockRepository(); var observable = mocks.Stub(); var distribution = mocks.Stub(); mocks.ReplayAll(); - var properties = new SimpleDistributionProperties(propertiesReadOnly, observable) + var properties = new SimpleDistributionProperties(propertiesReadOnly, observable, null) { Data = distribution }; @@ -161,16 +238,24 @@ } [Test] - public void SetProperties_StandardDeviationWithObserverable_ValueSetNotifyObservers() + [TestCase(true)] + [TestCase(false)] + public void StandardDeviation_WithObserverable_ValueSetNotifyObservers(bool withHandler) { // Setup var mockRepository = new MockRepository(); var observerableMock = mockRepository.StrictMock(); - observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); + observerableMock.Expect(o => o.NotifyObservers()); + DistributionPropertiesBase.IChangeHandler handler = null; + if (withHandler) + { + handler = mockRepository.StrictMock.IChangeHandler>(); + handler.Expect(o => o.PropertyChanged()); + } var distribution = mockRepository.Stub(); mockRepository.ReplayAll(); - var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock) + var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock, handler) { Data = distribution }; @@ -184,56 +269,10 @@ mockRepository.VerifyAll(); } - [Test] - [TestCase(DistributionPropertiesReadOnly.All, true, true)] - [TestCase(DistributionPropertiesReadOnly.Mean, true, false)] - [TestCase(DistributionPropertiesReadOnly.None, false, false)] - [TestCase(DistributionPropertiesReadOnly.StandardDeviation, false, true)] - public void Constructor_Always_PropertiesHaveExpectedAttributesValues(DistributionPropertiesReadOnly propertiesReadOnly, bool expectMeanReadOnly, bool expectStandardDeviationReadOnly) - { - // Setup - var mocks = new MockRepository(); - var observable = mocks.Stub(); - var distribution = mocks.Stub(); - mocks.ReplayAll(); - - // Call - var properties = new SimpleDistributionProperties(propertiesReadOnly, observable) - { - Data = distribution - }; - - // Assert - PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(3, dynamicProperties.Count); - - PropertyDescriptor distributionTypeProperty = dynamicProperties[0]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(distributionTypeProperty, - "Misc", - "Type verdeling", - "Het soort kansverdeling waarin deze parameter gedefinieerd wordt.", - true); - - PropertyDescriptor meanProperty = dynamicProperties[1]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(meanProperty, - "Misc", - "Verwachtingswaarde", - "", - expectMeanReadOnly); - - PropertyDescriptor standardDeviationProperty = dynamicProperties[2]; - PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(standardDeviationProperty, - "Misc", - "Standaardafwijking", - "", - expectStandardDeviationReadOnly); - mocks.VerifyAll(); - } - private class SimpleDistributionProperties : DistributionPropertiesBase { - public SimpleDistributionProperties(DistributionPropertiesReadOnly propertiesReadOnly, IObservable observable) - : base(propertiesReadOnly, observable) {} + public SimpleDistributionProperties(DistributionPropertiesReadOnly propertiesReadOnly, IObservable observable, IChangeHandler handler) + : base(propertiesReadOnly, observable, handler) {} public override string DistributionType { Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionPropertiesTest.cs =================================================================== diff -u -r5c5df51bc14a7e25692abf1db5a7476e5036b13f -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionPropertiesTest.cs (.../LogNormalDistributionPropertiesTest.cs) (revision 5c5df51bc14a7e25692abf1db5a7476e5036b13f) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionPropertiesTest.cs (.../LogNormalDistributionPropertiesTest.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -22,7 +22,6 @@ using System; using System.ComponentModel; using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; @@ -62,7 +61,7 @@ mockRepository.ReplayAll(); // Call - var properties = new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock); + var properties = new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock, null); // Assert Assert.IsNull(properties.Data); @@ -78,85 +77,21 @@ DistributionPropertiesReadOnly flags) { // Call - TestDelegate call = () => new LogNormalDistributionProperties(flags, null); + TestDelegate call = () => new LogNormalDistributionProperties(flags, null, null); // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Observable must be specified unless no property can be set."); } [Test] - public void SetProperties_MeanWithObserverable_ValueSetNotifyObservers() - { - // Setup - var observerableMock = mockRepository.StrictMock(); - observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - var properties = new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock) - { - Data = new LogNormalDistribution(2) - }; - mockRepository.ReplayAll(); - RoundedDouble newMeanValue = new RoundedDouble(3, 20); - - // Call - properties.Mean = newMeanValue; - - // Assert - Assert.AreEqual(newMeanValue, properties.Mean); - mockRepository.VerifyAll(); - } - - [Test] - [TestCase(DistributionPropertiesReadOnly.All)] - [TestCase(DistributionPropertiesReadOnly.StandardDeviation)] - public void SetProperties_ReadOnlyStandardDeviationWithObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) - { - // Setup - var observerableMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - var properties = new LogNormalDistributionProperties(propertiesReadOnly, observerableMock) - { - Data = new LogNormalDistribution(2) - }; - - // Call - TestDelegate test = () => properties.StandardDeviation = new RoundedDouble(2, 20); - - // Assert - const string expectedMessage = "StandardDeviation is set to be read-only."; - TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); - mockRepository.VerifyAll(); - } - - [Test] - public void SetProperties_StandardDeviationWithObserverable_ValueSetNotifyObservers() - { - // Setup - var observerableMock = mockRepository.StrictMock(); - observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - mockRepository.ReplayAll(); - var properties = new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock) - { - Data = new LogNormalDistribution(2) - }; - RoundedDouble newStandardDeviationValue = new RoundedDouble(3, 20); - - // Call - properties.StandardDeviation = newStandardDeviationValue; - - // Assert - Assert.AreEqual(newStandardDeviationValue, properties.StandardDeviation); - mockRepository.VerifyAll(); - } - - [Test] public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); // Call - var properties = new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock); + var properties = new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock, null); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionPropertiesTest.cs =================================================================== diff -u -rb8efcaa5b85f05c70660fa2f291d093500c90d2b -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionPropertiesTest.cs (.../NormalDistributionPropertiesTest.cs) (revision b8efcaa5b85f05c70660fa2f291d093500c90d2b) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionPropertiesTest.cs (.../NormalDistributionPropertiesTest.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -53,7 +53,7 @@ DistributionPropertiesReadOnly flags) { // Call - TestDelegate call = () => new NormalDistributionProperties(flags, null); + TestDelegate call = () => new NormalDistributionProperties(flags, null, null); // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Observable must be specified unless no property can be set."); @@ -68,7 +68,7 @@ mockRepository.ReplayAll(); // Call - var properties = new NormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock); + var properties = new NormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock, null); // Assert Assert.IsInstanceOf>(properties); @@ -86,7 +86,7 @@ mockRepository.ReplayAll(); // Call - var properties = new NormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock); + var properties = new NormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock, null); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TruncatedNormalDistributionPropertiesTest.cs =================================================================== diff -u -r8905298103eb01ce13dd5c1a2f267f879d4fda3e -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TruncatedNormalDistributionPropertiesTest.cs (.../TruncatedNormalDistributionPropertiesTest.cs) (revision 8905298103eb01ce13dd5c1a2f267f879d4fda3e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TruncatedNormalDistributionPropertiesTest.cs (.../TruncatedNormalDistributionPropertiesTest.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -53,7 +53,7 @@ DistributionPropertiesReadOnly flags) { // Call - TestDelegate call = () => new TruncatedNormalDistributionProperties(flags, null); + TestDelegate call = () => new TruncatedNormalDistributionProperties(flags, null, null); // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(call, "Observable must be specified unless no property can be set."); @@ -68,7 +68,7 @@ mockRepository.ReplayAll(); // Call - var properties = new TruncatedNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock); + var properties = new TruncatedNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock, null); // Assert Assert.IsInstanceOf>(properties); @@ -86,7 +86,7 @@ mockRepository.ReplayAll(); // Call - var properties = new TruncatedNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock); + var properties = new TruncatedNormalDistributionProperties(DistributionPropertiesReadOnly.None, observerableMock, null); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseBreakWaterPropertiesTest.cs =================================================================== diff -u -r7918a30f6ddc1ba9067a5eb461a1d7a8cb5bc8a0 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseBreakWaterPropertiesTest.cs (.../UseBreakWaterPropertiesTest.cs) (revision 7918a30f6ddc1ba9067a5eb461a1d7a8cb5bc8a0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/UseBreakWaterPropertiesTest.cs (.../UseBreakWaterPropertiesTest.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -56,27 +56,16 @@ public void Constructor_UseBreakWaterDataNull_ThrowsArgumentNullException() { // Call - TestDelegate test = () => new UseBreakWaterProperties(null, new TestCalculation()); + TestDelegate test = () => new UseBreakWaterProperties(null, null); // Assert var paramName = Assert.Throws(test).ParamName; Assert.AreEqual("useBreakWaterData", paramName); } [Test] - public void Constructor_CalculationNull_ThrowsArgumentNullException() + public void Constructor_WithUseBreakWaterData_ExpectedValues() { - // Call - TestDelegate test = () => new UseBreakWaterProperties(new TestUseBreakWater(), null); - - // Assert - var paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("calculation", paramName); - } - - [Test] - public void Constructor_ValidData_ExpectedValues() - { // Setup var useBreakWaterData = new TestUseBreakWater { @@ -85,7 +74,7 @@ }; // Call - var properties = new UseBreakWaterProperties(useBreakWaterData, new TestCalculation()); + var properties = new UseBreakWaterProperties(useBreakWaterData, null); // Assert Assert.IsTrue(properties.UseBreakWater); @@ -95,15 +84,15 @@ } [Test] - public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers() + public void SetProperties_IndividualProperties_UpdateData() { // Setup var breakWater = new BreakWater(BreakWaterType.Caisson, 2.2); var testUseBreakWater = new TestUseBreakWater { BreakWater = breakWater }; - var properties = new UseBreakWaterProperties(testUseBreakWater, new TestCalculation()); + var properties = new UseBreakWaterProperties(testUseBreakWater, null); // Call properties.UseBreakWater = true; @@ -122,23 +111,23 @@ [TestCase(false)] public void DikeHeight_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) { - SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.BreakWaterHeight = new Random(21).NextRoundedDouble()); + SetPropertyAndVerifyNotifcationsAndHandlerCall(hasOutput, properties => properties.BreakWaterHeight = new Random(21).NextRoundedDouble()); } [Test] [TestCase(true)] [TestCase(false)] public void BreakWaterType_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) { - SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.BreakWaterType = new Random(21).NextEnumValue()); + SetPropertyAndVerifyNotifcationsAndHandlerCall(hasOutput, properties => properties.BreakWaterType = new Random(21).NextEnumValue()); } [Test] [TestCase(true)] [TestCase(false)] public void UseBreakWater_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) { - SetPropertyAndVerifyNotifcationsAndOutput(hasOutput, properties => properties.UseBreakWater = new Random(21).NextBoolean()); + SetPropertyAndVerifyNotifcationsAndHandlerCall(hasOutput, properties => properties.UseBreakWater = new Random(21).NextBoolean()); } [Test] @@ -191,7 +180,7 @@ }; // Call - var properties = new UseBreakWaterProperties(testUseBreakWater, new TestCalculation()); + var properties = new UseBreakWaterProperties(testUseBreakWater, null); // Assert var dynamicPropertyBag = new DynamicPropertyBag(properties); @@ -230,17 +219,17 @@ public BreakWater BreakWater { get; set; } } - private void SetPropertyAndVerifyNotifcationsAndOutput( + private void SetPropertyAndVerifyNotifcationsAndHandlerCall( bool hasOutput, Action setProperty) { // Setup var mocks = new MockRepository(); var calculationObserver = mocks.StrictMock(); var inputObserver = mocks.StrictMock(); - int numberOfChangedProperties = hasOutput ? 1 : 0; - calculationObserver.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties); inputObserver.Expect(o => o.UpdateObserver()); + var handler = mocks.StrictMock(); + handler.Expect(o => o.PropertyChanged()); mocks.ReplayAll(); var calculation = new TestCalculation(); @@ -254,14 +243,12 @@ input.Attach(inputObserver); input.BreakWater = new BreakWater(BreakWaterType.Caisson, 3.2); - var properties = new UseBreakWaterProperties(input, calculation); + var properties = new UseBreakWaterProperties(input, handler); // Call setProperty(properties); // Assert - Assert.IsFalse(calculation.HasOutput); - mocks.VerifyAll(); } } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs =================================================================== diff -u -rbb80820ff4a4e09793da242cb7b36ca2bce59c32 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision bb80820ff4a4e09793da242cb7b36ca2bce59c32) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -30,6 +30,7 @@ using Core.Common.Utils; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; @@ -48,7 +49,9 @@ /// ViewModel of for properties panel. /// public class GrassCoverErosionInwardsInputContextProperties : ObjectProperties, - IHasHydraulicBoundaryLocationProperty + IHasHydraulicBoundaryLocationProperty, + UseBreakWaterProperties.IChangeHandler, + DistributionPropertiesBase.IChangeHandler { private const int dikeProfilePropertyIndex = 1; private const int worldReferencePointPropertyIndex = 2; @@ -76,7 +79,7 @@ { data.WrappedData.DikeProfile = value; GrassCoverErosionInwardsHelper.Update(data.FailureMechanism.SectionResults, data.Calculation); - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -109,7 +112,7 @@ set { data.WrappedData.Orientation = value; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -124,7 +127,7 @@ { return data.WrappedData.DikeProfile == null ? new UseBreakWaterProperties() : - new UseBreakWaterProperties(data.WrappedData, data.Calculation); + new UseBreakWaterProperties(data.WrappedData, this); } } @@ -171,7 +174,7 @@ set { data.WrappedData.DikeHeight = value; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -189,7 +192,7 @@ set { data.WrappedData.DikeHeightCalculationType = value; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -202,7 +205,7 @@ { get { - return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.CriticalFlowRate }; @@ -225,7 +228,7 @@ set { data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -252,14 +255,29 @@ data.AvailableHydraulicBoundaryLocations, calculationLocation); } - private void NotifyPropertyChanged() + void DistributionPropertiesBase.IChangeHandler.PropertyChanged() { + ClearCalculationOutput(); + } + + void UseBreakWaterProperties.IChangeHandler.PropertyChanged() + { + ClearCalculationOutput(); + } + + private void ClearOutputAndNotifyPropertyChanged() + { + ClearCalculationOutput(); + data.WrappedData.NotifyObservers(); + } + + private void ClearCalculationOutput() + { IEnumerable affectedCalculation = RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(data.Calculation); foreach (var calculation in affectedCalculation) { calculation.NotifyObservers(); } - data.WrappedData.NotifyObservers(); } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs =================================================================== diff -u -r9a342802cbb99bf909f9c93cdbd5826245b70905 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 9a342802cbb99bf909f9c93cdbd5826245b70905) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsInputContextPropertiesTest.cs (.../GrassCoverErosionInwardsInputContextPropertiesTest.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -244,14 +244,24 @@ [Test] [TestCase(true)] [TestCase(false)] - public void UseBreakWater_WithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + public void BreakWater_UseBreakWaterChangedWithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) { SetPropertyAndVerifyNotifcationsAndOutput( hasOutput, properties => properties.BreakWater.UseBreakWater = new Random(21).NextBoolean()); } [Test] + [TestCase(true)] + [TestCase(false)] + public void CriticalFlowRate_MeanChangedWithOrWithoutOutput_HasOutputFalseInputNotifiedAndCalculationNotifiedWhenHadOutput(bool hasOutput) + { + SetPropertyAndVerifyNotifcationsAndOutput( + hasOutput, + properties => properties.CriticalFlowRate.Mean = new Random(21).NextRoundedDouble()); + } + + [Test] public void SelectedHydraulicBoundaryLocation_InputNoLocation_ReturnsNull() { // Setup Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs =================================================================== diff -u -r57a8a7c5fb3b437a1ed450361e91bc79d0ee5d76 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 57a8a7c5fb3b437a1ed450361e91bc79d0ee5d76) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -24,6 +24,7 @@ using Core.Common.Gui.Attributes; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Utils; @@ -39,7 +40,8 @@ public class HeightStructuresInputContextProperties : StructuresInputBaseProperties, - HeightStructuresFailureMechanism> + HeightStructuresFailureMechanism>, + DistributionPropertiesBase.IChangeHandler { private const int structurePropertyIndex = 1; private const int structureLocationPropertyIndex = 2; @@ -61,24 +63,25 @@ /// /// Creates a new instance of the class. /// - public HeightStructuresInputContextProperties() : base(new ConstructionProperties - { - StructurePropertyIndex = structurePropertyIndex, - StructureLocationPropertyIndex = structureLocationPropertyIndex, - StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex, - FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex, - WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex, - StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex, - AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex, - CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex, - FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex, - ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex, - UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex, - UseForeshorePropertyIndex = useForeshorePropertyIndex, - ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex, - HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex, - StormDurationPropertyIndex = stormDurationPropertyIndex - }) {} + public HeightStructuresInputContextProperties() : base( + new ConstructionProperties + { + StructurePropertyIndex = structurePropertyIndex, + StructureLocationPropertyIndex = structureLocationPropertyIndex, + StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex, + FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex, + WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex, + StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex, + AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex, + CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex, + FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex, + ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex, + UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex, + UseForeshorePropertyIndex = useForeshorePropertyIndex, + ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex, + HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex, + StormDurationPropertyIndex = stormDurationPropertyIndex + }) {} #region Schematization @@ -91,7 +94,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.LevelCrestStructure }; @@ -110,6 +113,11 @@ return data.FailureMechanism.HeightStructures; } + void DistributionPropertiesBase.IChangeHandler.PropertyChanged() + { + // TODO WTI-972 + } + protected override void AfterSettingStructure() { StructuresHelper.Update(data.FailureMechanism.SectionResults, data.Calculation); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs =================================================================== diff -u -r917edb0f289fcc7259995bc8da2678142c16620c -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 917edb0f289fcc7259995bc8da2678142c16620c) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingInputContextProperties.cs (.../PipingInputContextProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -154,7 +154,7 @@ set { data.WrappedData.HydraulicBoundaryLocation = value.HydraulicBoundaryLocation; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -172,7 +172,7 @@ set { data.WrappedData.AssessmentLevel = value; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -189,7 +189,7 @@ set { data.WrappedData.UseAssessmentLevelManualInput = value; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -207,7 +207,7 @@ set { data.WrappedData.DampingFactorExit = value.Distribution; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -225,7 +225,7 @@ set { data.WrappedData.PhreaticLevelExit = value.Distribution; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -262,7 +262,7 @@ { data.WrappedData.SurfaceLine = value; PipingInputService.SetMatchingStochasticSoilModel(data.WrappedData, GetAvailableStochasticSoilModels()); - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } } @@ -284,7 +284,7 @@ { data.WrappedData.StochasticSoilModel = value; PipingInputService.SyncStochasticSoilProfileWithStochasticSoilModel(data.WrappedData); - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } } @@ -305,7 +305,7 @@ if (!ReferenceEquals(value, data.WrappedData.StochasticSoilProfile)) { data.WrappedData.StochasticSoilProfile = value; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } } @@ -323,7 +323,7 @@ set { data.WrappedData.EntryPointL = value; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -340,7 +340,7 @@ set { data.WrappedData.ExitPointL = value; - NotifyPropertyChanged(); + ClearOutputAndNotifyPropertyChanged(); } } @@ -437,7 +437,7 @@ #endregion - private void NotifyPropertyChanged() + private void ClearOutputAndNotifyPropertyChanged() { IEnumerable affectedCalculation = RingtoetsCommonDataSynchronizationService.ClearCalculationOutput(data.PipingCalculation); foreach (var calculation in affectedCalculation) Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs =================================================================== diff -u -rbb80820ff4a4e09793da242cb7b36ca2bce59c32 -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision bb80820ff4a4e09793da242cb7b36ca2bce59c32) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/PropertyClasses/WaveConditionsInputContextProperties.cs (.../WaveConditionsInputContextProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -47,7 +47,8 @@ /// public abstract class WaveConditionsInputContextProperties : ObjectProperties, IHasHydraulicBoundaryLocationProperty, - IHasForeshoreProfileProperty + IHasForeshoreProfileProperty, + UseBreakWaterProperties.IChangeHandler where T : WaveConditionsInputContext { private const int hydraulicBoundaryLocationPropertyIndex = 0; @@ -233,7 +234,7 @@ { return data.WrappedData.ForeshoreProfile == null ? new UseBreakWaterProperties() : - new UseBreakWaterProperties(data.WrappedData, data.Calculation); + new UseBreakWaterProperties(data.WrappedData, this); } } @@ -295,6 +296,11 @@ } } + void UseBreakWaterProperties.IChangeHandler.PropertyChanged() + { + // TODO WTI-969/WTI-970/WTI-971 + } + public virtual IEnumerable GetAvailableForeshoreProfiles() { return data.ForeshoreProfiles; Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs =================================================================== diff -u -rae5c573fb82f4b30350f63cb6f202ae99275f4ff -r68953cc654409e65478d6aa4fb8c1cf44b116d9d --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision ae5c573fb82f4b30350f63cb6f202ae99275f4ff) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/PropertyClasses/StabilityPointStructuresInputContextProperties.cs (.../StabilityPointStructuresInputContextProperties.cs) (revision 68953cc654409e65478d6aa4fb8c1cf44b116d9d) @@ -27,6 +27,7 @@ using Core.Common.Utils.Attributes; using Core.Common.Utils.Reflection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.PropertyClasses; @@ -44,7 +45,9 @@ public class StabilityPointStructuresInputContextProperties : StructuresInputBaseProperties, - StabilityPointStructuresFailureMechanism> + StabilityPointStructuresFailureMechanism>, + DistributionPropertiesBase.IChangeHandler, + DistributionPropertiesBase.IChangeHandler { private const int hydraulicBoundaryLocationPropertyIndex = 1; private const int volumicWeightWaterPropertyIndex = 2; @@ -91,23 +94,23 @@ /// public StabilityPointStructuresInputContextProperties() : base(new ConstructionProperties - { - StructurePropertyIndex = structurePropertyIndex, - StructureLocationPropertyIndex = structureLocationPropertyIndex, - StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex, - FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex, - WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex, - StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex, - AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex, - CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex, - FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex, - ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex, - UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex, - UseForeshorePropertyIndex = useForeshorePropertyIndex, - ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex, - HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex, - StormDurationPropertyIndex = stormDurationPropertyIndex - }) {} + { + StructurePropertyIndex = structurePropertyIndex, + StructureLocationPropertyIndex = structureLocationPropertyIndex, + StructureNormalOrientationPropertyIndex = structureNormalOrientationPropertyIndex, + FlowWidthAtBottomProtectionPropertyIndex = flowWidthAtBottomProtectionPropertyIndex, + WidthFlowAperturesPropertyIndex = widthFlowAperturesPropertyIndex, + StorageStructureAreaPropertyIndex = storageStructureAreaPropertyIndex, + AllowedLevelIncreaseStoragePropertyIndex = allowedLevelIncreaseStoragePropertyIndex, + CriticalOvertoppingDischargePropertyIndex = criticalOvertoppingDischargePropertyIndex, + FailureProbabilityStructureWithErosionPropertyIndex = failureProbabilityStructureWithErosionPropertyIndex, + ForeshoreProfilePropertyIndex = foreshoreProfilePropertyIndex, + UseBreakWaterPropertyIndex = useBreakWaterPropertyIndex, + UseForeshorePropertyIndex = useForeshorePropertyIndex, + ModelFactorSuperCriticalFlowPropertyIndex = modelFactorSuperCriticalFlowPropertyIndex, + HydraulicBoundaryLocationPropertyIndex = hydraulicBoundaryLocationPropertyIndex, + StormDurationPropertyIndex = stormDurationPropertyIndex + }) {} [DynamicVisibleValidationMethod] public bool DynamicVisibleValidationMethod(string propertyName) @@ -169,6 +172,16 @@ return data.FailureMechanism.StabilityPointStructures; } + void DistributionPropertiesBase.IChangeHandler.PropertyChanged() + { + // TODO WTI-974 + } + + void DistributionPropertiesBase.IChangeHandler.PropertyChanged() + { + // TODO WTI-974 + } + protected override void AfterSettingStructure() { StructuresHelper.Update(data.FailureMechanism.SectionResults, data.Calculation); @@ -202,7 +215,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.InsideWaterLevelFailureConstruction }; @@ -218,7 +231,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.InsideWaterLevel }; @@ -248,7 +261,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.StandardDeviation, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.StandardDeviation, data.WrappedData, this) { Data = data.WrappedData.DrainCoefficient }; @@ -281,7 +294,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.FlowVelocityStructureClosable }; @@ -346,7 +359,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.LevelCrestStructure }; @@ -362,7 +375,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.ThresholdHeightOpenWeir }; @@ -379,7 +392,7 @@ { get { - return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new LogNormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.AreaFlowApertures }; @@ -560,7 +573,7 @@ { get { - return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData) + return new NormalDistributionProperties(DistributionPropertiesReadOnly.None, data.WrappedData, this) { Data = data.WrappedData.BankWidth };