Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsCalculationsProperties.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsCalculationsProperties.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsCalculationsProperties.cs (revision 8bd852f489b78cc8bb932825f097e95ef923be81) @@ -0,0 +1,253 @@ +// 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.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; +using Riskeer.Revetment.Forms.PropertyClasses; +using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses +{ + /// + /// ViewModel of for properties panel. + /// + public class GrassCoverErosionOutwardsCalculationsProperties : ObjectProperties + { + private const int namePropertyIndex = 1; + private const int codePropertyIndex = 2; + private const int groupPropertyIndex = 3; + private const int contributionPropertyIndex = 4; + private const int isRelevantPropertyIndex = 5; + private const int nPropertyIndex = 6; + private const int waveRunUpPropertyIndex = 7; + private const int waveImpactPropertyIndex = 8; + private const int tailorMadeWaveImpactPropertyIndex = 9; + + private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; + + /// + /// Creates a new instance of . + /// + /// The failure mechanism to show the properties for. + /// Handler responsible for handling effects of a property change. + /// Thrown when is null. + public GrassCoverErosionOutwardsCalculationsProperties( + GrassCoverErosionOutwardsFailureMechanism failureMechanism, + IFailureMechanismPropertyChangeHandler handler) + { + if (failureMechanism == null) + { + throw new ArgumentNullException(nameof(failureMechanism)); + } + + if (handler == null) + { + throw new ArgumentNullException(nameof(handler)); + } + + Data = failureMechanism; + propertyChangeHandler = handler; + } + + #region Length effect parameters + + [DynamicVisible] + [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 + + [DynamicVisibleValidationMethod] + public bool DynamicVisibleValidationMethod(string propertyName) + { + if (!data.IsRelevant && ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName)) + { + return false; + } + + return true; + } + + private static void NotifyAffectedObjects(IEnumerable affectedObjects) + { + foreach (IObservable affectedObject in affectedObjects) + { + affectedObject.NotifyObservers(); + } + } + + private bool ShouldHidePropertyWhenFailureMechanismIrrelevant(string propertyName) + { + return nameof(Contribution).Equals(propertyName) + || nameof(WaveRunUp).Equals(propertyName) + || nameof(WaveImpact).Equals(propertyName) + || nameof(TailorMadeWaveImpact).Equals(propertyName) + || nameof(N).Equals(propertyName); + } + + #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; + } + } + + [DynamicVisible] + [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; + } + } + + [PropertyOrder(isRelevantPropertyIndex)] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_IsRelevant_DisplayName))] + [ResourcesDescription(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.FailureMechanism_IsRelevant_Description))] + public bool IsRelevant + { + get + { + return data.IsRelevant; + } + } + + #endregion + + #region Model settings + + [DynamicVisible] + [PropertyOrder(waveRunUpPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveRunUp_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveRunUp_Description))] + public GeneralWaveConditionsInputProperties WaveRunUp + { + get + { + return new GeneralWaveConditionsInputProperties + { + Data = data.GeneralInput.GeneralWaveRunUpWaveConditionsInput + }; + } + } + + [DynamicVisible] + [PropertyOrder(waveImpactPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveImpact_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_WaveImpact_Description))] + public GeneralWaveConditionsInputProperties WaveImpact + { + get + { + return new GeneralWaveConditionsInputProperties + { + Data = data.GeneralInput.GeneralWaveImpactWaveConditionsInput + }; + } + } + + [DynamicVisible] + [PropertyOrder(tailorMadeWaveImpactPropertyIndex)] + [TypeConverter(typeof(ExpandableObjectConverter))] + [ResourcesCategory(typeof(RiskeerCommonFormsResources), nameof(RiskeerCommonFormsResources.Categories_ModelSettings))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_TailorMadeWaveImpact_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.GrassCoverErosionOutwardsFailureMechanismProperties_TailorMadeWaveImpact_Description))] + public GeneralWaveConditionsInputProperties TailorMadeWaveImpact + { + get + { + return new GeneralWaveConditionsInputProperties + { + Data = data.GeneralInput.GeneralTailorMadeWaveImpactWaveConditionsInput + }; + } + } + + #endregion + } +} \ No newline at end of file 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/GrassCoverErosionOutwardsWaveConditionsOutputProperties.cs =================================================================== diff -u -r34ae183aaf6141f5d956743e3026130bb56938f3 -r8bd852f489b78cc8bb932825f097e95ef923be81 --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsOutputProperties.cs (.../GrassCoverErosionOutwardsWaveConditionsOutputProperties.cs) (revision 34ae183aaf6141f5d956743e3026130bb56938f3) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveConditionsOutputProperties.cs (.../GrassCoverErosionOutwardsWaveConditionsOutputProperties.cs) (revision 8bd852f489b78cc8bb932825f097e95ef923be81) @@ -41,7 +41,7 @@ private readonly GrassCoverErosionOutwardsWaveConditionsInput input; /// - /// Creates a new instance of . + /// Creates a new instance of . /// /// The data to show. /// The input belonging to the output. Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -r886b86a66f072735567285a3489923186c236c32 -r8bd852f489b78cc8bb932825f097e95ef923be81 --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 886b86a66f072735567285a3489923186c236c32) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 8bd852f489b78cc8bb932825f097e95ef923be81) @@ -78,9 +78,9 @@ public override IEnumerable GetPropertyInfos() { - yield return new PropertyInfo + yield return new PropertyInfo { - CreateInstance = context => new GrassCoverErosionOutwardsFailureMechanismProperties( + CreateInstance = context => new GrassCoverErosionOutwardsCalculationsProperties( context.WrappedData, new GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler()) }; Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsCalculationsPropertiesTest.cs =================================================================== diff -u --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsCalculationsPropertiesTest.cs (revision 0) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsCalculationsPropertiesTest.cs (revision 8bd852f489b78cc8bb932825f097e95ef923be81) @@ -0,0 +1,349 @@ +// 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.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; +using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses; + +namespace Riskeer.GrassCoverErosionOutwards.Forms.Test.PropertyClasses +{ + [TestFixture] + public class GrassCoverErosionOutwardsCalculationsPropertiesTest + { + private const int namePropertyIndex = 0; + private const int codePropertyIndex = 1; + private const int groupPropertyIndex = 2; + private const int contributionPropertyIndex = 3; + private const int isRelevantPropertyIndex = 4; + private const int nPropertyIndex = 5; + private const int waveRunUpPropertyIndex = 6; + private const int waveImpactPropertyIndex = 7; + private const int tailorMadeWaveImpactPropertyIndex = 8; + + [Test] + public void Constructor_WithoutFailureMechanism_ThrowsArgumentNullException() + { + // Setup + var mockRepository = new MockRepository(); + var changeHandler = mockRepository.Stub>(); + mockRepository.ReplayAll(); + + // Call + TestDelegate test = () => new GrassCoverErosionOutwardsCalculationsProperties(null, changeHandler); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("failureMechanism", paramName); + } + + [Test] + public void Constructor_WithoutChangeHandler_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new GrassCoverErosionOutwardsCalculationsProperties(new GrassCoverErosionOutwardsFailureMechanism(), null); + + // Assert + string paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("handler", paramName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Constructor_WithFailureMechanism_ExpectedValues(bool isRelevant) + { + // Setup + var mockRepository = new MockRepository(); + var changeHandler = mockRepository.Stub>(); + mockRepository.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism + { + IsRelevant = isRelevant + }; + + // Call + var properties = new GrassCoverErosionOutwardsCalculationsProperties(failureMechanism, changeHandler); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(failureMechanism, properties.Data); + Assert.AreEqual(failureMechanism.Name, properties.Name); + Assert.AreEqual(failureMechanism.Code, properties.Code); + Assert.AreEqual(failureMechanism.Group, properties.Group); + Assert.AreEqual(failureMechanism.Contribution, properties.Contribution); + Assert.AreEqual(isRelevant, properties.IsRelevant); + + GeneralGrassCoverErosionOutwardsInput generalInput = failureMechanism.GeneralInput; + Assert.AreSame(generalInput.GeneralWaveRunUpWaveConditionsInput, properties.WaveRunUp.Data); + Assert.AreSame(generalInput.GeneralWaveImpactWaveConditionsInput, properties.WaveImpact.Data); + Assert.AreSame(generalInput.GeneralTailorMadeWaveImpactWaveConditionsInput, properties.TailorMadeWaveImpact.Data); + } + + [Test] + public void Constructor_IsRelevantTrue_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mockRepository = new MockRepository(); + var changeHandler = mockRepository.Stub>(); + mockRepository.ReplayAll(); + + // Call + var properties = new GrassCoverErosionOutwardsCalculationsProperties( + new GrassCoverErosionOutwardsFailureMechanism + { + IsRelevant = true + }, + changeHandler); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(9, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + const string modelSettingsCategory = "Modelinstellingen"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het toetsspoor.", + true); + + PropertyDescriptor codeProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + 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 isRelevantProperty = dynamicProperties[isRelevantPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, + generalCategory, + "Is relevant", + "Geeft aan of dit toetsspoor relevant is of niet.", + true); + + PropertyDescriptor nProperty = dynamicProperties[nPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nProperty, + "Lengte-effect parameters", + "N [-]", + "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling."); + + PropertyDescriptor waveRunUpProperty = dynamicProperties[waveRunUpPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveRunUpProperty, + modelSettingsCategory, + "Golfoploop", + "De modelinstellingen voor het berekenen van golfcondities voor golfoploop.", + true); + + PropertyDescriptor waveImpactProperty = dynamicProperties[waveImpactPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveImpactProperty, + modelSettingsCategory, + "Golfklap", + "De modelinstellingen voor het berekenen van golfcondities voor golfklap zonder invloed van de golfinvalshoek.", + true); + + PropertyDescriptor tailorMadeWaveImpactProperty = dynamicProperties[tailorMadeWaveImpactPropertyIndex]; + 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] + public void Constructor_IsRelevantFalse_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mockRepository = new MockRepository(); + var changeHandler = mockRepository.Stub>(); + mockRepository.ReplayAll(); + + // Call + var properties = new GrassCoverErosionOutwardsCalculationsProperties( + new GrassCoverErosionOutwardsFailureMechanism + { + IsRelevant = false + }, + changeHandler); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + Assert.AreEqual(4, dynamicProperties.Count); + + const string generalCategory = "Algemeen"; + + PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategory, + "Naam", + "De naam van het toetsspoor.", + true); + + PropertyDescriptor codeProperty = dynamicProperties[codePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(codeProperty, + 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 isRelevantProperty = dynamicProperties[isRelevantPropertyIndex - 1]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isRelevantProperty, + generalCategory, + "Is relevant", + "Geeft aan of dit toetsspoor relevant is of niet.", + true); + + mockRepository.VerifyAll(); + } + + [Test] + [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 failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var changeHandler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( + failureMechanism, + newN, + new[] + { + observable + }); + + var properties = new GrassCoverErosionOutwardsCalculationsProperties(failureMechanism, changeHandler); + + // Call + TestDelegate test = () => properties.N = (RoundedDouble) newN; + + // Assert + Assert.Throws(test); + Assert.IsTrue(changeHandler.Called); + mockRepository.VerifyAll(); + } + + [Test] + [TestCase(1)] + [TestCase(10)] + [TestCase(20)] + public void N_SetValidValue_UpdateDataAndNotifyObservers(double newN) + { + // Setup + var mockRepository = new MockRepository(); + var observable = mockRepository.StrictMock(); + observable.Expect(o => o.NotifyObservers()); + mockRepository.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var changeHandler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( + failureMechanism, + newN, + new[] + { + observable + }); + + var properties = new GrassCoverErosionOutwardsCalculationsProperties(failureMechanism, changeHandler); + + // Call + properties.N = (RoundedDouble) newN; + + // Assert + Assert.AreEqual(newN, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); + Assert.IsTrue(changeHandler.Called); + mockRepository.VerifyAll(); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicVisibleValidationMethod_DependingOnRelevancy_ReturnExpectedVisibility(bool isRelevant) + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub>(); + mocks.ReplayAll(); + + var properties = new GrassCoverErosionOutwardsCalculationsProperties( + new GrassCoverErosionOutwardsFailureMechanism + { + IsRelevant = isRelevant + }, + changeHandler); + + // Call & Assert + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Code))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Group))); + Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.IsRelevant))); + + Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.Contribution))); + Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.WaveRunUp))); + Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.WaveImpact))); + Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.TailorMadeWaveImpact))); + Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.N))); + + Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); + + mocks.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.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs =================================================================== diff -u -r886b86a66f072735567285a3489923186c236c32 -r8bd852f489b78cc8bb932825f097e95ef923be81 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 886b86a66f072735567285a3489923186c236c32) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/GrassCoverErosionOutwardsPluginTest.cs (.../GrassCoverErosionOutwardsPluginTest.cs) (revision 8bd852f489b78cc8bb932825f097e95ef923be81) @@ -142,7 +142,7 @@ PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, typeof(GrassCoverErosionOutwardsCalculationsContext), - typeof(GrassCoverErosionOutwardsFailureMechanismProperties)); + typeof(GrassCoverErosionOutwardsCalculationsProperties)); PluginTestHelper.AssertPropertyInfoDefined( propertyInfos, Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsCalculationsContextPropertyInfoTest.cs =================================================================== diff -u -rdd0a175348c628645d2dc498994c6d21c214d813 -r8bd852f489b78cc8bb932825f097e95ef923be81 --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsCalculationsContextPropertyInfoTest.cs (.../GrassCoverErosionOutwardsCalculationsContextPropertyInfoTest.cs) (revision dd0a175348c628645d2dc498994c6d21c214d813) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Plugin.Test/PropertyInfos/GrassCoverErosionOutwardsCalculationsContextPropertyInfoTest.cs (.../GrassCoverErosionOutwardsCalculationsContextPropertyInfoTest.cs) (revision 8bd852f489b78cc8bb932825f097e95ef923be81) @@ -45,7 +45,7 @@ // Assert Assert.AreEqual(typeof(GrassCoverErosionOutwardsCalculationsContext), info.DataType); - Assert.AreEqual(typeof(GrassCoverErosionOutwardsFailureMechanismProperties), info.PropertyObjectType); + Assert.AreEqual(typeof(GrassCoverErosionOutwardsCalculationsProperties), info.PropertyObjectType); } } @@ -68,7 +68,7 @@ IObjectProperties objectProperties = info.CreateInstance(context); // Assert - Assert.IsInstanceOf(objectProperties); + Assert.IsInstanceOf(objectProperties); Assert.AreSame(failureMechanism, objectProperties.Data); }