Index: Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/IDistributionVariationCoefficient.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/IDistributionVariationCoefficient.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/IDistributionVariationCoefficient.cs (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -0,0 +1,70 @@
+// 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.
+
+using System;
+using Core.Common.Base.Data;
+using Ringtoets.Common.Data.Properties;
+
+namespace Ringtoets.Common.Data.Probabilistics
+{
+ ///
+ /// Extension for to support variation coefficient.
+ ///
+ public static class IDistributionVariationCoefficient
+ {
+ ///
+ /// Gets the variation coefficient ( / ) of the distribution.
+ ///
+ /// The distribution.
+ /// The variation coefficient.
+ public static RoundedDouble GetVariationCoefficient(this IDistribution distribution)
+ {
+ return new RoundedDouble(distribution.Mean.NumberOfDecimalPlaces, (distribution.Mean <= 0) ?
+ double.NegativeInfinity :
+ distribution.StandardDeviation/distribution.Mean);
+ }
+
+ ///
+ /// Sets the of the distribution ( * ).
+ ///
+ /// The distribution.
+ /// The variation coefficient.
+ public static void SetStandardDeviationFromVariationCoefficient(this IDistribution distribution, double variationCoefficient)
+ {
+ distribution.StandardDeviation = (RoundedDouble) variationCoefficient*distribution.Mean;
+ }
+
+ ///
+ /// Sets the of the distribution ( / ).
+ ///
+ /// The distribution.
+ /// The variation coefficient.
+ /// Thrown when is less than or equal to 0.
+ public static void SetMeanFromVariationCoefficient(this IDistribution distribution, double variationCoefficient)
+ {
+ if (variationCoefficient <= 0)
+ {
+ throw new ArgumentOutOfRangeException("variationCoefficient", Resources.VariationCoefficient_Should_be_greater_than_zero);
+ }
+ distribution.Mean = (RoundedDouble) (distribution.StandardDeviation/variationCoefficient);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/LogNormalDistribution.cs
===================================================================
diff -u -r98c8145f8fe1dcb2ec811a1238c5e26c7594b3f7 -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/LogNormalDistribution.cs (.../LogNormalDistribution.cs) (revision 98c8145f8fe1dcb2ec811a1238c5e26c7594b3f7)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Probabilistics/LogNormalDistribution.cs (.../LogNormalDistribution.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -91,37 +91,5 @@
standardDeviation = value.ToPrecision(standardDeviation.NumberOfDecimalPlaces);
}
}
-
- ///
- /// Gets the variation coefficient ( / ) of the distribution.
- ///
- /// The variation coefficient.
- public RoundedDouble GetVariationCoefficient()
- {
- return new RoundedDouble(numberOfDecimalPlaces, StandardDeviation/Mean);
- }
-
- ///
- /// Sets the of the distribution ( * ).
- ///
- /// The variation coefficient.
- public void SetStandardDeviationFromVariationCoefficient(double variationCoefficient)
- {
- StandardDeviation = (RoundedDouble) variationCoefficient*Mean;
- }
-
- ///
- /// Sets the of the distribution ( / ).
- ///
- /// The variation coefficient.
- /// Thrown when is less than or equal to 0.
- public void SetMeanFromVariationCoefficient(double variationCoefficient)
- {
- if (variationCoefficient <= 0)
- {
- throw new ArgumentOutOfRangeException("variationCoefficient", Resources.VariationCoefficient_Should_be_greater_than_zero);
- }
- Mean = (RoundedDouble) (StandardDeviation/variationCoefficient);
- }
- }
+ }
}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj
===================================================================
diff -u -rbe3779b7be55ce7821035393e89cdde997b15883 -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision be3779b7be55ce7821035393e89cdde997b15883)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -43,6 +43,7 @@
+
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -387,6 +387,15 @@
}
///
+ /// Looks up a localized string similar to Variatiecoëfficiënt.
+ ///
+ public static string Distribution_VariationCoefficient_DisplayName {
+ get {
+ return ResourceManager.GetString("Distribution_VariationCoefficient_DisplayName", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Lognormaal.
///
public static string DistributionType_LogNormal {
@@ -705,6 +714,15 @@
}
///
+ /// Looks up a localized string similar to De variatiecoëfficiënt van de lognormale verdeling..
+ ///
+ public static string LogNormalDistribution_VariationCoefficient_Description {
+ get {
+ return ResourceManager.GetString("LogNormalDistribution_VariationCoefficient_Description", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to De gemiddelde waarde van de normale verdeling..
///
public static string NormalDistribution_Mean_Description {
@@ -741,6 +759,15 @@
}
///
+ /// Looks up a localized string similar to De variatiecoëfficiënt van de normale verdeling..
+ ///
+ public static string NormalDistribution_VariationCoefficient_Description {
+ get {
+ return ResourceManager.GetString("NormalDistribution_VariationCoefficient_Description", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized resource of type System.Drawing.Bitmap.
///
public static System.Drawing.Bitmap OutputFolderIcon {
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -400,4 +400,13 @@
Normale verdeling
+
+ De variatiecoëfficiënt van de lognormale verdeling.
+
+
+ Variatiecoëfficiënt
+
+
+ De variatiecoëfficiënt van de normale verdeling.
+
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionProperties.cs
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionProperties.cs (.../DistributionProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionProperties.cs (.../DistributionProperties.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -35,6 +35,7 @@
///
public abstract class DistributionProperties : ObjectProperties
{
+ protected readonly bool IsVariationCoefficientReadOnly;
private readonly bool isMeanReadOnly;
private readonly bool isStandardDeviationReadOnly;
protected IObservable Observerable;
@@ -43,6 +44,7 @@
{
isStandardDeviationReadOnly = propertiesReadOnly == DistributionPropertiesReadOnly.All || propertiesReadOnly == DistributionPropertiesReadOnly.StandardDeviation;
isMeanReadOnly = propertiesReadOnly == DistributionPropertiesReadOnly.All || propertiesReadOnly == DistributionPropertiesReadOnly.Mean;
+ IsVariationCoefficientReadOnly = propertiesReadOnly == DistributionPropertiesReadOnly.All || propertiesReadOnly == DistributionPropertiesReadOnly.VariationCoefficient;
}
[PropertyOrder(1)]
@@ -109,6 +111,8 @@
return isMeanReadOnly;
case "StandardDeviation":
return isStandardDeviationReadOnly;
+ case "VariationCoefficient":
+ return IsVariationCoefficientReadOnly;
default:
return false;
}
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionPropertiesReadOnly.cs
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionPropertiesReadOnly.cs (.../DistributionPropertiesReadOnly.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/DistributionPropertiesReadOnly.cs (.../DistributionPropertiesReadOnly.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -42,6 +42,11 @@
StandardDeviation,
///
+ /// Mark variation coefficient read-only.
+ ///
+ VariationCoefficient,
+
+ ///
/// Mark both and editable.
///
None
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionProperties.cs
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionProperties.cs (.../LogNormalDistributionProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionProperties.cs (.../LogNormalDistributionProperties.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -73,7 +73,6 @@
}
}
- [DynamicReadOnly]
[ResourcesDescription(typeof(Resources), "LogNormalDistribution_StandardDeviation_Description")]
public override RoundedDouble StandardDeviation
{
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionVariationProperties.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionVariationProperties.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/LogNormalDistributionVariationProperties.cs (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -0,0 +1,106 @@
+// 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.
+
+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;
+using Ringtoets.Common.Forms.Properties;
+
+namespace Ringtoets.Common.Forms.PropertyClasses
+{
+ ///
+ /// An implementation for
+ /// properties that display variation coefficient.
+ ///
+ public class LogNormalDistributionVariationProperties : LogNormalDistributionProperties
+ {
+ ///
+ /// Creates a new read-only instance of .
+ ///
+ public LogNormalDistributionVariationProperties() : this(null, DistributionPropertiesReadOnly.All) {}
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// Object to observe to notify upon change.
+ /// Sets if and/or
+ /// should be marked read-only.
+ public LogNormalDistributionVariationProperties(IObservable observerable, DistributionPropertiesReadOnly propertiesReadOnly)
+ : base(observerable, propertiesReadOnly) {}
+
+ public override RoundedDouble Mean
+ {
+ get
+ {
+ return base.Mean;
+ }
+ set
+ {
+ var variationCoefficient = data.GetVariationCoefficient();
+ base.Mean = value;
+ if (!double.IsInfinity(variationCoefficient))
+ {
+ data.SetStandardDeviationFromVariationCoefficient(variationCoefficient);
+ Observerable.NotifyObservers();
+ }
+ }
+ }
+
+ [Browsable(false)]
+ public override RoundedDouble StandardDeviation { get; set; }
+
+ [PropertyOrder(3)]
+ [DynamicReadOnly]
+ [ResourcesDisplayName(typeof(Resources), "Distribution_VariationCoefficient_DisplayName")]
+ [ResourcesDescription(typeof(Resources), "LogNormalDistribution_VariationCoefficient_Description")]
+ public RoundedDouble VariationCoefficient
+ {
+ get
+ {
+ return data.GetVariationCoefficient();
+ }
+ set
+ {
+ if (IsVariationCoefficientReadOnly)
+ {
+ throw new ArgumentException("Variation coefficient is set to be read-only.");
+ }
+ if (Observerable == null)
+ {
+ throw new ArgumentException("No observerable object set.");
+ }
+ data.SetStandardDeviationFromVariationCoefficient(value);
+ Observerable.NotifyObservers();
+ }
+ }
+
+ public override string ToString()
+ {
+ return data == null ? Resources.Distribution_VariationCoefficient_DisplayName :
+ string.Format("{0} ({1} = {2})", Mean, Resources.Distribution_VariationCoefficient_DisplayName, VariationCoefficient);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/NormalDistributionVariationProperties.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/NormalDistributionVariationProperties.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/NormalDistributionVariationProperties.cs (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -0,0 +1,106 @@
+// 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.
+
+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;
+using Ringtoets.Common.Forms.Properties;
+
+namespace Ringtoets.Common.Forms.PropertyClasses
+{
+ ///
+ /// An implementation for
+ /// properties that display variation coefficient.
+ ///
+ public class NormalDistributionVariationProperties : NormalDistributionProperties
+ {
+ ///
+ /// Creates a new read-only instance of .
+ ///
+ public NormalDistributionVariationProperties() : this(null, DistributionPropertiesReadOnly.All) {}
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// Object to observe to notify upon change.
+ /// Sets if and/or
+ /// should be marked read-only.
+ public NormalDistributionVariationProperties(IObservable observerable, DistributionPropertiesReadOnly propertiesReadOnly)
+ : base(observerable, propertiesReadOnly) {}
+
+ public override RoundedDouble Mean
+ {
+ get
+ {
+ return base.Mean;
+ }
+ set
+ {
+ var variationCoefficient = data.GetVariationCoefficient();
+ base.Mean = value;
+ if (!double.IsInfinity(variationCoefficient))
+ {
+ data.SetStandardDeviationFromVariationCoefficient(variationCoefficient);
+ Observerable.NotifyObservers();
+ }
+ }
+ }
+
+ [Browsable(false)]
+ public override RoundedDouble StandardDeviation { get; set; }
+
+ [PropertyOrder(3)]
+ [DynamicReadOnly]
+ [ResourcesDisplayName(typeof(Resources), "Distribution_VariationCoefficient_DisplayName")]
+ [ResourcesDescription(typeof(Resources), "NormalDistribution_VariationCoefficient_Description")]
+ public RoundedDouble VariationCoefficient
+ {
+ get
+ {
+ return data.GetVariationCoefficient();
+ }
+ set
+ {
+ if (IsVariationCoefficientReadOnly)
+ {
+ throw new ArgumentException("Variation coefficient is set to be read-only.");
+ }
+ if (Observerable == null)
+ {
+ throw new ArgumentException("No observerable object set.");
+ }
+ data.SetStandardDeviationFromVariationCoefficient(value);
+ Observerable.NotifyObservers();
+ }
+ }
+
+ public override string ToString()
+ {
+ return data == null ? Resources.Distribution_VariationCoefficient_DisplayName :
+ string.Format("{0} ({1} = {2})", Mean, Resources.Distribution_VariationCoefficient_DisplayName, VariationCoefficient);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -63,6 +63,8 @@
+
+
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/DistributionPropertiesTest.cs
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/DistributionPropertiesTest.cs (.../DistributionPropertiesTest.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/DistributionPropertiesTest.cs (.../DistributionPropertiesTest.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -55,15 +55,14 @@
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)]
+ [TestCase(DistributionPropertiesReadOnly.VariationCoefficient, false, false)]
public void DynamicReadOnlyValidationMethod_VariousReadOnlySet_ExpectedValues(DistributionPropertiesReadOnly propertiesReadOnly, bool expectMeanReadOnly, bool expectStandardDeviationReadOnly)
{
// Setup
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionPropertiesTest.cs
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionPropertiesTest.cs (.../LogNormalDistributionPropertiesTest.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionPropertiesTest.cs (.../LogNormalDistributionPropertiesTest.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -69,7 +69,6 @@
var properties = new LogNormalDistributionProperties(observerableMock, DistributionPropertiesReadOnly.None);
// Assert
- Assert.IsInstanceOf(properties);
Assert.IsNull(properties.Data);
Assert.AreEqual("Lognormaal", properties.DistributionType);
mockRepository.VerifyAll();
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionVariationPropertiesTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionVariationPropertiesTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/LogNormalDistributionVariationPropertiesTest.cs (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -0,0 +1,289 @@
+// 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.
+
+using System;
+using System.ComponentModel;
+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
+{
+ [TestFixture]
+ public class LogNormalDistributionVariationPropertiesTest
+ {
+ private MockRepository mockRepository;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mockRepository = new MockRepository();
+ }
+
+ [Test]
+ public void Constructor_WithoutParameters_ExpectedValues()
+ {
+ // Call
+ var properties = new LogNormalDistributionVariationProperties();
+
+ // Assert
+ Assert.IsInstanceOf>(properties);
+ Assert.IsNull(properties.Data);
+ Assert.AreEqual("Variatiecoëfficiënt", properties.ToString());
+ Assert.AreEqual("Lognormaal", properties.DistributionType);
+ }
+
+ [Test]
+ public void Constructor_WithParameters_ExpectedValues()
+ {
+ // Call
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+ var properties = new LogNormalDistributionVariationProperties(observerableMock, DistributionPropertiesReadOnly.None);
+
+ // Assert
+ Assert.IsNull(properties.Data);
+ Assert.AreEqual("Variatiecoëfficiënt", properties.ToString());
+ Assert.AreEqual("Lognormaal", properties.DistributionType);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.All, true, true)]
+ [TestCase(DistributionPropertiesReadOnly.Mean, true, false)]
+ [TestCase(DistributionPropertiesReadOnly.None, false, false)]
+ [TestCase(DistributionPropertiesReadOnly.StandardDeviation, false, false)]
+ [TestCase(DistributionPropertiesReadOnly.VariationCoefficient, false, true)]
+ public void DynamicReadOnlyValidationMethod_VariousReadOnlySet_ExpectedValues(DistributionPropertiesReadOnly propertiesReadOnly, bool expectMeanReadOnly, bool expectVariarionCoefficient)
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+ var properties = new LogNormalDistributionVariationProperties(observerableMock, propertiesReadOnly);
+
+ // Call
+ var meanIsReadOnly = properties.DynamicReadOnlyValidationMethod("Mean");
+ var variarionCoefficientIsReadOnly = properties.DynamicReadOnlyValidationMethod("VariationCoefficient");
+ var doesNotExist = properties.DynamicReadOnlyValidationMethod("DoesNotExist");
+
+ // Assert
+ Assert.AreEqual(expectVariarionCoefficient, variarionCoefficientIsReadOnly);
+ Assert.AreEqual(expectMeanReadOnly, meanIsReadOnly);
+ Assert.IsFalse(doesNotExist);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Data_SetNewDistributionContextInstance_ReturnCorrectPropertyValues()
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ var properties = new LogNormalDistributionVariationProperties(observerableMock, DistributionPropertiesReadOnly.None);
+ var distribution = new LogNormalDistribution(2);
+
+ // Call
+ properties.Data = distribution;
+
+ // Assert
+ Assert.AreEqual(distribution.Mean, properties.Mean);
+ Assert.AreEqual(distribution.GetVariationCoefficient(), properties.VariationCoefficient);
+ var expectedToString = string.Format("{0} ({1} = {2})", distribution.Mean, Resources.Distribution_VariationCoefficient_DisplayName,
+ distribution.GetVariationCoefficient());
+ Assert.AreEqual(expectedToString, properties.ToString());
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.None)]
+ [TestCase(DistributionPropertiesReadOnly.StandardDeviation)]
+ [TestCase(DistributionPropertiesReadOnly.VariationCoefficient)]
+ public void SetProperties_EditableMeanWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly)
+ {
+ // Setup
+ var properties = new LogNormalDistributionVariationProperties(null, propertiesReadOnly)
+ {
+ Data = new LogNormalDistribution(2)
+ };
+
+ // Call
+ TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "No observerable object set.");
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.All)]
+ [TestCase(DistributionPropertiesReadOnly.Mean)]
+ public void SetProperties_ReadOnlyMeanWithObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly)
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ var properties = new LogNormalDistributionVariationProperties(observerableMock, propertiesReadOnly)
+ {
+ Data = new LogNormalDistribution(2)
+ };
+
+ // Call
+ TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20);
+
+ // Assert
+ 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.Twice();
+ var properties = new LogNormalDistributionVariationProperties(observerableMock, DistributionPropertiesReadOnly.None)
+ {
+ 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.None)]
+ [TestCase(DistributionPropertiesReadOnly.Mean)]
+ public void SetProperties_EditableVariationCoefficientWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly)
+ {
+ // Setup
+ var properties = new LogNormalDistributionVariationProperties(null, propertiesReadOnly)
+ {
+ Data = new LogNormalDistribution(2)
+ };
+
+ // Call
+ TestDelegate test = () => properties.VariationCoefficient = new RoundedDouble(2, 20);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "No observerable object set.");
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.All)]
+ [TestCase(DistributionPropertiesReadOnly.VariationCoefficient)]
+ public void SetProperties_ReadOnlyVariationCoefficientWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly)
+ {
+ // Setup
+ var properties = new LogNormalDistributionVariationProperties(null, propertiesReadOnly)
+ {
+ Data = new LogNormalDistribution(2)
+ };
+
+ // Call
+ TestDelegate test = () => properties.VariationCoefficient = new RoundedDouble(2, 20);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "Variation coefficient is set to be read-only.");
+ }
+
+ [Test]
+ public void SetProperties_VariationCoefficientWithObserverable_ValueSetNotifyObservers()
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once();
+ var properties = new LogNormalDistributionVariationProperties(observerableMock, DistributionPropertiesReadOnly.None)
+ {
+ Data = new LogNormalDistribution(2)
+ };
+ mockRepository.ReplayAll();
+ RoundedDouble newVariationCoefficientValue = new RoundedDouble(2, 20);
+
+ // Call
+ properties.VariationCoefficient = newVariationCoefficientValue;
+
+ // Assert
+ Assert.AreEqual(newVariationCoefficientValue, properties.VariationCoefficient);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.All, true, true)]
+ [TestCase(DistributionPropertiesReadOnly.Mean, true, false)]
+ [TestCase(DistributionPropertiesReadOnly.None, false, false)]
+ [TestCase(DistributionPropertiesReadOnly.VariationCoefficient, false, true)]
+ public void PropertyAttributes_ReturnExpectedValues(DistributionPropertiesReadOnly propertiesReadOnly, bool expectMeanReadOnly, bool expectVariationCoefficientReadOnly)
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ // Call
+ var properties = new LogNormalDistributionVariationProperties(observerableMock, propertiesReadOnly)
+ {
+ Data = new LogNormalDistribution(2)
+ };
+
+ // Assert
+ TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true);
+ Assert.IsNotInstanceOf(classTypeConverter);
+
+ var dynamicPropertyBag = new DynamicPropertyBag(properties);
+ PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[]
+ {
+ new BrowsableAttribute(true)
+ });
+ Assert.AreEqual(3, dynamicProperties.Count);
+
+ 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.AreEqual(expectMeanReadOnly, meanProperty.IsReadOnly);
+ Assert.AreEqual("Verwachtingswaarde", meanProperty.DisplayName);
+ Assert.AreEqual("De gemiddelde waarde van de lognormale verdeling.", meanProperty.Description);
+
+ PropertyDescriptor variationCoefficientProperty = dynamicProperties[2];
+ Assert.IsNotNull(variationCoefficientProperty);
+ Assert.AreEqual(expectVariationCoefficientReadOnly, variationCoefficientProperty.IsReadOnly);
+ Assert.AreEqual("Variatiecoëfficiënt", variationCoefficientProperty.DisplayName);
+ Assert.AreEqual("De variatiecoëfficiënt van de lognormale verdeling.", variationCoefficientProperty.Description);
+ mockRepository.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionVariationPropertiesTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionVariationPropertiesTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/NormalDistributionVariationPropertiesTest.cs (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -0,0 +1,295 @@
+// 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.
+
+using System;
+using System.ComponentModel;
+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
+{
+ [TestFixture]
+ public class NormalDistributionVariationPropertiesTest
+ {
+ private MockRepository mockRepository;
+
+ [SetUp]
+ public void SetUp()
+ {
+ mockRepository = new MockRepository();
+ }
+
+ [Test]
+ public void Constructor_WithoutParameters_ExpectedValues()
+ {
+ // Call
+ var properties = new NormalDistributionVariationProperties();
+
+ // Assert
+ Assert.IsInstanceOf>(properties);
+ Assert.IsNull(properties.Data);
+ Assert.AreEqual("Variatiecoëfficiënt", properties.ToString());
+ Assert.AreEqual("Normale verdeling", properties.DistributionType);
+ }
+
+ [Test]
+ public void Constructor_WithParameters_ExpectedValues()
+ {
+ // Call
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+ var properties = new NormalDistributionVariationProperties(observerableMock, DistributionPropertiesReadOnly.None);
+
+ // Assert
+ Assert.IsNull(properties.Data);
+ Assert.AreEqual("Variatiecoëfficiënt", properties.ToString());
+ Assert.AreEqual("Normale verdeling", properties.DistributionType);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.All, true, true)]
+ [TestCase(DistributionPropertiesReadOnly.Mean, true, false)]
+ [TestCase(DistributionPropertiesReadOnly.None, false, false)]
+ [TestCase(DistributionPropertiesReadOnly.StandardDeviation, false, false)]
+ [TestCase(DistributionPropertiesReadOnly.VariationCoefficient, false, true)]
+ public void DynamicReadOnlyValidationMethod_VariousReadOnlySet_ExpectedValues(DistributionPropertiesReadOnly propertiesReadOnly, bool expectMeanReadOnly, bool expectVariarionCoefficient)
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+ var properties = new NormalDistributionVariationProperties(observerableMock, propertiesReadOnly);
+
+ // Call
+ var meanIsReadOnly = properties.DynamicReadOnlyValidationMethod("Mean");
+ var variarionCoefficientIsReadOnly = properties.DynamicReadOnlyValidationMethod("VariationCoefficient");
+ var doesNotExist = properties.DynamicReadOnlyValidationMethod("DoesNotExist");
+
+ // Assert
+ Assert.AreEqual(expectVariarionCoefficient, variarionCoefficientIsReadOnly);
+ Assert.AreEqual(expectMeanReadOnly, meanIsReadOnly);
+ Assert.IsFalse(doesNotExist);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Data_SetNewDistributionContextInstance_ReturnCorrectPropertyValues()
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ var properties = new NormalDistributionVariationProperties(observerableMock, DistributionPropertiesReadOnly.None);
+ var distribution = new NormalDistribution(2)
+ {
+ Mean = (RoundedDouble) 2
+ };
+
+ // Call
+ properties.Data = distribution;
+
+ // Assert
+ Assert.AreEqual(distribution.Mean, properties.Mean);
+ Assert.AreEqual(distribution.GetVariationCoefficient(), properties.VariationCoefficient);
+ var expectedToString = string.Format("{0} ({1} = {2})", distribution.Mean, Resources.Distribution_VariationCoefficient_DisplayName,
+ distribution.GetVariationCoefficient());
+ Assert.AreEqual(expectedToString, properties.ToString());
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.None)]
+ [TestCase(DistributionPropertiesReadOnly.StandardDeviation)]
+ [TestCase(DistributionPropertiesReadOnly.VariationCoefficient)]
+ public void SetProperties_EditableMeanWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly)
+ {
+ // Setup
+ var properties = new NormalDistributionVariationProperties(null, propertiesReadOnly)
+ {
+ Data = new NormalDistribution(2)
+ };
+
+ // Call
+ TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "No observerable object set.");
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.All)]
+ [TestCase(DistributionPropertiesReadOnly.Mean)]
+ public void SetProperties_ReadOnlyMeanWithObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly)
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ var properties = new NormalDistributionVariationProperties(observerableMock, propertiesReadOnly)
+ {
+ Data = new NormalDistribution(2)
+ };
+
+ // Call
+ TestDelegate test = () => properties.Mean = new RoundedDouble(2, 20);
+
+ // Assert
+ 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 NormalDistributionVariationProperties(observerableMock, DistributionPropertiesReadOnly.None)
+ {
+ Data = new NormalDistribution(2)
+ };
+ mockRepository.ReplayAll();
+ RoundedDouble newMeanValue = new RoundedDouble(3, 5);
+
+ // Call
+ properties.Mean = newMeanValue;
+
+ // Assert
+ Assert.AreEqual(newMeanValue, properties.Mean);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.None)]
+ [TestCase(DistributionPropertiesReadOnly.Mean)]
+ public void SetProperties_EditableVariationCoefficientWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly)
+ {
+ // Setup
+ var properties = new NormalDistributionVariationProperties(null, propertiesReadOnly)
+ {
+ Data = new NormalDistribution(2)
+ };
+
+ // Call
+ TestDelegate test = () => properties.VariationCoefficient = new RoundedDouble(2, 20);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "No observerable object set.");
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.All)]
+ [TestCase(DistributionPropertiesReadOnly.VariationCoefficient)]
+ public void SetProperties_ReadOnlyVariationCoefficientWithoutObserverable_ThrowsArgumentException(DistributionPropertiesReadOnly propertiesReadOnly)
+ {
+ // Setup
+ var properties = new NormalDistributionVariationProperties(null, propertiesReadOnly)
+ {
+ Data = new NormalDistribution(2)
+ };
+
+ // Call
+ TestDelegate test = () => properties.VariationCoefficient = new RoundedDouble(2, 20);
+
+ // Assert
+ TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "Variation coefficient is set to be read-only.");
+ }
+
+ [Test]
+ public void SetProperties_VariationCoefficientWithObserverable_ValueSetNotifyObservers()
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ observerableMock.Expect(o => o.NotifyObservers()).Repeat.Once();
+ var properties = new NormalDistributionVariationProperties(observerableMock, DistributionPropertiesReadOnly.None)
+ {
+ Data = new NormalDistribution(2)
+ {
+ Mean = (RoundedDouble) 2
+ }
+ };
+ mockRepository.ReplayAll();
+ RoundedDouble newVariationCoefficientValue = new RoundedDouble(2, 20);
+
+ // Call
+ properties.VariationCoefficient = newVariationCoefficientValue;
+
+ // Assert
+ Assert.AreEqual(newVariationCoefficientValue, properties.VariationCoefficient);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [TestCase(DistributionPropertiesReadOnly.All, true, true)]
+ [TestCase(DistributionPropertiesReadOnly.Mean, true, false)]
+ [TestCase(DistributionPropertiesReadOnly.None, false, false)]
+ [TestCase(DistributionPropertiesReadOnly.VariationCoefficient, false, true)]
+ public void PropertyAttributes_ReturnExpectedValues(DistributionPropertiesReadOnly propertiesReadOnly, bool expectMeanReadOnly, bool expectVariationCoefficientReadOnly)
+ {
+ // Setup
+ var observerableMock = mockRepository.StrictMock();
+ mockRepository.ReplayAll();
+
+ // Call
+ var properties = new NormalDistributionVariationProperties(observerableMock, propertiesReadOnly)
+ {
+ Data = new NormalDistribution(2)
+ };
+
+ // Assert
+ TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true);
+ Assert.IsNotInstanceOf(classTypeConverter);
+
+ var dynamicPropertyBag = new DynamicPropertyBag(properties);
+ PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[]
+ {
+ new BrowsableAttribute(true)
+ });
+ Assert.AreEqual(3, dynamicProperties.Count);
+
+ 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.AreEqual(expectMeanReadOnly, meanProperty.IsReadOnly);
+ Assert.AreEqual("Verwachtingswaarde", meanProperty.DisplayName);
+ Assert.AreEqual("De gemiddelde waarde van de normale verdeling.", meanProperty.Description);
+
+ PropertyDescriptor variationCoefficientProperty = dynamicProperties[2];
+ Assert.IsNotNull(variationCoefficientProperty);
+ Assert.AreEqual(expectVariationCoefficientReadOnly, variationCoefficientProperty.IsReadOnly);
+ Assert.AreEqual("Variatiecoëfficiënt", variationCoefficientProperty.DisplayName);
+ Assert.AreEqual("De variatiecoëfficiënt van de normale verdeling.", variationCoefficientProperty.Description);
+ mockRepository.VerifyAll();
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -67,6 +67,8 @@
+
+
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresCalculation.cs
===================================================================
diff -u -rea180de6e9f5ba1108b4ff3cf7bb7e57de72a37a -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresCalculation.cs (.../HeightStructuresCalculation.cs) (revision ea180de6e9f5ba1108b4ff3cf7bb7e57de72a37a)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresCalculation.cs (.../HeightStructuresCalculation.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -86,7 +86,6 @@
InputParameters.LevelOfCrestOfStructure.Mean = (RoundedDouble) 3.5;
InputParameters.OrientationOfTheNormalOfTheStructure = (RoundedDouble) 115;
InputParameters.AllowableIncreaseOfLevelForStorage.Mean = (RoundedDouble) 1.0;
- InputParameters.StorageStructureArea.Mean = (RoundedDouble) 1000000;
InputParameters.FlowWidthAtBottomProtection.Mean = (RoundedDouble) 18;
InputParameters.CriticalOvertoppingDischarge.Mean = (RoundedDouble) 1;
InputParameters.WidthOfFlowApertures.Mean = (RoundedDouble) 18;
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs
===================================================================
diff -u -r7f4ee0fa245a18426c81c11c8f9ea18e73e42d07 -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs (.../HeightStructuresInput.cs) (revision 7f4ee0fa245a18426c81c11c8f9ea18e73e42d07)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Data/HeightStructuresInput.cs (.../HeightStructuresInput.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -70,9 +70,9 @@
storageStructureArea = new LogNormalDistribution(2)
{
- Mean = (RoundedDouble) double.NaN,
- StandardDeviation = (RoundedDouble) 0.1
+ Mean = (RoundedDouble) 1.0
};
+ storageStructureArea.SetStandardDeviationFromVariationCoefficient(0.1);
flowWidthAtBottomProtection = new LogNormalDistribution(2)
{
@@ -82,9 +82,9 @@
criticalOvertoppingDischarge = new LogNormalDistribution(2)
{
- Mean = (RoundedDouble) double.NaN,
- StandardDeviation = (RoundedDouble) 0.15
+ Mean = (RoundedDouble) 1.0
};
+ criticalOvertoppingDischarge.SetStandardDeviationFromVariationCoefficient(0.15);
failureProbabilityOfStructureGivenErosion = new RoundedDouble(2);
@@ -97,9 +97,9 @@
stormDuration = new LogNormalDistribution(2)
{
- Mean = (RoundedDouble) 7.5,
- StandardDeviation = (RoundedDouble) 0.25
+ Mean = (RoundedDouble) 7.5
};
+ stormDuration.SetStandardDeviationFromVariationCoefficient(0.25);
}
#region Model Factors
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs
===================================================================
diff -u -r26359a31a29af21b6690cacd9b810b1565af9e4b -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision 26359a31a29af21b6690cacd9b810b1565af9e4b)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/PropertyClasses/HeightStructuresInputContextProperties.cs (.../HeightStructuresInputContextProperties.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -148,11 +148,11 @@
[ResourcesCategory(typeof(Resources), "Categories_Schematisation")]
[ResourcesDisplayName(typeof(Resources), "StorageStructureArea_DisplayName")]
[ResourcesDescription(typeof(Resources), "StorageStructureArea_Description")]
- public LogNormalDistributionProperties StorageStructureArea
+ public LogNormalDistributionVariationProperties StorageStructureArea
{
get
{
- return new LogNormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.None)
+ return new LogNormalDistributionVariationProperties(data.WrappedData, DistributionPropertiesReadOnly.None)
{
Data = data.WrappedData.StorageStructureArea
};
@@ -196,11 +196,11 @@
[ResourcesCategory(typeof(Resources), "Categories_Schematisation")]
[ResourcesDisplayName(typeof(Resources), "CriticalOvertoppingDischarge_DisplayName")]
[ResourcesDescription(typeof(Resources), "CriticalOvertoppingDischarge_Description")]
- public LogNormalDistributionProperties CriticalOvertoppingDischarge
+ public LogNormalDistributionVariationProperties CriticalOvertoppingDischarge
{
get
{
- return new LogNormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.None)
+ return new LogNormalDistributionVariationProperties(data.WrappedData, DistributionPropertiesReadOnly.None)
{
Data = data.WrappedData.CriticalOvertoppingDischarge
};
@@ -250,11 +250,11 @@
[ResourcesCategory(typeof(Resources), "Categories_HydraulicData")]
[ResourcesDisplayName(typeof(Resources), "StormDuration_DisplayName")]
[ResourcesDescription(typeof(Resources), "StormDuration_Description")]
- public LogNormalDistributionProperties StormDuration
+ public LogNormalDistributionVariationProperties StormDuration
{
get
{
- return new LogNormalDistributionProperties(data.WrappedData, DistributionPropertiesReadOnly.StandardDeviation)
+ return new LogNormalDistributionVariationProperties(data.WrappedData, DistributionPropertiesReadOnly.VariationCoefficient)
{
Data = data.WrappedData.StormDuration
};
Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs
===================================================================
diff -u -r06f95f8ac2bd80176a952183c0bb4e0154b1fc3e -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs (.../HeightStructuresGuiPlugin.cs) (revision 06f95f8ac2bd80176a952183c0bb4e0154b1fc3e)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Plugin/HeightStructuresGuiPlugin.cs (.../HeightStructuresGuiPlugin.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -31,6 +31,7 @@
using Ringtoets.Common.Data;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.Probabilistics;
using Ringtoets.Common.Data.Probability;
using Ringtoets.Common.Forms.Helpers;
using Ringtoets.Common.Forms.PresentationObjects;
@@ -161,14 +162,14 @@
inputParameters.ModelFactorOvertoppingSuperCriticalFlow.Mean, inputParameters.ModelFactorOvertoppingSuperCriticalFlow.StandardDeviation,
inputParameters.AllowableIncreaseOfLevelForStorage.Mean, inputParameters.AllowableIncreaseOfLevelForStorage.StandardDeviation,
generalInputParameters.ModelFactorForStorageVolume.Mean, generalInputParameters.ModelFactorForStorageVolume.StandardDeviation,
- inputParameters.StorageStructureArea.Mean, inputParameters.StorageStructureArea.StandardDeviation,
+ inputParameters.StorageStructureArea.Mean, inputParameters.StorageStructureArea.GetVariationCoefficient(),
generalInputParameters.ModelFactorForIncomingFlowVolume,
inputParameters.FlowWidthAtBottomProtection.Mean, inputParameters.FlowWidthAtBottomProtection.StandardDeviation,
- inputParameters.CriticalOvertoppingDischarge.Mean, inputParameters.CriticalOvertoppingDischarge.StandardDeviation,
+ inputParameters.CriticalOvertoppingDischarge.Mean, inputParameters.CriticalOvertoppingDischarge.GetVariationCoefficient(),
inputParameters.FailureProbabilityOfStructureGivenErosion,
- inputParameters.WidthOfFlowApertures.Mean, inputParameters.WidthOfFlowApertures.StandardDeviation,
+ inputParameters.WidthOfFlowApertures.Mean, inputParameters.WidthOfFlowApertures.GetVariationCoefficient(),
inputParameters.DeviationOfTheWaveDirection,
- inputParameters.StormDuration.Mean, inputParameters.StormDuration.StandardDeviation),
+ inputParameters.StormDuration.Mean, inputParameters.StormDuration.GetVariationCoefficient()),
calculation.ClearOutput,
output => { ParseHydraRingOutput(calculation, failureMechanism, assessmentSection, output); });
}
Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs
===================================================================
diff -u -r7f4ee0fa245a18426c81c11c8f9ea18e73e42d07 -re1157c221217ef3b5ade6034183a7da0e620eb05
--- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision 7f4ee0fa245a18426c81c11c8f9ea18e73e42d07)
+++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/PropertyClasses/HeightStructuresInputContextPropertiesTest.cs (.../HeightStructuresInputContextPropertiesTest.cs) (revision e1157c221217ef3b5ade6034183a7da0e620eb05)
@@ -96,7 +96,7 @@
};
AssertDistributionProperties(allowableIncreaseOfLevelForStorageProperties, properties.AllowableIncreaseOfLevelForStorage);
- var storageStructureAreaProperties = new LogNormalDistributionProperties
+ var storageStructureAreaProperties = new LogNormalDistributionVariationProperties
{
Data = input.StorageStructureArea
};
@@ -108,13 +108,13 @@
};
AssertDistributionProperties(flowWidthAtBottomProtectionProperties, properties.FlowWidthAtBottomProtection);
- var widthOfFlowAperturesProperties = new NormalDistributionProperties
+ var widthOfFlowAperturesProperties = new NormalDistributionVariationProperties
{
Data = input.WidthOfFlowApertures
};
AssertDistributionProperties(widthOfFlowAperturesProperties, properties.WidthOfFlowApertures);
- var criticalOvertoppingDischargeProperties = new LogNormalDistributionProperties
+ var criticalOvertoppingDischargeProperties = new LogNormalDistributionVariationProperties
{
Data = input.CriticalOvertoppingDischarge
};
@@ -126,7 +126,7 @@
Assert.AreEqual(input.HydraulicBoundaryLocation, properties.HydraulicBoundaryLocation);
- var stormDurationProperties = new LogNormalDistributionProperties
+ var stormDurationProperties = new LogNormalDistributionVariationProperties
{
Data = input.StormDuration
};
@@ -271,6 +271,11 @@
Assert.AreEqual(expected.Data, actual.Data);
}
+ private static void AssertDistributionProperties(LogNormalDistributionVariationProperties expected, LogNormalDistributionVariationProperties actual)
+ {
+ Assert.AreEqual(expected.Data, actual.Data);
+ }
+
private const int orientationOfTheNormalOfTheStructurePropertyIndex = 0;
private const int levelOfCrestOfStructurePropertyIndex = 1;
private const int allowableIncreaseOfLevelForStoragePropertyIndex = 2;