Index: Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverCalculationsProperties.cs =================================================================== diff -u -ra4921cd3a6c1247f24331618100ab7c468007bd5 -rf9ca24058b91d70a3ff903638831960c76899d95 --- Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverCalculationsProperties.cs (.../StabilityStoneCoverCalculationsProperties.cs) (revision a4921cd3a6c1247f24331618100ab7c468007bd5) +++ Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverCalculationsProperties.cs (.../StabilityStoneCoverCalculationsProperties.cs) (revision f9ca24058b91d70a3ff903638831960c76899d95) @@ -23,7 +23,6 @@ using System.ComponentModel; using Core.Common.Util.Attributes; using Core.Gui.Attributes; -using Core.Gui.PropertyBag; using Riskeer.Revetment.Forms.PropertyClasses; using Riskeer.StabilityStoneCover.Data; using Riskeer.StabilityStoneCover.Forms.Properties; @@ -34,7 +33,7 @@ /// /// Calculation related ViewModel of for properties panel. /// - public class StabilityStoneCoverCalculationsProperties : ObjectProperties + public class StabilityStoneCoverCalculationsProperties : StabilityStoneCoverFailureMechanismProperties { private const int namePropertyIndex = 1; private const int codePropertyIndex = 2; @@ -47,8 +46,13 @@ /// /// The instance to show the properties of. /// Thrown when is null. - public StabilityStoneCoverCalculationsProperties(StabilityStoneCoverFailureMechanism data) + public StabilityStoneCoverCalculationsProperties(StabilityStoneCoverFailureMechanism data) : base(data, new ConstructionProperties { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex, + GroupPropertyIndex = groupPropertyIndex + }) + { if (data == null) { throw new ArgumentNullException(nameof(data)); @@ -57,46 +61,6 @@ Data = data; } - #region General - - [PropertyOrder(namePropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Name_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Name_Description))] - public string Name - { - get - { - return data.Name; - } - } - - [PropertyOrder(codePropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Code_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Code_Description))] - public string Code - { - get - { - return data.Code; - } - } - - [PropertyOrder(groupPropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Group_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Group_Description))] - public int Group - { - get - { - return data.Group; - } - } - - #endregion - #region Model settings [PropertyOrder(blocksPropertyIndex)] Fisheye: Tag b34121639ee958b5cc453eab960551ae69a7959a refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverFailureMechanismProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverFailurePathProperties.cs =================================================================== diff -u --- Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverFailurePathProperties.cs (revision 0) +++ Riskeer/StabilityStoneCover/src/Riskeer.StabilityStoneCover.Forms/PropertyClasses/StabilityStoneCoverFailurePathProperties.cs (revision f9ca24058b91d70a3ff903638831960c76899d95) @@ -0,0 +1,99 @@ +// Copyright (C) Stichting Deltares 2021. 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.StabilityStoneCover.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.StabilityStoneCover.Forms.PropertyClasses +{ + /// + /// Failure path related ViewModel of for properties panel. + /// + public class StabilityStoneCoverFailurePathProperties : StabilityStoneCoverFailureMechanismProperties + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int groupPropertyIndex = 3; + private const int contributionPropertyIndex = 4; + private const int nPropertyIndex = 5; + + /// + /// Creates a new instance of . + /// + /// The instance to show the properties of. + /// Thrown when is null. + public StabilityStoneCoverFailurePathProperties(StabilityStoneCoverFailureMechanism data) : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex, + GroupPropertyIndex = groupPropertyIndex + }) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + + Data = data; + } + + #region Length effect parameters + + [PropertyOrder(nPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Rounded_Description))] + public RoundedDouble N + { + get + { + return data.GeneralInput.N; + } + set + { + data.GeneralInput.N = value; + } + } + + #endregion + + #region General + + [PropertyOrder(contributionPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_Contribution_Description))] + public double Contribution + { + get + { + return data.Contribution; + } + } + + #endregion + + } +} \ No newline at end of file Fisheye: Tag b34121639ee958b5cc453eab960551ae69a7959a refers to a dead (removed) revision in file `Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverFailureMechanismPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverFailurePathPropertiesTest.cs =================================================================== diff -u --- Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverFailurePathPropertiesTest.cs (revision 0) +++ Riskeer/StabilityStoneCover/test/Riskeer.StabilityStoneCover.Forms.Test/PropertyClasses/StabilityStoneCoverFailurePathPropertiesTest.cs (revision f9ca24058b91d70a3ff903638831960c76899d95) @@ -0,0 +1,191 @@ +// Copyright (C) Stichting Deltares 2021. 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.TestUtil; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.StabilityStoneCover.Data; +using Riskeer.StabilityStoneCover.Forms.PropertyClasses; + +namespace Riskeer.StabilityStoneCover.Forms.Test.PropertyClasses +{ + public class StabilityStoneCoverFailurePathPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int groupPropertyIndex = 2; + private const int contributionPropertyIndex = 3; + private const int nPropertyIndex = 4; + private MockRepository mocks; + + [SetUp] + public void SetUp() + { + mocks = new MockRepository(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + + // Call + var properties = new StabilityStoneCoverFailurePathProperties(failureMechanism); + + // Assert + Assert.IsInstanceOf(properties); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + Assert.AreEqual(failureMechanism.Group, properties.Group); + Assert.AreEqual(failureMechanism.Contribution, properties.Contribution); + + GeneralStabilityStoneCoverWaveConditionsInput generalInput = failureMechanism.GeneralInput; + Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); + Assert.AreEqual(generalInput.N, + properties.N, + properties.N.GetAccuracy()); + } + + [Test] + public void Constructor_Always_PropertiesHaveExpectedAttributesValues() + { + // Setup + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + + // Call + var properties = new StabilityStoneCoverFailurePathProperties(failureMechanism); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(5, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + const string lengthEffectCategory = "Lengte-effect parameters"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het toetsspoor.", + true); + + PropertyDescriptor labelProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(labelProperty, + generalCategory, + "Label", + "Het label van het toetsspoor.", + true); + + PropertyDescriptor groupProperty = dynamicProperties[groupPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(groupProperty, + generalCategory, + "Groep", + "De groep waar het toetsspoor toe behoort.", + true); + + PropertyDescriptor contributionProperty = dynamicProperties[contributionPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(contributionProperty, + generalCategory, + "Faalkansbijdrage [%]", + "Procentuele bijdrage van dit toetsspoor aan de totale overstromingskans van het traject.", + true); + + PropertyDescriptor nProperty = dynamicProperties[nPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty, + lengthEffectCategory, + "N* [-]", + "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling (afgerond)."); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(0.0)] + [TestCase(-1.0)] + [TestCase(-20.0)] + public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN) + { + // Setup + var observable = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var handler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( + failureMechanism, + (RoundedDouble) newN, + new[] + { + observable + }); + + var properties = new StabilityStoneCoverFailurePathProperties(failureMechanism); + + // Call + void Call() => properties.N = (RoundedDouble) newN; + + // Assert + const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); + Assert.IsTrue(handler.Called); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(20.0)] + public void N_SetValidValue_UpdateDataAndNotifyObservers(double newN) + { + // Setup + var observable = mocks.StrictMock(); + observable.Expect(o => o.NotifyObservers()); + mocks.ReplayAll(); + + var failureMechanism = new StabilityStoneCoverFailureMechanism(); + var handler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( + failureMechanism, + (RoundedDouble) newN, + new[] + { + observable + }); + + var properties = new StabilityStoneCoverFailurePathProperties(failureMechanism); + + // Call + properties.N = (RoundedDouble) newN; + + // Assert + Assert.AreEqual(newN, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); + Assert.IsTrue(handler.Called); + + mocks.VerifyAll(); + } + } +} \ No newline at end of file