Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/VariationCoefficientDesignVariableProperties.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/VariationCoefficientDesignVariableProperties.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/VariationCoefficientDesignVariableProperties.cs (revision 2230d58267d9924153aa45d0398ea2623f9ad198)
@@ -0,0 +1,95 @@
+// 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 Core.Common.Gui.Attributes;
+using Core.Common.Utils.Attributes;
+using Ringtoets.Common.Data.Probabilistics;
+using Ringtoets.Common.Forms.PropertyClasses;
+using Ringtoets.Piping.Forms.Properties;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Piping.Forms.PropertyClasses
+{
+ ///
+ /// ViewModel base of for properties panel.
+ ///
+ /// The type of the distribution.
+ public abstract class VariationCoefficientDesignVariableProperties
+ : VariationCoefficientDistributionPropertiesBase
+ where TDistribution : IVariationCoefficientDistribution
+ {
+ ///
+ /// Creates a new .
+ ///
+ /// Indicates which properties, if any, should be marked as read-only.
+ /// The data of the to create the properties for.
+ /// The handler responsible for handling effects of a property change.
+ /// Thrown when is null
+ /// or when any number of properties in this class is editable and any other parameter is null.
+ protected VariationCoefficientDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly,
+ VariationCoefficientDesignVariable designVariable,
+ IObservablePropertyChangeHandler handler)
+ : base(propertiesReadOnly, GetDistribution(designVariable), handler)
+ {
+ DesignVariable = designVariable;
+ }
+
+ [PropertyOrder(5)]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.DesignVariableProperties_DesignValue_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.DesignVariableProperties_DesignValue_Description))]
+ public RoundedDouble DesignValue
+ {
+ get
+ {
+ return DesignVariable.GetDesignValue();
+ }
+ }
+
+ public override string ToString()
+ {
+ return $"{DesignValue} ({RingtoetsCommonFormsResources.NormalDistribution_Mean_DisplayName} = {Mean}, " +
+ $"{RingtoetsCommonFormsResources.Distribution_VariationCoefficient_DisplayName} = {CoefficientOfVariation})";
+ }
+
+ ///
+ /// Gets the design variable.
+ ///
+ protected VariationCoefficientDesignVariable DesignVariable { get; }
+
+ ///
+ /// Gets the of the .
+ ///
+ /// The design variable to get the distribution from.
+ /// The distribution of the design variable.
+ /// Thrown when
+ /// is null.
+ private static TDistribution GetDistribution(VariationCoefficientDesignVariable designVariable)
+ {
+ if (designVariable == null)
+ {
+ throw new ArgumentNullException(nameof(designVariable));
+ }
+ return designVariable.Distribution;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/VariationCoefficientLogNormalDistributionDesignVariableProperties.cs
===================================================================
diff -u
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/VariationCoefficientLogNormalDistributionDesignVariableProperties.cs (revision 0)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/VariationCoefficientLogNormalDistributionDesignVariableProperties.cs (revision 2230d58267d9924153aa45d0398ea2623f9ad198)
@@ -0,0 +1,88 @@
+// 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 Core.Common.Utils.Attributes;
+using Ringtoets.Common.Data.Probabilistics;
+using Ringtoets.Common.Forms.PropertyClasses;
+using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources;
+
+namespace Ringtoets.Piping.Forms.PropertyClasses
+{
+ ///
+ /// ViewModel of of for properties panel.
+ ///
+ public class VariationCoefficientLogNormalDistributionDesignVariableProperties
+ : VariationCoefficientDesignVariableProperties
+ {
+ ///
+ /// Creates a new read-only .
+ ///
+ /// The to create the properties for.
+ /// Thrown when is null.
+ public VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDesignVariable designVariable)
+ : this(VariationCoefficientDistributionPropertiesReadOnly.All, designVariable, null) {}
+
+ ///
+ /// Creates a new .
+ ///
+ /// Indicates which properties, if any, should be marked as read-only.
+ /// The to create the properties for.
+ /// The handler responsible for handling effects of a property change.
+ /// Thrown when is null
+ /// or when any number of properties in this class is editable and any other parameter is null.
+ public VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly,
+ VariationCoefficientDesignVariable designVariable,
+ IObservablePropertyChangeHandler handler)
+ : base(propertiesReadOnly,
+ designVariable,
+ handler) {}
+
+ public override string DistributionType { get; } = RingtoetsCommonFormsResources.DistributionType_LogNormal;
+
+ [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.LogNormalDistribution_Mean_Description))]
+ public override RoundedDouble Mean
+ {
+ get
+ {
+ return base.Mean;
+ }
+ set
+ {
+ base.Mean = value;
+ }
+ }
+
+ [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.LogNormalDistribution_VariationCoefficient_Description))]
+ public override RoundedDouble CoefficientOfVariation
+ {
+ get
+ {
+ return base.CoefficientOfVariation;
+ }
+ set
+ {
+ base.CoefficientOfVariation = value;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/VariationCoefficientDesignVariablePropertiesTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/VariationCoefficientDesignVariablePropertiesTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/VariationCoefficientDesignVariablePropertiesTest.cs (revision 2230d58267d9924153aa45d0398ea2623f9ad198)
@@ -0,0 +1,132 @@
+// 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 NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.Probabilistics;
+using Ringtoets.Common.Forms.PropertyClasses;
+using Ringtoets.Piping.Forms.PropertyClasses;
+
+namespace Ringtoets.Piping.Forms.Test.PropertyClasses
+{
+ [TestFixture]
+ public class VariationCoefficientDesignVariablePropertiesTest
+ {
+ [Test]
+ public void Constructor_DesignVariableNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var handler = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => new SimpleDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly.None,
+ null,
+ handler);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("designVariable", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var handler = mockRepository.Stub();
+ var distribution = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var designVariable = new SimpleVariationCoefficientDesignVariableProperties(distribution, RoundedDouble.NaN);
+
+ // Call
+ var properties = new SimpleDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly.All,
+ designVariable,
+ handler);
+
+ // Assert
+ Assert.IsInstanceOf>(properties);
+ Assert.AreEqual(designVariable.GetDesignValue(), properties.DesignValue);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ public void ToString_Always_ReturnDistributionName()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var handler = mockRepository.Stub();
+ var distribution = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var numberOfDecimalPlaces = 2;
+ distribution.Mean = new RoundedDouble(numberOfDecimalPlaces, 1);
+ distribution.CoefficientOfVariation = new RoundedDouble(numberOfDecimalPlaces, 2);
+
+ var designVariable = new SimpleVariationCoefficientDesignVariableProperties(distribution, new RoundedDouble(numberOfDecimalPlaces, 0.45));
+
+ // Call
+ var properties = new SimpleDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly.None,
+ designVariable,
+ handler);
+
+ // Call
+ var propertyName = properties.ToString();
+
+ // Assert
+ Assert.AreEqual("0,45 (Verwachtingswaarde = 1,00, Variatiecoëfficiënt = 2,00)", propertyName);
+ }
+
+ private class SimpleDesignVariableProperties : VariationCoefficientDesignVariableProperties
+ {
+ public SimpleDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly propertiesReadOnly,
+ VariationCoefficientDesignVariable designVariable,
+ IObservablePropertyChangeHandler handler)
+ : base(propertiesReadOnly, designVariable, handler) {}
+
+ public override string DistributionType { get; }
+ }
+
+ public class SimpleVariationCoefficientDesignVariableProperties : VariationCoefficientDesignVariable
+ {
+ private RoundedDouble designValue;
+
+ public SimpleVariationCoefficientDesignVariableProperties(
+ IVariationCoefficientDistribution variationCoefficientLogNormalDistribution,
+ RoundedDouble designValue)
+ : base(variationCoefficientLogNormalDistribution)
+ {
+ this.designValue = designValue;
+ }
+
+ public override RoundedDouble GetDesignValue()
+ {
+ return designValue;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/VariationCoefficientLogNormalDistributionDesignVariablePropertiesTest.cs
===================================================================
diff -u
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/VariationCoefficientLogNormalDistributionDesignVariablePropertiesTest.cs (revision 0)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/VariationCoefficientLogNormalDistributionDesignVariablePropertiesTest.cs (revision 2230d58267d9924153aa45d0398ea2623f9ad198)
@@ -0,0 +1,185 @@
+// 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.Data;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.Data.Probabilistics;
+using Ringtoets.Common.Forms.PropertyClasses;
+using Ringtoets.Piping.Forms.PropertyClasses;
+
+namespace Ringtoets.Piping.Forms.Test.PropertyClasses
+{
+ [TestFixture]
+ public class VariationCoefficientLogNormalDistributionDesignVariablePropertiesTest
+ {
+ [Test]
+ public void SingleParameterConstructor_DesignVariableNull_ThrowArgumentNullException()
+ {
+ // Call
+ TestDelegate test = () => new VariationCoefficientLogNormalDistributionDesignVariableProperties(null);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("designVariable", exception.ParamName);
+ }
+
+ [Test]
+ public void SingleParameterConstructor_ExpectedValues()
+ {
+ // Setup
+ var distribution = new VariationCoefficientLogNormalDistribution();
+ var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(distribution);
+
+ // Call
+ var properties = new VariationCoefficientLogNormalDistributionDesignVariableProperties(designVariable);
+
+ // Assert
+ Assert.IsInstanceOf>(properties);
+ Assert.AreSame(distribution, properties.Data);
+ Assert.AreEqual(distribution.Mean, properties.Mean);
+ Assert.AreEqual(distribution.CoefficientOfVariation, properties.CoefficientOfVariation);
+ Assert.AreEqual("Lognormaal", properties.DistributionType);
+ }
+
+ [Test]
+ public void Constructor_DesignVariableNull_ThrowArgumentNullException()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var handler = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => new VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly.None,
+ null,
+ handler);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ Assert.AreEqual("designVariable", exception.ParamName);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var handler = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var distribution = new VariationCoefficientLogNormalDistribution();
+ var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(distribution);
+
+ // Call
+ var properties = new VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly.All,
+ designVariable,
+ handler);
+
+ // Assert
+ Assert.IsInstanceOf>(properties);
+ Assert.AreSame(distribution, properties.Data);
+ Assert.AreEqual(distribution.Mean, properties.Mean);
+ Assert.AreEqual(distribution.CoefficientOfVariation, properties.CoefficientOfVariation);
+ Assert.AreEqual("Lognormaal", properties.DistributionType);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var handler = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var distribution = new VariationCoefficientLogNormalDistribution();
+ var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(distribution);
+
+ // Call
+ var properties = new VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly.None,
+ designVariable,
+ handler);
+
+ // Assert
+ PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
+ Assert.AreEqual(4, dynamicProperties.Count);
+
+ PropertyDescriptor distributionTypeProperty = dynamicProperties[0];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(distributionTypeProperty,
+ "Misc",
+ "Type verdeling",
+ "Het soort kansverdeling waarin deze parameter gedefinieerd wordt.",
+ true);
+
+ PropertyDescriptor meanProperty = dynamicProperties[1];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(meanProperty,
+ "Misc",
+ "Verwachtingswaarde",
+ "De gemiddelde waarde van de lognormale verdeling.");
+
+ PropertyDescriptor standardDeviationProperty = dynamicProperties[2];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(standardDeviationProperty,
+ "Misc",
+ "Variatiecoëfficiënt",
+ "De variatiecoëfficiënt van de lognormale verdeling.");
+
+ PropertyDescriptor designValueProperty = dynamicProperties[3];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(designValueProperty,
+ "Misc",
+ "Rekenwaarde",
+ "De representatieve waarde die gebruikt wordt door de berekening.",
+ true);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
+ public void GetProperties_WithData_ReturnExpectedValues()
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var handler = mockRepository.Stub();
+ mockRepository.ReplayAll();
+
+ var distribution = new VariationCoefficientLogNormalDistribution(2)
+ {
+ Mean = new RoundedDouble(2, 1),
+ CoefficientOfVariation = new RoundedDouble(2, 2)
+ };
+ var designVariable = new VariationCoefficientLogNormalDistributionDesignVariable(distribution);
+
+ // Call
+ var properties = new VariationCoefficientLogNormalDistributionDesignVariableProperties(VariationCoefficientDistributionPropertiesReadOnly.None,
+ designVariable,
+ handler);
+
+ // Assert
+ Assert.AreEqual("Lognormaal", properties.DistributionType);
+ Assert.AreEqual(distribution.Mean, properties.Mean);
+ Assert.AreEqual(distribution.CoefficientOfVariation, properties.CoefficientOfVariation);
+ Assert.AreEqual(designVariable.GetDesignValue(), properties.DesignValue);
+ }
+ }
+}
\ No newline at end of file