Index: Riskeer/Common/src/Riskeer.Common.Forms/PropertyClasses/FailureMechanismSectionConfigurationProperties.cs
===================================================================
diff -u -rb7287691250fed592734d5c21058a6ce6eec6776 -red517ce7cfed48e23a3dd4c1381bdfb778cd9f70
--- Riskeer/Common/src/Riskeer.Common.Forms/PropertyClasses/FailureMechanismSectionConfigurationProperties.cs (.../FailureMechanismSectionConfigurationProperties.cs) (revision b7287691250fed592734d5c21058a6ce6eec6776)
+++ Riskeer/Common/src/Riskeer.Common.Forms/PropertyClasses/FailureMechanismSectionConfigurationProperties.cs (.../FailureMechanismSectionConfigurationProperties.cs) (revision ed517ce7cfed48e23a3dd4c1381bdfb778cd9f70)
@@ -67,7 +67,7 @@
[ResourcesCategory(typeof(Resources), nameof(Resources.Categories_General))]
[ResourcesDisplayName(typeof(Resources), nameof(Resources.FailureMechanismSectionConfiguration_Parameter_A_DisplayName))]
[ResourcesDescription(typeof(Resources), nameof(Resources.FailureMechanismSectionConfiguration_Parameter_A_Description))]
- public RoundedDouble ParameterA
+ public virtual RoundedDouble ParameterA
{
get
{
Index: Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/PipingFailureMechanismSectionConfigurationProperties.cs
===================================================================
diff -u
--- Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/PipingFailureMechanismSectionConfigurationProperties.cs (revision 0)
+++ Riskeer/Piping/src/Riskeer.Piping.Forms/PropertyClasses/PipingFailureMechanismSectionConfigurationProperties.cs (revision ed517ce7cfed48e23a3dd4c1381bdfb778cd9f70)
@@ -0,0 +1,98 @@
+// Copyright (C) Stichting Deltares and State of the Netherlands 2023. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.Util.Attributes;
+using Core.Gui.Attributes;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Data.Probability;
+using Riskeer.Common.Forms.ChangeHandlers;
+using Riskeer.Common.Forms.PropertyClasses;
+using Riskeer.Piping.Data;
+using Riskeer.Piping.Forms.Properties;
+using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources;
+
+namespace Riskeer.Piping.Forms.PropertyClasses
+{
+ ///
+ /// ViewModel of for properties panel.
+ ///
+ public class PipingFailureMechanismSectionConfigurationProperties : FailureMechanismSectionConfigurationProperties
+ {
+ private readonly FailureMechanismSectionConfiguration sectionConfiguration;
+ private readonly IObservablePropertyChangeHandler propertyChangeHandler;
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The section configuration to show the properties for.
+ /// The start of the section from the beginning
+ /// of the reference line in meters.
+ /// The end of the section from the beginning of
+ /// the reference line in meters.
+ /// The 'b' parameter representing the equivalent independent length to factor in the
+ /// 'length effect'.
+ /// The handler responsible for handling effects of a property change.
+ /// Thrown when or
+ /// is null.
+ public PipingFailureMechanismSectionConfigurationProperties(PipingFailureMechanismSectionConfiguration sectionConfiguration, double sectionStart, double sectionEnd, double b,
+ IObservablePropertyChangeHandler propertyChangeHandler)
+ : base(sectionConfiguration, sectionStart, sectionEnd, b)
+ {
+ if (propertyChangeHandler == null)
+ {
+ throw new ArgumentNullException(nameof(propertyChangeHandler));
+ }
+
+ this.sectionConfiguration = sectionConfiguration;
+ this.propertyChangeHandler = propertyChangeHandler;
+ }
+
+ [PropertyOrder(8)]
+ [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanismSectionConfiguration_Parameter_A_DisplayName))]
+ [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanismSectionConfiguration_Parameter_A_Description))]
+ public override RoundedDouble ParameterA
+ {
+ get
+ {
+ return base.ParameterA;
+ }
+ set
+ {
+ PropertyChangeHelper.ChangePropertyAndNotify(() => sectionConfiguration.A = value, propertyChangeHandler);
+ }
+ }
+
+ [PropertyOrder(10)]
+ [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.FailureMechanismSensitiveSectionLength_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.FailureMechanismSensitiveSectionLength_Description))]
+ public RoundedDouble FailureMechanismSensitiveSectionLength
+ {
+ get
+ {
+ return new RoundedDouble(2, sectionConfiguration.GetFailureMechanismSensitiveSectionLength());
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismSectionConfigurationPropertiesTest.cs
===================================================================
diff -u
--- Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismSectionConfigurationPropertiesTest.cs (revision 0)
+++ Riskeer/Piping/test/Riskeer.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismSectionConfigurationPropertiesTest.cs (revision ed517ce7cfed48e23a3dd4c1381bdfb778cd9f70)
@@ -0,0 +1,203 @@
+// Copyright (C) Stichting Deltares and State of the Netherlands 2023. All rights reserved.
+//
+// This file is part of Riskeer.
+//
+// Riskeer 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.TestUtil;
+using Core.Gui.TestUtil;
+using NUnit.Framework;
+using Rhino.Mocks;
+using Riskeer.Common.Data.FailureMechanism;
+using Riskeer.Common.Data.Probability;
+using Riskeer.Common.Data.TestUtil;
+using Riskeer.Common.Forms.PropertyClasses;
+using Riskeer.Common.Forms.TestUtil;
+using Riskeer.Piping.Data;
+using Riskeer.Piping.Forms.PropertyClasses;
+
+namespace Riskeer.Piping.Forms.Test.PropertyClasses
+{
+ [TestFixture]
+ public class PipingFailureMechanismSectionConfigurationPropertiesTest
+ {
+ [Test]
+ public void Constructor_PropertyChangeHandlerNull_ThrowsArgumentNullException()
+ {
+ // Setup
+ var sectionConfiguration = new PipingFailureMechanismSectionConfiguration(FailureMechanismSectionTestFactory.CreateFailureMechanismSection());
+
+ // Call
+ void Call() => new PipingFailureMechanismSectionConfigurationProperties(sectionConfiguration, double.NaN, double.NaN, double.NaN, null);
+
+ // Assert
+ var exception = Assert.Throws(Call);
+ Assert.AreEqual("propertyChangeHandler", exception.ParamName);
+ }
+
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var propertyChangeHandler = mocks.Stub();
+ mocks.ReplayAll();
+
+ var random = new Random(21);
+ double sectionStart = random.NextDouble();
+ double sectionEnd = random.NextDouble();
+ double b = random.NextDouble();
+
+ FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionConfiguration = new PipingFailureMechanismSectionConfiguration(section);
+
+ // Call
+ var properties = new PipingFailureMechanismSectionConfigurationProperties(sectionConfiguration, sectionStart, sectionEnd, b, propertyChangeHandler);
+
+ // Assert
+ Assert.IsInstanceOf(properties);
+ Assert.AreSame(section, properties.Data);
+
+ Assert.AreEqual(section.Name, properties.Name);
+ Assert.AreEqual(section.Length, properties.Length, properties.Length.GetAccuracy());
+ Assert.AreEqual(section.StartPoint, properties.StartPoint);
+ Assert.AreEqual(section.EndPoint, properties.EndPoint);
+
+ Assert.AreEqual(sectionStart, properties.SectionStart, properties.SectionStart.GetAccuracy());
+ Assert.AreEqual(sectionEnd, properties.SectionEnd, properties.SectionEnd.GetAccuracy());
+
+ Assert.AreEqual(sectionConfiguration.A, properties.ParameterA);
+ Assert.AreEqual(sectionConfiguration.GetN(b), properties.LengthEffectNRounded, properties.LengthEffectNRounded.GetAccuracy());
+ Assert.AreEqual(2, properties.FailureMechanismSensitiveSectionLength.NumberOfDecimalPlaces);
+ Assert.AreEqual(sectionConfiguration.GetFailureMechanismSensitiveSectionLength(), properties.FailureMechanismSensitiveSectionLength,
+ properties.FailureMechanismSensitiveSectionLength.GetAccuracy());
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var propertyChangeHandler = mocks.Stub();
+ mocks.ReplayAll();
+
+ FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionConfiguration = new PipingFailureMechanismSectionConfiguration(section);
+
+ // Call
+ var properties = new PipingFailureMechanismSectionConfigurationProperties(sectionConfiguration, double.NaN, double.NaN, double.NaN, propertyChangeHandler);
+
+ // Assert
+ PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
+ Assert.AreEqual(9, dynamicProperties.Count);
+
+ PropertyDescriptor nameProperty = dynamicProperties[0];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty,
+ "Algemeen",
+ "Vaknaam",
+ "De naam van het vak.",
+ true);
+ PropertyDescriptor sectionStartDistanceProperty = dynamicProperties[1];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sectionStartDistanceProperty,
+ "Algemeen",
+ "Metrering van* [m]",
+ "De afstand tussen het beginpunt van het vak en het begin van het traject, gemeten langs het traject in meters (afgerond).",
+ true);
+ PropertyDescriptor sectionEndDistanceProperty = dynamicProperties[2];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(sectionEndDistanceProperty,
+ "Algemeen",
+ "Metrering tot* [m]",
+ "De afstand tussen het eindpunt van het vak en het begin van het traject, gemeten langs het traject in meters (afgerond).",
+ true);
+ PropertyDescriptor lengthProperty = dynamicProperties[3];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lengthProperty,
+ "Algemeen",
+ "Lengte* [m]",
+ "De totale lengte van het vak in meters (afgerond).",
+ true);
+ PropertyDescriptor startPointProperty = dynamicProperties[4];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(startPointProperty,
+ "Algemeen",
+ "Beginpunt",
+ "Beginpunt van het vak (X-coördinaat, Y-coördinaat).",
+ true);
+ PropertyDescriptor endPointProperty = dynamicProperties[5];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(endPointProperty,
+ "Algemeen",
+ "Eindpunt",
+ "Eindpunt van het vak (X-coördinaat, Y-coördinaat).",
+ true);
+
+ PropertyDescriptor parameterAProperty = dynamicProperties[6];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(parameterAProperty,
+ "Algemeen",
+ "a [-]",
+ "Mechanismegevoelige fractie van het dijkvak.");
+
+ PropertyDescriptor lengthEffectNRoundedProperty = dynamicProperties[7];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(lengthEffectNRoundedProperty,
+ "Algemeen",
+ "Nvak* [-]",
+ "De parameter 'Nvak*' die het lengte-effect beschrijft in de berekening van de faalkans per vak in de semi-probabilistische toets.",
+ true);
+
+ PropertyDescriptor failureMechanismSectionSensitiveLengthProperty = dynamicProperties[8];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(failureMechanismSectionSensitiveLengthProperty,
+ "Algemeen",
+ "Mechanismegevoelige vaklengte* [m]",
+ "De mechanismegevoelige lengte van het vak in meters (afgerond).",
+ true);
+ }
+
+ [Test]
+ public void ParameterA_Always_InputChangedAndObservablesNotified()
+ {
+ // Setup
+ var random = new Random(21);
+ RoundedDouble newValue = random.NextRoundedDouble();
+
+ var mockRepository = new MockRepository();
+ var observable = mockRepository.StrictMock();
+ observable.Expect(o => o.NotifyObservers());
+ mockRepository.ReplayAll();
+
+ FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection();
+ var sectionConfiguration = new PipingFailureMechanismSectionConfiguration(section);
+
+ var customHandler = new SetPropertyValueAfterConfirmationParameterTester(new[]
+ {
+ observable
+ });
+
+ var properties = new PipingFailureMechanismSectionConfigurationProperties(sectionConfiguration, double.NaN, double.NaN, double.NaN, customHandler);
+
+ // Call
+ properties.ParameterA = newValue;
+
+ // Assert
+ Assert.AreEqual(newValue, sectionConfiguration.A, sectionConfiguration.A.GetAccuracy());
+
+ mockRepository.VerifyAll();
+ }
+ }
+}
\ No newline at end of file