Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r7cfeb195650f713f29c53e9926499fa63e4c79ea -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7cfeb195650f713f29c53e9926499fa63e4c79ea) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -369,6 +369,42 @@ } /// + /// Looks up a localized string similar to Het soort kansverdeling waarin deze parameter gedefinieerd wordt.. + /// + public static string Distribution_DestributionType_Description { + get { + return ResourceManager.GetString("Distribution_DestributionType_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Type verdeling. + /// + public static string Distribution_DestributionType_DisplayName { + get { + return ResourceManager.GetString("Distribution_DestributionType_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Lognormaal. + /// + public static string DistributionType_LogNormal { + get { + return ResourceManager.GetString("DistributionType_LogNormal", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Normale verdeling. + /// + public static string DistributionType_Normal { + get { + return ResourceManager.GetString("DistributionType_Normal", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap EditDocumentIcon { @@ -669,24 +705,6 @@ } /// - /// Looks up a localized string similar to Het soort kansverdeling waarin deze parameter gedefinieerd wordt.. - /// - public static string NormalDistribution_DestributionType_Description { - get { - return ResourceManager.GetString("NormalDistribution_DestributionType_Description", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Type verdeling. - /// - public static string NormalDistribution_DestributionType_DisplayName { - get { - return ResourceManager.GetString("NormalDistribution_DestributionType_DisplayName", resourceCulture); - } - } - - /// /// Looks up a localized string similar to De gemiddelde waarde van de normale verdeling.. /// public static string NormalDistribution_Mean_Description { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -r7cfeb195650f713f29c53e9926499fa63e4c79ea -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 7cfeb195650f713f29c53e9926499fa63e4c79ea) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -343,10 +343,10 @@ De standaardafwijking van de lognormale verdeling. - + Het soort kansverdeling waarin deze parameter gedefinieerd wordt. - + Type verdeling @@ -394,4 +394,10 @@ Betrouwbaarheidsindex faalkanseis [-] + + Lognormaal + + + Normale verdeling + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionProperties.cs =================================================================== diff -u -rf5ac9de8b45cef4515fa7a051c5af54446f96712 -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionProperties.cs (.../DistributionProperties.cs) (revision f5ac9de8b45cef4515fa7a051c5af54446f96712) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionProperties.cs (.../DistributionProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -20,9 +20,9 @@ // All rights reserved. using System; -using System.ComponentModel; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.Probabilistics; @@ -33,15 +33,25 @@ /// /// Property for probabilistic distribution. /// - [TypeConverter(typeof(ExpandableObjectConverter))] public abstract class DistributionProperties : ObjectProperties { + private readonly bool isMeanReadOnly; + private readonly bool isStandardDeviationReadOnly; protected IObservable Observerable; - [ResourcesDisplayName(typeof(Resources), "NormalDistribution_DestributionType_DisplayName")] - [ResourcesDescription(typeof(Resources), "NormalDistribution_DestributionType_Description")] + protected DistributionProperties(DistributionPropertiesReadOnly propertiesReadOnly) + { + isStandardDeviationReadOnly = propertiesReadOnly == DistributionPropertiesReadOnly.All || propertiesReadOnly == DistributionPropertiesReadOnly.StandardDeviation; + isMeanReadOnly = propertiesReadOnly == DistributionPropertiesReadOnly.All || propertiesReadOnly == DistributionPropertiesReadOnly.Mean; + } + + [PropertyOrder(1)] + [ResourcesDisplayName(typeof(Resources), "Distribution_DestributionType_DisplayName")] + [ResourcesDescription(typeof(Resources), "Distribution_DestributionType_Description")] public abstract string DistributionType { get; } + [PropertyOrder(2)] + [DynamicReadOnly] [ResourcesDisplayName(typeof(Resources), "NormalDistribution_Mean_DisplayName")] [ResourcesDescription(typeof(Resources), "NormalDistribution_Mean_Description")] public virtual RoundedDouble Mean @@ -52,15 +62,21 @@ } set { + if (isMeanReadOnly) + { + throw new ArgumentException("Mean is set to be read-only."); + } if (Observerable == null) { - throw new ArgumentException(); + throw new ArgumentException("No observerable object set."); } data.Mean = new RoundedDouble(data.StandardDeviation.NumberOfDecimalPlaces, value); Observerable.NotifyObservers(); } } + [PropertyOrder(3)] + [DynamicReadOnly] [ResourcesDisplayName(typeof(Resources), "NormalDistribution_StandardDeviation_DisplayName")] [ResourcesDescription(typeof(Resources), "NormalDistribution_StandardDeviation_Description")] public virtual RoundedDouble StandardDeviation @@ -71,15 +87,33 @@ } set { + if (isStandardDeviationReadOnly) + { + throw new ArgumentException("StandardDeviation is set to be read-only."); + } if (Observerable == null) { - throw new ArgumentException(); + throw new ArgumentException("No observerable object set."); } data.StandardDeviation = new RoundedDouble(data.StandardDeviation.NumberOfDecimalPlaces, value); Observerable.NotifyObservers(); } } + [DynamicReadOnlyValidationMethod] + public bool DynamicReadOnlyValidationMethod(string propertyName) + { + switch (propertyName) + { + case "Mean": + return isMeanReadOnly; + case "StandardDeviation": + return isStandardDeviationReadOnly; + default: + return false; + } + } + public override string ToString() { return data == null ? Resources.NormalDistribution_StandardDeviation_DisplayName : Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionPropertiesReadOnly.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionPropertiesReadOnly.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionPropertiesReadOnly.cs (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -0,0 +1,49 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +namespace Ringtoets.Common.Forms.PropertyClasses +{ + /// + /// All options to mark properties of as read-only. + /// + public enum DistributionPropertiesReadOnly + { + /// + /// Mark both and read-only. + /// + All, + + /// + /// Mark read-only. + /// + Mean, + + /// + /// Mark read-only. + /// + StandardDeviation, + + /// + /// Mark both and editable. + /// + None + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionProperties.cs =================================================================== diff -u -r816ada789a47f320a798b9a66059fbfec54947ff -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionProperties.cs (.../LogNormalDistributionProperties.cs) (revision 816ada789a47f320a798b9a66059fbfec54947ff) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionProperties.cs (.../LogNormalDistributionProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -19,9 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System.ComponentModel; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; using Ringtoets.Common.Data.Probabilistics; @@ -33,14 +33,21 @@ /// An implementation for /// properties. /// - [TypeConverter(typeof(ExpandableObjectConverter))] public class LogNormalDistributionProperties : DistributionProperties { /// + /// Creates a new read-only instance of . + /// + public LogNormalDistributionProperties() : this(null, DistributionPropertiesReadOnly.All) {} + + /// /// Creates a new instance of . /// /// Object to observe to notify upon change. - public LogNormalDistributionProperties(IObservable observerable) + /// Sets if and/or + /// should be marked read-only. + public LogNormalDistributionProperties(IObservable observerable, DistributionPropertiesReadOnly propertiesReadOnly) + : base(propertiesReadOnly) { Observerable = observerable; } @@ -49,7 +56,7 @@ { get { - return "Lognormaal"; + return Resources.DistributionType_LogNormal; } } @@ -66,6 +73,7 @@ } } + [DynamicReadOnly] [ResourcesDescription(typeof(Resources), "LogNormalDistribution_StandardDeviation_Description")] public override RoundedDouble StandardDeviation { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/NormalDistributionProperties.cs =================================================================== diff -u -r37a53b1ca9a4cdfc6e6df7f065cd540c627f2622 -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/NormalDistributionProperties.cs (.../NormalDistributionProperties.cs) (revision 37a53b1ca9a4cdfc6e6df7f065cd540c627f2622) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/NormalDistributionProperties.cs (.../NormalDistributionProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -19,34 +19,41 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System.ComponentModel; using Core.Common.Base; using Core.Common.Gui.PropertyBag; using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Forms.Properties; namespace Ringtoets.Common.Forms.PropertyClasses { /// /// An implementation for /// properties. /// - [TypeConverter(typeof(ExpandableObjectConverter))] public class NormalDistributionProperties : DistributionProperties { /// + /// Creates a new read-only instance of . + /// + public NormalDistributionProperties() : this(null, DistributionPropertiesReadOnly.All) {} + + /// /// Creates a new instance of . /// /// Object to observe to notify upon change. - public NormalDistributionProperties(IObservable observerable) + /// Sets if and/or + /// should be marked read-only. + public NormalDistributionProperties(IObservable observerable, DistributionPropertiesReadOnly propertiesReadOnly) : base(propertiesReadOnly) { Observerable = observerable; + } public override string DistributionType { get { - return "Normale verdeling"; + return Resources.DistributionType_Normal; } } } Fisheye: Tag 26359a31a29af21b6690cacd9b810b1565af9e4b refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/ReadOnlyNormalDistributionProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -r7cfeb195650f713f29c53e9926499fa63e4c79ea -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 7cfeb195650f713f29c53e9926499fa63e4c79ea) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -62,11 +62,10 @@ Resources.resx + - - Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/DistributionPropertiesTest.cs =================================================================== diff -u -rf5ac9de8b45cef4515fa7a051c5af54446f96712 -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/DistributionPropertiesTest.cs (.../DistributionPropertiesTest.cs) (revision f5ac9de8b45cef4515fa7a051c5af54446f96712) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/DistributionPropertiesTest.cs (.../DistributionPropertiesTest.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -24,9 +24,11 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.Probabilistics; +using Ringtoets.Common.Forms.Properties; using Ringtoets.Common.Forms.PropertyClasses; namespace Ringtoets.Common.Forms.Test.PropertyClasses @@ -43,19 +45,42 @@ } [Test] - public void Constructor_ExpectedValues() + public void Constructor_WithParameters_ExpectedValues() { // Call - var properties = new SimpleDistributionProperties(); + var properties = new SimpleDistributionProperties(DistributionPropertiesReadOnly.None); // Assert - Assert.IsInstanceOf>(properties); + Assert.IsInstanceOf(properties); Assert.IsNull(properties.Data); Assert.AreEqual("Standaardafwijking", properties.ToString()); Assert.AreEqual("SimpleDestributionType", properties.DistributionType); + var expectedToString = Resources.NormalDistribution_StandardDeviation_DisplayName; + Assert.AreEqual(expectedToString, properties.ToString()); } [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 properties = new SimpleDistributionProperties(propertiesReadOnly); + + // Call + var meanIsReadOnly = properties.DynamicReadOnlyValidationMethod("Mean"); + var standardDeviationIsReadOnly = properties.DynamicReadOnlyValidationMethod("StandardDeviation"); + var doesNotExist = properties.DynamicReadOnlyValidationMethod("DoesNotExist"); + + // Assert + Assert.AreEqual(expectStandardDeviationReadOnly, standardDeviationIsReadOnly); + Assert.AreEqual(expectMeanReadOnly, meanIsReadOnly); + Assert.IsFalse(doesNotExist); + } + + [Test] public void Data_SetNewDistributionContextInstance_ReturnCorrectPropertyValues() { // Setup @@ -64,47 +89,54 @@ Mean = new RoundedDouble(1, 1.1), StandardDeviation = new RoundedDouble(2, 2.2) }; + var propertiesReadOnly = DistributionPropertiesReadOnly.None; - var properties = new SimpleDistributionProperties(); + var properties = new SimpleDistributionProperties(propertiesReadOnly); // Call properties.Data = distribution; // Assert Assert.AreEqual(distribution.Mean, properties.Mean); Assert.AreEqual(distribution.StandardDeviation, properties.StandardDeviation); + var expectedToString = string.Format("{0} ({1} = {2})", distribution.Mean, Resources.NormalDistribution_StandardDeviation_DisplayName, distribution.StandardDeviation); + Assert.AreEqual(expectedToString, properties.ToString()); } [Test] - public void SetProperties_MeanWithoutObserverable_ThrowsArgumentException() + [TestCase(DistributionPropertiesReadOnly.None)] + [TestCase(DistributionPropertiesReadOnly.StandardDeviation)] + public void SetProperties_EditableMeanWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) { // Setup - var properties = new SimpleDistributionProperties + var properties = new SimpleDistributionProperties(propertiesReadOnly) { - Data = new SimpleDistribution(), + Data = new SimpleDistribution() }; // Call TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20); // Assert - Assert.Throws(test); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "No observerable object set."); } [Test] - public void SetProperties_StandardDeviationWithoutObserverable_ThrowsArgumentException() + [TestCase(DistributionPropertiesReadOnly.All)] + [TestCase(DistributionPropertiesReadOnly.Mean)] + public void SetProperties_ReadOnlyMeanWithObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) { // Setup - var properties = new SimpleDistributionProperties + var properties = new SimpleDistributionProperties(propertiesReadOnly) { Data = new SimpleDistribution() }; // Call - TestDelegate test = () => properties.StandardDeviation = new RoundedDouble(2, 20); + TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20); // Assert - Assert.Throws(test); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "Mean is set to be read-only."); } [Test] @@ -113,9 +145,9 @@ // Setup var observerableMock = mockRepository.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - var properties = new SimpleObserverableDistributionProperties(observerableMock) + var properties = new SimpleObserverableDistributionProperties(observerableMock, DistributionPropertiesReadOnly.None) { - Data = new SimpleDistribution(), + Data = new SimpleDistribution() }; mockRepository.ReplayAll(); RoundedDouble newMeanValue = new RoundedDouble(3, 20); @@ -129,14 +161,50 @@ } [Test] + [TestCase(DistributionPropertiesReadOnly.None)] + [TestCase(DistributionPropertiesReadOnly.Mean)] + public void SetProperties_EditableStandardDeviationWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) + { + // Setup + var properties = new SimpleDistributionProperties(propertiesReadOnly) + { + Data = new SimpleDistribution() + }; + + // Call + TestDelegate test = () => properties.StandardDeviation = new RoundedDouble(2, 20); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "No observerable object set."); + } + + [Test] + [TestCase(DistributionPropertiesReadOnly.All)] + [TestCase(DistributionPropertiesReadOnly.StandardDeviation)] + public void SetProperties_ReadOnlyStandardDeviationWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) + { + // Setup + var properties = new SimpleDistributionProperties(propertiesReadOnly) + { + Data = new SimpleDistribution() + }; + + // Call + TestDelegate test = () => properties.StandardDeviation = new RoundedDouble(2, 20); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "StandardDeviation is set to be read-only."); + } + + [Test] public void SetProperties_StandardDeviationWithObserverable_ValueSetNotifyObservers() { // Setup var observerableMock = mockRepository.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - var properties = new SimpleObserverableDistributionProperties(observerableMock) + var properties = new SimpleObserverableDistributionProperties(observerableMock, DistributionPropertiesReadOnly.None) { - Data = new SimpleDistribution(), + Data = new SimpleDistribution() }; mockRepository.ReplayAll(); RoundedDouble newStandardDeviationValue = new RoundedDouble(3, 20); @@ -150,17 +218,21 @@ } [Test] - public void PropertyAttributes_ReturnExpectedValues() + [TestCase(DistributionPropertiesReadOnly.All, true, true)] + [TestCase(DistributionPropertiesReadOnly.Mean, true, false)] + [TestCase(DistributionPropertiesReadOnly.None, false, false)] + [TestCase(DistributionPropertiesReadOnly.StandardDeviation, false, true)] + public void PropertyAttributes_ReturnExpectedValues(DistributionPropertiesReadOnly propertiesReadOnly, bool expectMeanReadOnly, bool expectStandardDeviationReadOnly) { // Call - var properties = new SimpleDistributionProperties + var properties = new SimpleDistributionProperties(propertiesReadOnly) { Data = new SimpleDistribution() }; // Assert TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); - Assert.IsInstanceOf(classTypeConverter); + Assert.IsNotInstanceOf(classTypeConverter); var dynamicPropertyBag = new DynamicPropertyBag(properties); PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); @@ -169,22 +241,27 @@ PropertyDescriptor distributionTypeProperty = dynamicProperties[0]; Assert.IsNotNull(distributionTypeProperty); Assert.IsTrue(distributionTypeProperty.IsReadOnly); + Assert.AreEqual("Type verdeling", distributionTypeProperty.DisplayName); + Assert.AreEqual("Het soort kansverdeling waarin deze parameter gedefinieerd wordt.", distributionTypeProperty.Description); PropertyDescriptor meanProperty = dynamicProperties[1]; Assert.IsNotNull(meanProperty); - Assert.IsFalse(meanProperty.IsReadOnly); + Assert.AreEqual(expectMeanReadOnly, meanProperty.IsReadOnly); Assert.AreEqual("Verwachtingswaarde", meanProperty.DisplayName); Assert.AreEqual("De gemiddelde waarde van de normale verdeling.", meanProperty.Description); PropertyDescriptor standardDeviationProperty = dynamicProperties[2]; Assert.IsNotNull(standardDeviationProperty); - Assert.IsFalse(standardDeviationProperty.IsReadOnly); + Assert.AreEqual(expectStandardDeviationReadOnly, standardDeviationProperty.IsReadOnly); Assert.AreEqual("Standaardafwijking", standardDeviationProperty.DisplayName); Assert.AreEqual("De standaardafwijking van de normale verdeling.", standardDeviationProperty.Description); } private class SimpleDistributionProperties : DistributionProperties { + public SimpleDistributionProperties(DistributionPropertiesReadOnly propertiesReadOnly) + : base(propertiesReadOnly) {} + public override string DistributionType { get @@ -196,7 +273,8 @@ private class SimpleObserverableDistributionProperties : DistributionProperties { - public SimpleObserverableDistributionProperties(IObservable observerable) + public SimpleObserverableDistributionProperties(IObservable observerable, DistributionPropertiesReadOnly propertiesReadOnly) + : base(propertiesReadOnly) { Observerable = observerable; } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionPropertiesTest.cs =================================================================== diff -u -r5b8f476716cb75977616203318fa250f608fe7a5 -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionPropertiesTest.cs (.../LogNormalDistributionPropertiesTest.cs) (revision 5b8f476716cb75977616203318fa250f608fe7a5) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionPropertiesTest.cs (.../LogNormalDistributionPropertiesTest.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -26,6 +26,7 @@ using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; using Core.Common.Utils.Attributes; using NUnit.Framework; using Rhino.Mocks; @@ -46,103 +47,82 @@ } [Test] - public void Constructor_ExpectedValues() + public void Constructor_WithoutParameters_ExpectedValues() { - // Setup - var observerableMock = mockRepository.StrictMock(); - mockRepository.ReplayAll(); - // Call - var properties = new LogNormalDistributionProperties(observerableMock); + var properties = new LogNormalDistributionProperties(); // Assert Assert.IsInstanceOf(properties); Assert.IsNull(properties.Data); Assert.AreEqual("Lognormaal", properties.DistributionType); - mockRepository.VerifyAll(); } [Test] - public void PropertyAttributes_ReturnExpectedValues() + public void Constructor_WithParameters_ExpectedValues() { // Setup var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); // Call - var properties = new LogNormalDistributionProperties(observerableMock); + var properties = new LogNormalDistributionProperties(observerableMock, DistributionPropertiesReadOnly.None); // Assert - TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); - Assert.IsInstanceOf(classTypeConverter); - - var dynamicPropertyBag = new DynamicPropertyBag(properties); - PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); - Assert.AreEqual(4, dynamicProperties.Count); - - var meanAttributes = Attribute.GetCustomAttributes(properties.GetType().GetProperty("Mean")); - Assert.IsNotNull(meanAttributes); - AssertAttributesOfType(meanAttributes, "Verwachtingswaarde", - attribute => attribute.DisplayName); - AssertAttributesOfType(meanAttributes, - "De gemiddelde waarde van de lognormale verdeling.", - attribute => attribute.Description); - - var standardAttributes = Attribute.GetCustomAttributes(properties.GetType().GetProperty("StandardDeviation")); - Assert.IsNotNull(standardAttributes); - AssertAttributesOfType(standardAttributes, "Standaardafwijking", - attribute => attribute.DisplayName); - AssertAttributesOfType(standardAttributes, - "De standaardafwijking van de lognormale verdeling.", - attribute => attribute.Description); - + Assert.IsInstanceOf(properties); + Assert.IsNull(properties.Data); + Assert.AreEqual("Lognormaal", properties.DistributionType); mockRepository.VerifyAll(); } - [Test] - public void SetProperties_MeanWithoutObserverable_ThrowsArgumentException() + [TestCase(DistributionPropertiesReadOnly.None)] + [TestCase(DistributionPropertiesReadOnly.StandardDeviation)] + public void SetProperties_EditableMeanWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) { // Setup - var properties = new LogNormalDistributionProperties(null) + var properties = new LogNormalDistributionProperties(null, propertiesReadOnly) { - Data = new LogNormalDistribution(2), + Data = new LogNormalDistribution(2) }; // Call TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20); // Assert - Assert.Throws(test); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "No observerable object set."); } [Test] - public void SetProperties_StandardDeviationWithoutObserverable_ThrowsArgumentException() + [TestCase(DistributionPropertiesReadOnly.All)] + [TestCase(DistributionPropertiesReadOnly.Mean)] + public void SetProperties_ReadOnlyMeanWithObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) { // Setup - var properties = new LogNormalDistributionProperties(null) + var observerableMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + var properties = new LogNormalDistributionProperties(observerableMock, propertiesReadOnly) { Data = new LogNormalDistribution(2) }; // Call - TestDelegate test = () => properties.StandardDeviation = new RoundedDouble(2, 20); + TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20); // Assert - Assert.Throws(test); + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "Mean is set to be read-only."); + mockRepository.VerifyAll(); } - - [Test] public void SetProperties_MeanWithObserverable_ValueSetNotifyObservers() { // Setup var observerableMock = mockRepository.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - var properties = new LogNormalDistributionProperties(observerableMock) + var properties = new LogNormalDistributionProperties(observerableMock, DistributionPropertiesReadOnly.None) { - Data = new LogNormalDistribution(3) + Data = new LogNormalDistribution(2) }; mockRepository.ReplayAll(); RoundedDouble newMeanValue = new RoundedDouble(3, 20); @@ -156,16 +136,55 @@ } [Test] + [TestCase(DistributionPropertiesReadOnly.None)] + [TestCase(DistributionPropertiesReadOnly.Mean)] + public void SetProperties_EditableStandardDeviationWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly) + { + // Setup + var properties = new LogNormalDistributionProperties(null, propertiesReadOnly) + { + Data = new LogNormalDistribution(2) + }; + + // Call + TestDelegate test = () => properties.StandardDeviation = new RoundedDouble(2, 20); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "No observerable object set."); + } + + [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(observerableMock, propertiesReadOnly) + { + Data = new LogNormalDistribution(2) + }; + + // Call + TestDelegate test = () => properties.StandardDeviation = new RoundedDouble(2, 20); + + // Assert + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "StandardDeviation is set to be read-only."); + mockRepository.VerifyAll(); + } + + [Test] public void SetProperties_StandardDeviationWithObserverable_ValueSetNotifyObservers() { // Setup var observerableMock = mockRepository.StrictMock(); observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - var properties = new LogNormalDistributionProperties(observerableMock) + mockRepository.ReplayAll(); + var properties = new LogNormalDistributionProperties(observerableMock, DistributionPropertiesReadOnly.None) { - Data = new LogNormalDistribution(3) + Data = new LogNormalDistribution(2) }; - mockRepository.ReplayAll(); RoundedDouble newStandardDeviationValue = new RoundedDouble(3, 20); // Call @@ -176,6 +195,43 @@ mockRepository.VerifyAll(); } + [Test] + public void PropertyAttributes_ReturnExpectedValues() + { + // Setup + var observerableMock = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + // Call + var properties = new LogNormalDistributionProperties(observerableMock, DistributionPropertiesReadOnly.None); + + // Assert + TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); + Assert.IsNotInstanceOf(classTypeConverter); + + var dynamicPropertyBag = new DynamicPropertyBag(properties); + PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); + Assert.AreEqual(4, dynamicProperties.Count); + + var meanAttributes = Attribute.GetCustomAttributes(properties.GetType().GetProperty("Mean")); + Assert.IsNotNull(meanAttributes); + AssertAttributesOfType(meanAttributes, "Verwachtingswaarde", + attribute => attribute.DisplayName); + AssertAttributesOfType(meanAttributes, + "De gemiddelde waarde van de lognormale verdeling.", + attribute => attribute.Description); + + var standardAttributes = Attribute.GetCustomAttributes(properties.GetType().GetProperty("StandardDeviation")); + Assert.IsNotNull(standardAttributes); + AssertAttributesOfType(standardAttributes, "Standaardafwijking", + attribute => attribute.DisplayName); + AssertAttributesOfType(standardAttributes, + "De standaardafwijking van de lognormale verdeling.", + attribute => attribute.Description); + + mockRepository.VerifyAll(); + } + private static void AssertAttributesOfType(IEnumerable attributes, TR expectedValue, Func action) { Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionPropertiesTest.cs =================================================================== diff -u -r5b8f476716cb75977616203318fa250f608fe7a5 -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionPropertiesTest.cs (.../NormalDistributionPropertiesTest.cs) (revision 5b8f476716cb75977616203318fa250f608fe7a5) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionPropertiesTest.cs (.../NormalDistributionPropertiesTest.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -24,12 +24,10 @@ using System.ComponentModel; using System.Linq; using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; using NUnit.Framework; using Rhino.Mocks; -using Ringtoets.Common.Data.Probabilistics; using Ringtoets.Common.Forms.PropertyClasses; namespace Ringtoets.Common.Forms.Test.PropertyClasses @@ -46,14 +44,26 @@ } [Test] - public void Constructor_ExpectedValues() + public void Constructor_WithoutParameters_ExpectedValues() { + // Call + var properties = new NormalDistributionProperties(); + + // Assert + Assert.IsInstanceOf(properties); + Assert.IsNull(properties.Data); + Assert.AreEqual("Normale verdeling", properties.DistributionType); + } + + [Test] + public void Constructor_WithParameters_ExpectedValues() + { // Setup var observerableMock = mockRepository.StrictMock(); mockRepository.ReplayAll(); // Call - var properties = new NormalDistributionProperties(observerableMock); + var properties = new NormalDistributionProperties(observerableMock, DistributionPropertiesReadOnly.None); // Assert Assert.IsInstanceOf(properties); @@ -70,11 +80,11 @@ mockRepository.ReplayAll(); // Call - var properties = new NormalDistributionProperties(observerableMock); + var properties = new NormalDistributionProperties(observerableMock, DistributionPropertiesReadOnly.None); // Assert TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); - Assert.IsInstanceOf(classTypeConverter); + Assert.IsNotInstanceOf(classTypeConverter); var dynamicPropertyBag = new DynamicPropertyBag(properties); PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(); @@ -99,80 +109,6 @@ mockRepository.VerifyAll(); } - [Test] - public void SetProperties_MeanWithoutObserverable_ThrowsArgumentException() - { - // Setup - var properties = new NormalDistributionProperties(null) - { - Data = new LogNormalDistribution(2), - }; - - // Call - TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20); - - // Assert - Assert.Throws(test); - } - - [Test] - public void SetProperties_StandardDeviationWithoutObserverable_ThrowsArgumentException() - { - // Setup - var properties = new NormalDistributionProperties(null) - { - Data = new LogNormalDistribution(2) - }; - - // Call - TestDelegate test = () => properties.StandardDeviation = new RoundedDouble(2, 20); - - // Assert - Assert.Throws(test); - } - - [Test] - public void SetProperties_MeanWithObserverable_ValueSetNotifyObservers() - { - // Setup - var observerableMock = mockRepository.StrictMock(); - observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - var properties = new NormalDistributionProperties(observerableMock) - { - Data = new LogNormalDistribution(3) - }; - mockRepository.ReplayAll(); - RoundedDouble newMeanValue = new RoundedDouble(3, 20); - - // Call - properties.Mean = newMeanValue; - - // Assert - Assert.AreEqual(newMeanValue, properties.Mean); - mockRepository.VerifyAll(); - } - - [Test] - public void SetProperties_StandardDeviationWithObserverable_ValueSetNotifyObservers() - { - // Setup - var observerableMock = mockRepository.StrictMock(); - observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once(); - var properties = new NormalDistributionProperties(observerableMock) - { - Data = new LogNormalDistribution(3) - }; - mockRepository.ReplayAll(); - RoundedDouble newStandardDeviationValue = new RoundedDouble(3, 20); - - // Call - properties.StandardDeviation = newStandardDeviationValue; - - // Assert - Assert.AreEqual(newStandardDeviationValue, properties.StandardDeviation); - mockRepository.VerifyAll(); - } - private static void AssertAttributesOfType(IEnumerable attributes, TR expectedValue, Func action) { Fisheye: Tag 26359a31a29af21b6690cacd9b810b1565af9e4b refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/ReadOnlyNormalDistributionPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -r7cfeb195650f713f29c53e9926499fa63e4c79ea -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 7cfeb195650f713f29c53e9926499fa63e4c79ea) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -70,8 +70,6 @@ - - Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs =================================================================== diff -u -r3c1ed9049be26ab9460bf2192c55149c45fbba3c -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs (.../GrassCoverErosionInwardsFailureMechanismContextProperties.cs) (revision 3c1ed9049be26ab9460bf2192c55149c45fbba3c) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs (.../GrassCoverErosionInwardsFailureMechanismContextProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.ComponentModel; using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; @@ -93,59 +94,63 @@ #region Model settings [PropertyOrder(frunupModelFactorPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_ModelSettings")] [ResourcesDisplayName(typeof(Resources), "GrassCoverErosionInwardsInput_FrunupModelFactor_DisplayName")] [ResourcesDescription(typeof(Resources), "GrassCoverErosionInwardsInput_FrunupModelFactor_Description")] - public ReadOnlyNormalDistributionProperties FrunupModelFactor + public NormalDistributionProperties FrunupModelFactor { get { - return new ReadOnlyNormalDistributionProperties + return new NormalDistributionProperties { Data = data.WrappedData.GeneralInput.FrunupModelFactor }; } } [PropertyOrder(fbFactorPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_ModelSettings")] [ResourcesDisplayName(typeof(Resources), "GrassCoverErosionInwardsInput_FbFactor_DisplayName")] [ResourcesDescription(typeof(Resources), "GrassCoverErosionInwardsInput_FbFactor_Description")] - public ReadOnlyNormalDistributionProperties FbFactor + public NormalDistributionProperties FbFactor { get { - return new ReadOnlyNormalDistributionProperties + return new NormalDistributionProperties { Data = data.WrappedData.GeneralInput.FbFactor }; } } [PropertyOrder(fnFactorPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_ModelSettings")] [ResourcesDisplayName(typeof(Resources), "GrassCoverErosionInwardsInput_FnFactor_DisplayName")] [ResourcesDescription(typeof(Resources), "GrassCoverErosionInwardsInput_FnFactor_Description")] - public ReadOnlyNormalDistributionProperties FnFactor + public NormalDistributionProperties FnFactor { get { - return new ReadOnlyNormalDistributionProperties + return new NormalDistributionProperties { Data = data.WrappedData.GeneralInput.FnFactor }; } } [PropertyOrder(fshallowModelFactorPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_ModelSettings")] [ResourcesDisplayName(typeof(Resources), "GrassCoverErosionInwardsInput_FshallowModelFactor_DisplayName")] [ResourcesDescription(typeof(Resources), "GrassCoverErosionInwardsInput_FshallowModelFactor_Description")] - public ReadOnlyNormalDistributionProperties FshallowModelFactor + public NormalDistributionProperties FshallowModelFactor { get { - return new ReadOnlyNormalDistributionProperties + return new NormalDistributionProperties { Data = data.WrappedData.GeneralInput.FshallowModelFactor }; Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs =================================================================== diff -u -r37a53b1ca9a4cdfc6e6df7f065cd540c627f2622 -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision 37a53b1ca9a4cdfc6e6df7f065cd540c627f2622) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsInputContextProperties.cs (.../GrassCoverErosionInwardsInputContextProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -127,14 +127,15 @@ } [PropertyOrder(criticalFlowRatePropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_CriticalValues")] [ResourcesDisplayName(typeof(Resources), "CriticalFlowRate_DisplayName")] [ResourcesDescription(typeof(Resources), "CriticalFlowRate_Description")] public LogNormalDistributionProperties CriticalFlowRate { get { - return new LogNormalDistributionProperties(data.WrappedData) + return new LogNormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.None) { Data = data.WrappedData.CriticalFlowRate }; Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismContextProperties.cs =================================================================== diff -u -r3c1ed9049be26ab9460bf2192c55149c45fbba3c -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismContextProperties.cs (.../HeightStructuresFailureMechanismContextProperties.cs) (revision 3c1ed9049be26ab9460bf2192c55149c45fbba3c) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresFailureMechanismContextProperties.cs (.../HeightStructuresFailureMechanismContextProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.ComponentModel; using Core.Common.Base.Data; using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; @@ -106,29 +107,31 @@ #region Model settings [PropertyOrder(modelfactorOvertoppingFlowPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_ModelSettings")] [ResourcesDisplayName(typeof(Resources), "HeightStructuresInputFailureMechanismContext_ModelFactorOvertoppingFlow_DisplayName")] [ResourcesDescription(typeof(Resources), "HeightStructuresInputFailureMechanismContext_ModelFactorOvertoppingFlow_Description")] - public ReadOnlyLogNormalDistributionProperties ModelFactorOvertoppingFlow + public LogNormalDistributionProperties ModelFactorOvertoppingFlow { get { - return new ReadOnlyLogNormalDistributionProperties + return new LogNormalDistributionProperties { Data = data.WrappedData.GeneralInput.ModelFactorOvertoppingFlow }; } } [PropertyOrder(modelFactorForStorageVolumePropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_ModelSettings")] [ResourcesDisplayName(typeof(Resources), "HeightStructuresInputFailureMechanismContext_ModelFactorForStorageVolume_DisplayName")] [ResourcesDescription(typeof(Resources), "HeightStructuresInputFailureMechanismContext_ModelFactorForStorageVolume_Description")] - public ReadOnlyLogNormalDistributionProperties ModelFactorForStorageVolume + public LogNormalDistributionProperties ModelFactorForStorageVolume { get { - return new ReadOnlyLogNormalDistributionProperties + return new LogNormalDistributionProperties { Data = data.WrappedData.GeneralInput.ModelFactorForStorageVolume }; Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs =================================================================== diff -u -r37a53b1ca9a4cdfc6e6df7f065cd540c627f2622 -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 37a53b1ca9a4cdfc6e6df7f065cd540c627f2622) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -55,14 +55,15 @@ #region Model settings [PropertyOrder(modelFactorOvertoppingSuperCriticalFlowPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_ModelSettings")] [ResourcesDisplayName(typeof(Resources), "ModelFactorOvertoppingSuperCriticalFlow_DisplayName")] [ResourcesDescription(typeof(Resources), "ModelFactorOvertoppingSuperCriticalFlow_Description")] public NormalDistributionProperties ModelFactorOvertoppingSuperCriticalFlow { get { - return new NormalDistributionProperties(data.WrappedData) + return new NormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.StandardDeviation) { Data = data.WrappedData.ModelFactorOvertoppingSuperCriticalFlow }; @@ -111,89 +112,95 @@ } [PropertyOrder(levelOfCrestOfStructurePropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] [ResourcesDisplayName(typeof(Resources), "LevelOfCrestOfStructure_DisplayName")] [ResourcesDescription(typeof(Resources), "LevelOfCrestOfStructure_Description")] public NormalDistributionProperties LevelOfCrestOfStructure { get { - return new NormalDistributionProperties(data.WrappedData) + return new NormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.None) { Data = data.WrappedData.LevelOfCrestOfStructure }; } } [PropertyOrder(allowableIncreaseOfLevelForStoragePropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] [ResourcesDisplayName(typeof(Resources), "AllowableIncreaseOfLevelForStorage_DisplayName")] [ResourcesDescription(typeof(Resources), "AllowableIncreaseOfLevelForStorage_Description")] public LogNormalDistributionProperties AllowableIncreaseOfLevelForStorage { get { - return new LogNormalDistributionProperties(data.WrappedData) + return new LogNormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.None) { Data = data.WrappedData.AllowableIncreaseOfLevelForStorage }; } } [PropertyOrder(storageStructureAreaPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] [ResourcesDisplayName(typeof(Resources), "StorageStructureArea_DisplayName")] [ResourcesDescription(typeof(Resources), "StorageStructureArea_Description")] public LogNormalDistributionProperties StorageStructureArea { get { - return new LogNormalDistributionProperties(data.WrappedData) + return new LogNormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.None) { Data = data.WrappedData.StorageStructureArea }; } } [PropertyOrder(flowWidthAtBottomProtectionPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] [ResourcesDisplayName(typeof(Resources), "FlowWidthAtBottomProtection_DisplayName")] [ResourcesDescription(typeof(Resources), "FlowWidthAtBottomProtection_Description")] public LogNormalDistributionProperties FlowWidthAtBottomProtection { get { - return new LogNormalDistributionProperties(data.WrappedData) + return new LogNormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.None) { Data = data.WrappedData.FlowWidthAtBottomProtection }; } } [PropertyOrder(widthOfFlowAperturesPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] [ResourcesDisplayName(typeof(Resources), "WidthOfFlowApertures_DisplayName")] [ResourcesDescription(typeof(Resources), "WidthOfFlowApertures_Description")] public NormalDistributionProperties WidthOfFlowApertures { get { - return new NormalDistributionProperties(data.WrappedData) + return new NormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.None) { Data = data.WrappedData.WidthOfFlowApertures }; } } [PropertyOrder(criticalOvertoppingDischargePropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_Schematisation")] [ResourcesDisplayName(typeof(Resources), "CriticalOvertoppingDischarge_DisplayName")] [ResourcesDescription(typeof(Resources), "CriticalOvertoppingDischarge_Description")] public LogNormalDistributionProperties CriticalOvertoppingDischarge { get { - return new LogNormalDistributionProperties(data.WrappedData) + return new LogNormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.None) { Data = data.WrappedData.CriticalOvertoppingDischarge }; @@ -239,15 +246,15 @@ } [PropertyOrder(stormDurationPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] [ResourcesCategory(typeof(Resources), "Categories_HydraulicData")] [ResourcesDisplayName(typeof(Resources), "StormDuration_DisplayName")] [ResourcesDescription(typeof(Resources), "StormDuration_Description")] public LogNormalDistributionProperties StormDuration { get { - // TODO make standard deviation read-only - return new LogNormalDistributionProperties(data.WrappedData) + return new LogNormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.StandardDeviation) { Data = data.WrappedData.StormDuration }; Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs =================================================================== diff -u -r37a53b1ca9a4cdfc6e6df7f065cd540c627f2622 -r26359a31a29af21b6690cacd9b810b1565af9e4b --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 37a53b1ca9a4cdfc6e6df7f065cd540c627f2622) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b) @@ -76,45 +76,45 @@ properties.Data = inputContext; // Assert - var modelFactorOvertoppingSuperCriticalFlowProperties = new NormalDistributionProperties(null) + var modelFactorOvertoppingSuperCriticalFlowProperties = new NormalDistributionProperties { Data = input.ModelFactorOvertoppingSuperCriticalFlow }; AssertDistributionProperties(modelFactorOvertoppingSuperCriticalFlowProperties, properties.ModelFactorOvertoppingSuperCriticalFlow); Assert.AreEqual(input.OrientationOfTheNormalOfTheStructure, properties.OrientationOfTheNormalOfTheStructure); - var levelOfCrestOfStructureProperties = new NormalDistributionProperties(null) + var levelOfCrestOfStructureProperties = new NormalDistributionProperties { Data = input.LevelOfCrestOfStructure }; AssertDistributionProperties(levelOfCrestOfStructureProperties, properties.LevelOfCrestOfStructure); - var allowableIncreaseOfLevelForStorageProperties = new LogNormalDistributionProperties(null) + var allowableIncreaseOfLevelForStorageProperties = new LogNormalDistributionProperties { Data = input.AllowableIncreaseOfLevelForStorage }; AssertDistributionProperties(allowableIncreaseOfLevelForStorageProperties, properties.AllowableIncreaseOfLevelForStorage); - var storageStructureAreaProperties = new LogNormalDistributionProperties(null) + var storageStructureAreaProperties = new LogNormalDistributionProperties { Data = input.StorageStructureArea }; AssertDistributionProperties(storageStructureAreaProperties, properties.StorageStructureArea); - var flowWidthAtBottomProtectionProperties = new LogNormalDistributionProperties(null) + var flowWidthAtBottomProtectionProperties = new LogNormalDistributionProperties { Data = input.FlowWidthAtBottomProtection }; AssertDistributionProperties(flowWidthAtBottomProtectionProperties, properties.FlowWidthAtBottomProtection); - var widthOfFlowAperturesProperties = new NormalDistributionProperties(null) + var widthOfFlowAperturesProperties = new NormalDistributionProperties { Data = input.WidthOfFlowApertures }; AssertDistributionProperties(widthOfFlowAperturesProperties, properties.WidthOfFlowApertures); - var criticalOvertoppingDischargeProperties = new LogNormalDistributionProperties(null) + var criticalOvertoppingDischargeProperties = new LogNormalDistributionProperties { Data = input.CriticalOvertoppingDischarge }; @@ -126,7 +126,7 @@ Assert.AreEqual(input.HydraulicBoundaryLocation, properties.HydraulicBoundaryLocation); - var stormDurationProperties = new LogNormalDistributionProperties(null) + var stormDurationProperties = new LogNormalDistributionProperties { Data = input.StormDuration };