Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsCalculationsPropertiesTest.cs =================================================================== diff -u -ra6b25485107819b4f25c58cf768fd647b67fcb5d -r8983e38fa9279a0b707ad2652aa0fc0b9d441924 --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsCalculationsPropertiesTest.cs (.../GrassCoverErosionInwardsCalculationsPropertiesTest.cs) (revision a6b25485107819b4f25c58cf768fd647b67fcb5d) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsCalculationsPropertiesTest.cs (.../GrassCoverErosionInwardsCalculationsPropertiesTest.cs) (revision 8983e38fa9279a0b707ad2652aa0fc0b9d441924) @@ -54,6 +54,12 @@ { mocks = new MockRepository(); } + + [TearDown] + public void TearDown() + { + mocks.VerifyAll(); + } [Test] public void Constructor_ExpectedValues() @@ -92,8 +98,6 @@ Assert.AreEqual(generalInput.FshallowModelFactor.Mean, properties.FshallowModelFactor.Mean); Assert.AreEqual(generalInput.FshallowModelFactor.StandardDeviation, properties.FshallowModelFactor.StandardDeviation); - - mocks.VerifyAll(); } [Test] Index: Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailurePathPropertiesTest.cs =================================================================== diff -u -ra6b25485107819b4f25c58cf768fd647b67fcb5d -r8983e38fa9279a0b707ad2652aa0fc0b9d441924 --- Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionInwardsFailurePathPropertiesTest.cs) (revision a6b25485107819b4f25c58cf768fd647b67fcb5d) +++ Riskeer/GrassCoverErosionInwards/test/Riskeer.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionInwardsFailurePathPropertiesTest.cs) (revision 8983e38fa9279a0b707ad2652aa0fc0b9d441924) @@ -87,10 +87,10 @@ public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup - var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); - var handler = mocks.Stub>(); mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); // Call var properties = new GrassCoverErosionInwardsFailurePathProperties(failureMechanism, handler); Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsCalculationsProperties.cs =================================================================== diff -u -re262d32936be3357594b08fd1ce7aedf3b4c5182 -r8983e38fa9279a0b707ad2652aa0fc0b9d441924 --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsCalculationsProperties.cs (.../GrassCoverErosionOutwardsCalculationsProperties.cs) (revision e262d32936be3357594b08fd1ce7aedf3b4c5182) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsCalculationsProperties.cs (.../GrassCoverErosionOutwardsCalculationsProperties.cs) (revision 8983e38fa9279a0b707ad2652aa0fc0b9d441924) @@ -20,13 +20,9 @@ // All rights reserved. using System; -using System.Collections.Generic; using System.ComponentModel; -using Core.Common.Base; -using Core.Common.Base.Data; using Core.Common.Util.Attributes; using Core.Gui.Attributes; -using Core.Gui.PropertyBag; using Riskeer.Common.Forms.PropertyClasses; using Riskeer.GrassCoverErosionOutwards.Data; using Riskeer.GrassCoverErosionOutwards.Forms.Properties; @@ -38,7 +34,7 @@ /// /// Calculation related ViewModel of for properties panel. /// - public class GrassCoverErosionOutwardsCalculationsProperties : ObjectProperties + public class GrassCoverErosionOutwardsCalculationsProperties : GrassCoverErosionOutwardsFailureMechanismProperties { private const int namePropertyIndex = 1; private const int codePropertyIndex = 2; @@ -49,117 +45,23 @@ private const int waveImpactPropertyIndex = 7; private const int tailorMadeWaveImpactPropertyIndex = 8; - private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; - /// /// Creates a new instance of . /// - /// The failure mechanism to show the properties for. + /// The instance to show the properties of. /// Handler responsible for handling effects of a property change. - /// Thrown when is null. + /// Thrown when is null. public GrassCoverErosionOutwardsCalculationsProperties( - GrassCoverErosionOutwardsFailureMechanism failureMechanism, - IFailureMechanismPropertyChangeHandler handler) + GrassCoverErosionOutwardsFailureMechanism data, + IFailureMechanismPropertyChangeHandler handler) : base(data, new ConstructionProperties { - if (failureMechanism == null) - { - throw new ArgumentNullException(nameof(failureMechanism)); - } + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex, + GroupPropertyIndex = groupPropertyIndex, + ContributionPropertyIndex = contributionPropertyIndex, + NPropertyIndex = nPropertyIndex + }, handler) {} - if (handler == null) - { - throw new ArgumentNullException(nameof(handler)); - } - - Data = failureMechanism; - propertyChangeHandler = handler; - } - - #region Length effect parameters - - [PropertyOrder(nPropertyIndex)] - [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_LengthEffect))] - [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_DisplayName))] - [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_N_Description))] - public RoundedDouble N - { - get - { - return data.GeneralInput.N; - } - set - { - IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( - data, - value, - (f, v) => f.GeneralInput.N = v); - - NotifyAffectedObjects(affectedObjects); - } - } - - #endregion - - private static void NotifyAffectedObjects(IEnumerable affectedObjects) - { - foreach (IObservable affectedObject in affectedObjects) - { - affectedObject.NotifyObservers(); - } - } - - #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; - } - } - - [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 - #region Model settings [PropertyOrder(waveRunUpPropertyIndex)] Fisheye: Tag 8bd852f489b78cc8bb932825f097e95ef923be81 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs (revision 8983e38fa9279a0b707ad2652aa0fc0b9d441924) @@ -0,0 +1,57 @@ +// 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 Riskeer.Common.Forms.PropertyClasses; +using Riskeer.GrassCoverErosionOutwards.Data; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses +{ + /// + /// Failure path related ViewModel of for properties panel. + /// + public class GrassCoverErosionOutwardsFailurePathProperties : GrassCoverErosionOutwardsFailureMechanismProperties + { + 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. + /// Handler responsible for handling effects of a property change. + /// Thrown when is null. + public GrassCoverErosionOutwardsFailurePathProperties( + GrassCoverErosionOutwardsFailureMechanism data, + IFailureMechanismPropertyChangeHandler handler) : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex, + GroupPropertyIndex = groupPropertyIndex, + ContributionPropertyIndex = contributionPropertyIndex, + NPropertyIndex = nPropertyIndex + }, handler) {} + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r8bd852f489b78cc8bb932825f097e95ef923be81 -r8983e38fa9279a0b707ad2652aa0fc0b9d441924 --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 8bd852f489b78cc8bb932825f097e95ef923be81) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 8983e38fa9279a0b707ad2652aa0fc0b9d441924) @@ -84,6 +84,12 @@ context.WrappedData, new GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler()) }; + yield return new PropertyInfo + { + CreateInstance = context => new GrassCoverErosionOutwardsFailurePathProperties( + context.WrappedData, + new GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler()) + }; yield return new PropertyInfo { CreateInstance = context => new DesignWaterLevelCalculationsProperties(context.WrappedData) Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsCalculationsPropertiesTest.cs =================================================================== diff -u -r60d2150807dae0d16cb683b12b9857fb66e69bec -r8983e38fa9279a0b707ad2652aa0fc0b9d441924 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsCalculationsPropertiesTest.cs (.../GrassCoverErosionOutwardsCalculationsPropertiesTest.cs) (revision 60d2150807dae0d16cb683b12b9857fb66e69bec) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsCalculationsPropertiesTest.cs (.../GrassCoverErosionOutwardsCalculationsPropertiesTest.cs) (revision 8983e38fa9279a0b707ad2652aa0fc0b9d441924) @@ -23,11 +23,11 @@ using System.ComponentModel; using Core.Common.Base; using Core.Common.Base.Data; +using Core.Common.TestUtil; using Core.Gui.PropertyBag; using Core.Gui.TestUtil; using NUnit.Framework; using Rhino.Mocks; -using Riskeer.Common.Data.TestUtil; using Riskeer.Common.Forms.PropertyClasses; using Riskeer.Common.Forms.TestUtil; using Riskeer.GrassCoverErosionOutwards.Data; @@ -46,32 +46,18 @@ private const int waveRunUpPropertyIndex = 5; private const int waveImpactPropertyIndex = 6; private const int tailorMadeWaveImpactPropertyIndex = 7; + private MockRepository mocks; - [Test] - public void Constructor_WithoutFailureMechanism_ThrowsArgumentNullException() + [SetUp] + public void SetUp() { - // Setup - var mockRepository = new MockRepository(); - var changeHandler = mockRepository.Stub>(); - mockRepository.ReplayAll(); - - // Call - void Call() => new GrassCoverErosionOutwardsCalculationsProperties(null, changeHandler); - - // Assert - string paramName = Assert.Throws(Call).ParamName; - Assert.AreEqual("failureMechanism", paramName); + mocks = new MockRepository(); } - [Test] - public void Constructor_WithoutChangeHandler_ThrowsArgumentNullException() + [TearDown] + public void TearDown() { - // Call - void Call() => new GrassCoverErosionOutwardsCalculationsProperties(new GrassCoverErosionOutwardsFailureMechanism(), null); - - // Assert - string paramName = Assert.Throws(Call).ParamName; - Assert.AreEqual("handler", paramName); + mocks.VerifyAll(); } [Test] @@ -154,41 +140,43 @@ "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling."); PropertyDescriptor waveRunUpProperty = dynamicProperties[waveRunUpPropertyIndex]; + Assert.IsInstanceOf(waveRunUpProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveRunUpProperty, modelSettingsCategory, "Golfoploop", "De modelinstellingen voor het berekenen van golfcondities voor golfoploop.", true); PropertyDescriptor waveImpactProperty = dynamicProperties[waveImpactPropertyIndex]; + Assert.IsInstanceOf(waveImpactProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveImpactProperty, modelSettingsCategory, "Golfklap", "De modelinstellingen voor het berekenen van golfcondities voor golfklap zonder invloed van de golfinvalshoek.", true); PropertyDescriptor tailorMadeWaveImpactProperty = dynamicProperties[tailorMadeWaveImpactPropertyIndex]; + Assert.IsInstanceOf(tailorMadeWaveImpactProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(tailorMadeWaveImpactProperty, modelSettingsCategory, "Golfklap voor toets op maat", "De modelinstellingen voor het berekenen van golfcondities voor golfklap met invloed van de golfinvalshoek, voor toets op maat.", true); - - mockRepository.VerifyAll(); } [Test] + [SetCulture("nl-NL")] [TestCase(0.0)] [TestCase(-1.0)] [TestCase(-20.0)] public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN) { // Setup - var mockRepository = new MockRepository(); - var observable = mockRepository.StrictMock(); - mockRepository.ReplayAll(); + var observable = mocks.StrictMock(); + mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var changeHandler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( failureMechanism, newN, @@ -197,30 +185,32 @@ observable }); - var properties = new GrassCoverErosionOutwardsCalculationsProperties(failureMechanism, changeHandler); + var properties = new GrassCoverErosionOutwardsCalculationsProperties( + failureMechanism, + changeHandler); // Call void Call() => properties.N = (RoundedDouble) newN; // Assert - Assert.Throws(Call); + const string expectedMessage = "De waarde voor 'N' moet in het bereik [1,00, 20,00] liggen."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(Call, expectedMessage); Assert.IsTrue(changeHandler.Called); - mockRepository.VerifyAll(); } [Test] - [TestCase(1)] - [TestCase(10)] - [TestCase(20)] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(20.0)] public void N_SetValidValue_UpdateDataAndNotifyObservers(double newN) { // Setup - var mockRepository = new MockRepository(); - var observable = mockRepository.StrictMock(); + var observable = mocks.StrictMock(); observable.Expect(o => o.NotifyObservers()); - mockRepository.ReplayAll(); + mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var changeHandler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( failureMechanism, newN, @@ -229,15 +219,16 @@ observable }); - var properties = new GrassCoverErosionOutwardsCalculationsProperties(failureMechanism, changeHandler); + var properties = new GrassCoverErosionOutwardsCalculationsProperties( + failureMechanism, + changeHandler); // Call properties.N = (RoundedDouble) newN; // Assert - Assert.AreEqual(newN, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); + Assert.AreEqual(newN, failureMechanism.GeneralInput.N); Assert.IsTrue(changeHandler.Called); - mockRepository.VerifyAll(); } } } \ No newline at end of file Fisheye: Tag 8bd852f489b78cc8bb932825f097e95ef923be81 refers to a dead (removed) revision in file `Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs (revision 8983e38fa9279a0b707ad2652aa0fc0b9d441924) @@ -0,0 +1,201 @@ +// 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.PropertyClasses; +using Riskeer.Common.Forms.TestUtil; +using Riskeer.GrassCoverErosionOutwards.Data; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.Test.PropertyClasses +{ + [TestFixture] + public class GrassCoverErosionOutwardsFailurePathPropertiesTest + { + 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(); + } + + [TearDown] + public void TearDown() + { + mocks.VerifyAll(); + } + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var handler = mocks.Stub>(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism, handler); + + // 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); + + GeneralGrassCoverErosionOutwardsInput 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 handler = mocks.Stub>(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + + // Call + var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism, handler); + + // 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."); + } + + [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 GrassCoverErosionOutwardsFailureMechanism(); + var handler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( + failureMechanism, + (RoundedDouble) newN, + new[] + { + observable + }); + + var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism, handler); + + // 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); + } + + [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 GrassCoverErosionOutwardsFailureMechanism(); + var handler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( + failureMechanism, + (RoundedDouble) newN, + new[] + { + observable + }); + + var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism, handler); + + // Call + properties.N = (RoundedDouble) newN; + + // Assert + Assert.AreEqual(newN, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); + Assert.IsTrue(handler.Called); + } + } +} \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs =================================================================== diff -u -r8bd852f489b78cc8bb932825f097e95ef923be81 -r8983e38fa9279a0b707ad2652aa0fc0b9d441924 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 8bd852f489b78cc8bb932825f097e95ef923be81) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 8983e38fa9279a0b707ad2652aa0fc0b9d441924) @@ -137,7 +137,7 @@ PropertyInfo[] propertyInfos = plugin.GetPropertyInfos().ToArray(); // Assert - Assert.AreEqual(7, propertyInfos.Length); + Assert.AreEqual(8, propertyInfos.Length); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, @@ -146,6 +146,11 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, + typeof(GrassCoverErosionOutwardsFailurePathContext), + typeof(GrassCoverErosionOutwardsFailurePathProperties)); + + PluginTestHelper.AssertPropertyInfoDefined( + propertyInfos, typeof(GrassCoverErosionOutwardsDesignWaterLevelCalculationsContext), typeof(DesignWaterLevelCalculationsProperties));