Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs =================================================================== diff -u -r54e90c015ee3809e2a907cd7b865f062589ae375 -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs (.../GrassCoverErosionOutwardsFailureMechanismProperties.cs) (revision 54e90c015ee3809e2a907cd7b865f062589ae375) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs (.../GrassCoverErosionOutwardsFailureMechanismProperties.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) @@ -21,12 +21,9 @@ using System; using System.Collections.Generic; -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 RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; @@ -38,19 +35,16 @@ public class GrassCoverErosionOutwardsFailureMechanismProperties : ObjectProperties { private readonly Dictionary propertyIndexLookup; - private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; /// /// Creates a new instance of . /// /// The instance to show the properties of. /// The property values required to create an instance of . - /// Handler responsible for handling effects of a property change. /// Thrown when any parameter is null. public GrassCoverErosionOutwardsFailureMechanismProperties( GrassCoverErosionOutwardsFailureMechanism data, - ConstructionProperties constructionProperties, - IFailureMechanismPropertyChangeHandler handler) + ConstructionProperties constructionProperties) { if (data == null) { @@ -62,13 +56,7 @@ throw new ArgumentNullException(nameof(constructionProperties)); } - if (handler == null) - { - throw new ArgumentNullException(nameof(handler)); - } - Data = data; - propertyChangeHandler = handler; propertyIndexLookup = new Dictionary { @@ -83,38 +71,10 @@ }, { nameof(Contribution), constructionProperties.ContributionPropertyIndex - }, - { - nameof(N), constructionProperties.NPropertyIndex } }; } - #region Length effect parameters - - [DynamicPropertyOrder] - [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 - [DynamicPropertyOrderEvaluationMethod] public int DynamicPropertyOrderEvaluationMethod(string propertyName) { @@ -123,28 +83,11 @@ return propertyIndex; } - private static void NotifyAffectedObjects(IEnumerable affectedObjects) - { - foreach (IObservable affectedObject in affectedObjects) - { - affectedObject.NotifyObservers(); - } - } - /// /// Class holding the various construction parameters for . /// public class ConstructionProperties { - #region Length effect parameters - - /// - /// Gets or sets the property index for . - /// - public int NPropertyIndex { get; set; } - - #endregion - #region General /// Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs =================================================================== diff -u -r54e90c015ee3809e2a907cd7b865f062589ae375 -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs (.../GrassCoverErosionOutwardsFailurePathProperties.cs) (revision 54e90c015ee3809e2a907cd7b865f062589ae375) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs (.../GrassCoverErosionOutwardsFailurePathProperties.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) @@ -20,6 +20,11 @@ // All rights reserved. using System; +using System.Collections.Generic; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Util.Attributes; +using Core.Gui.Attributes; using Riskeer.Common.Forms.PropertyClasses; using Riskeer.GrassCoverErosionOutwards.Data; using RiskeerCommonFormsResources = Riskeer.Common.Forms.Properties.Resources; @@ -36,6 +41,7 @@ private const int groupPropertyIndex = 3; private const int contributionPropertyIndex = 4; private const int nPropertyIndex = 5; + private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; /// /// Creates a new instance of . @@ -50,8 +56,48 @@ NamePropertyIndex = namePropertyIndex, CodePropertyIndex = codePropertyIndex, GroupPropertyIndex = groupPropertyIndex, - ContributionPropertyIndex = contributionPropertyIndex, - NPropertyIndex = nPropertyIndex - }, handler) {} + ContributionPropertyIndex = contributionPropertyIndex + }) + { + if (handler == null) + { + throw new ArgumentNullException(nameof(handler)); + } + + 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(); + } + } } } \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsProperties.cs =================================================================== diff -u -r2e4b8f918ac0d3b3caf81280ff79bf2b679926cc -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsProperties.cs (.../GrassCoverErosionOutwardsHydraulicLoadsProperties.cs) (revision 2e4b8f918ac0d3b3caf81280ff79bf2b679926cc) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsProperties.cs (.../GrassCoverErosionOutwardsHydraulicLoadsProperties.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) @@ -23,7 +23,6 @@ using System.ComponentModel; using Core.Common.Util.Attributes; using Core.Gui.Attributes; -using Riskeer.Common.Forms.PropertyClasses; using Riskeer.GrassCoverErosionOutwards.Data; using Riskeer.GrassCoverErosionOutwards.Forms.Properties; using Riskeer.Revetment.Forms.PropertyClasses; @@ -40,27 +39,23 @@ private const int codePropertyIndex = 2; private const int groupPropertyIndex = 3; private const int contributionPropertyIndex = 4; - private const int nPropertyIndex = 5; - private const int waveRunUpPropertyIndex = 6; - private const int waveImpactPropertyIndex = 7; - private const int tailorMadeWaveImpactPropertyIndex = 8; + private const int waveRunUpPropertyIndex = 5; + private const int waveImpactPropertyIndex = 6; + private const int tailorMadeWaveImpactPropertyIndex = 7; /// /// Creates a new instance of . /// /// The instance to show the properties of. - /// Handler responsible for handling effects of a property change. - /// Thrown when any parameter is null. + /// Thrown when is null. public GrassCoverErosionOutwardsHydraulicLoadsProperties( - GrassCoverErosionOutwardsFailureMechanism data, - IFailureMechanismPropertyChangeHandler handler) : base(data, new ConstructionProperties + GrassCoverErosionOutwardsFailureMechanism data) : base(data, new ConstructionProperties { NamePropertyIndex = namePropertyIndex, CodePropertyIndex = codePropertyIndex, GroupPropertyIndex = groupPropertyIndex, - ContributionPropertyIndex = contributionPropertyIndex, - NPropertyIndex = nPropertyIndex - }, handler) {} + ContributionPropertyIndex = contributionPropertyIndex + }) {} #region Model settings Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -rb940b6d997e521c433775bcd2aa5eddd15010d15 -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision b940b6d997e521c433775bcd2aa5eddd15010d15) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) @@ -71,9 +71,7 @@ { yield return new PropertyInfo { - CreateInstance = context => new GrassCoverErosionOutwardsHydraulicLoadsProperties( - context.WrappedData, - new FailureMechanismPropertyChangeHandler()) + CreateInstance = context => new GrassCoverErosionOutwardsHydraulicLoadsProperties(context.WrappedData) }; yield return new PropertyInfo Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs =================================================================== diff -u -r3582da966b5a517f7106ee0009f039cfa7f390f9 -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (.../GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs) (revision 3582da966b5a517f7106ee0009f039cfa7f390f9) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (.../GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) @@ -21,16 +21,9 @@ using System; 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; using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses; @@ -39,34 +32,16 @@ [TestFixture] public class GrassCoverErosionOutwardsFailureMechanismPropertiesTest { - private const int namePropertyIndex = 4; - private const int codePropertyIndex = 3; - private const int groupPropertyIndex = 2; - private const int contributionPropertyIndex = 1; - private const int nPropertyIndex = 0; - private MockRepository mocks; + private const int namePropertyIndex = 3; + private const int codePropertyIndex = 2; + private const int groupPropertyIndex = 1; + private const int contributionPropertyIndex = 0; - [SetUp] - public void SetUp() - { - mocks = new MockRepository(); - } - - [TearDown] - public void TearDown() - { - mocks.VerifyAll(); - } - [Test] public void Constructor_DataNull_ThrowArgumentNullException() { - // Setup - var handler = mocks.Stub>(); - mocks.ReplayAll(); - // Call - void Call() => new GrassCoverErosionOutwardsFailureMechanismProperties(null, new GrassCoverErosionOutwardsFailureMechanismProperties.ConstructionProperties(), handler); + void Call() => new GrassCoverErosionOutwardsFailureMechanismProperties(null, new GrassCoverErosionOutwardsFailureMechanismProperties.ConstructionProperties()); // Assert var exception = Assert.Throws(Call); @@ -76,61 +51,35 @@ [Test] public void Constructor_ConstructionPropertiesNull_ThrowsArgumentNullException() { - // Setup - var handler = mocks.Stub>(); - mocks.ReplayAll(); - // Call - void Call() => new GrassCoverErosionOutwardsFailureMechanismProperties(new GrassCoverErosionOutwardsFailureMechanism(), null, handler); + void Call() => new GrassCoverErosionOutwardsFailureMechanismProperties(new GrassCoverErosionOutwardsFailureMechanism(), null); // Assert var exception = Assert.Throws(Call); Assert.AreEqual("constructionProperties", exception.ParamName); } [Test] - public void Constructor_ChangeHandlerNull_ThrowsArgumentNullException() - { - // Call - void Call() => new GrassCoverErosionOutwardsFailureMechanismProperties(new GrassCoverErosionOutwardsFailureMechanism(), new GrassCoverErosionOutwardsFailureMechanismProperties.ConstructionProperties(), null); - - // Assert - var exception = Assert.Throws(Call); - Assert.AreEqual("handler", exception.ParamName); - } - - [Test] public void Constructor_ExpectedValues() { // Setup - var handler = mocks.Stub>(); - mocks.ReplayAll(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); // Call - var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism, new GrassCoverErosionOutwardsFailureMechanismProperties.ConstructionProperties(), handler); + var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism, new GrassCoverErosionOutwardsFailureMechanismProperties.ConstructionProperties()); // 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); - - Assert.AreEqual(2, properties.N.NumberOfDecimalPlaces); - Assert.AreEqual(failureMechanism.GeneralInput.N, - properties.N, - properties.N.GetAccuracy()); } [Test] public void Constructor_Always_PropertiesHaveExpectedAttributeValues() { // Setup - var handler = mocks.Stub>(); - mocks.ReplayAll(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); // Call @@ -139,16 +88,14 @@ NamePropertyIndex = namePropertyIndex, CodePropertyIndex = codePropertyIndex, GroupPropertyIndex = groupPropertyIndex, - ContributionPropertyIndex = contributionPropertyIndex, - NPropertyIndex = nPropertyIndex - }, handler); + ContributionPropertyIndex = contributionPropertyIndex + }); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(5, dynamicProperties.Count); + Assert.AreEqual(4, dynamicProperties.Count); const string generalCategory = "Algemeen"; - const string lengthEffectCategory = "Lengte-effect parameters"; PropertyDescriptor nameProperty = dynamicProperties[namePropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, @@ -177,77 +124,6 @@ "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, - newN, - new[] - { - observable - }); - - var properties = new GrassCoverErosionOutwardsFailureMechanismProperties( - failureMechanism, - new GrassCoverErosionOutwardsFailureMechanismProperties.ConstructionProperties(), 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, - newN, - new[] - { - observable - }); - - var properties = new GrassCoverErosionOutwardsFailureMechanismProperties( - failureMechanism, - new GrassCoverErosionOutwardsFailureMechanismProperties.ConstructionProperties(), handler); - - // Call - properties.N = (RoundedDouble) newN; - - // Assert - Assert.AreEqual(newN, failureMechanism.GeneralInput.N); - Assert.IsTrue(handler.Called); - } } } \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs =================================================================== diff -u -r9c4b1971a701c1ff62d8615f3868c5f093c97f68 -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionOutwardsFailurePathPropertiesTest.cs) (revision 9c4b1971a701c1ff62d8615f3868c5f093c97f68) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionOutwardsFailurePathPropertiesTest.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) @@ -19,12 +19,17 @@ // 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; @@ -38,24 +43,23 @@ private const int groupPropertyIndex = 2; private const int contributionPropertyIndex = 3; private const int nPropertyIndex = 4; - private MockRepository mocks; - [SetUp] - public void SetUp() + [Test] + public void Constructor_ChangeHandlerNull_ThrowsArgumentNullException() { - mocks = new MockRepository(); - } + // Call + void Call() => new GrassCoverErosionOutwardsFailurePathProperties(new GrassCoverErosionOutwardsFailureMechanism(), null); - [TearDown] - public void TearDown() - { - mocks.VerifyAll(); + // Assert + var exception = Assert.Throws(Call); + Assert.AreEqual("handler", exception.ParamName); } [Test] public void Constructor_ExpectedValues() { // Setup + var mocks = new MockRepository(); var handler = mocks.Stub>(); mocks.ReplayAll(); @@ -76,12 +80,15 @@ Assert.AreEqual(generalInput.N, properties.N, properties.N.GetAccuracy()); + + mocks.VerifyAll(); } [Test] public void Constructor_Always_PropertiesHaveExpectedAttributesValues() { // Setup + var mocks = new MockRepository(); var handler = mocks.Stub>(); mocks.ReplayAll(); @@ -130,6 +137,75 @@ lengthEffectCategory, "N [-]", "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling."); + + mocks.VerifyAll(); } + + [Test] + [SetCulture("nl-NL")] + [TestCase(0.0)] + [TestCase(-1.0)] + [TestCase(-20.0)] + public void N_SetInvalidValue_ThrowsArgumentOutOfRangeExceptionNoNotifications(double newN) + { + // Setup + var mocks = new MockRepository(); + var observable = mocks.StrictMock(); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var handler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( + failureMechanism, + 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); + + mocks.VerifyAll(); + } + + [Test] + [TestCase(1.0)] + [TestCase(10.0)] + [TestCase(20.0)] + public void N_SetValidValue_UpdateDataAndNotifyObservers(double newN) + { + // Setup + var mocks = new MockRepository(); + var observable = mocks.StrictMock(); + observable.Expect(o => o.NotifyObservers()); + mocks.ReplayAll(); + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + var handler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( + failureMechanism, + newN, + new[] + { + observable + }); + + var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism, handler); + + // Call + properties.N = (RoundedDouble) newN; + + // Assert + Assert.AreEqual(newN, failureMechanism.GeneralInput.N); + Assert.IsTrue(handler.Called); + + mocks.VerifyAll(); + } } } \ No newline at end of file Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs =================================================================== diff -u -r6fa58773f92dd68cb7cc02acbf87cc9bd21f2e60 -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs (.../GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs) (revision 6fa58773f92dd68cb7cc02acbf87cc9bd21f2e60) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs (.../GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) @@ -23,8 +23,6 @@ using Core.Gui.PropertyBag; using Core.Gui.TestUtil; using NUnit.Framework; -using Rhino.Mocks; -using Riskeer.Common.Forms.PropertyClasses; using Riskeer.GrassCoverErosionOutwards.Data; using Riskeer.GrassCoverErosionOutwards.Forms.PropertyClasses; @@ -37,36 +35,18 @@ private const int codePropertyIndex = 1; private const int groupPropertyIndex = 2; private const int contributionPropertyIndex = 3; - private const int nPropertyIndex = 4; - private const int waveRunUpPropertyIndex = 5; - private const int waveImpactPropertyIndex = 6; - private const int tailorMadeWaveImpactPropertyIndex = 7; - private MockRepository mocks; + private const int waveRunUpPropertyIndex = 4; + private const int waveImpactPropertyIndex = 5; + private const int tailorMadeWaveImpactPropertyIndex = 6; - [SetUp] - public void SetUp() - { - mocks = new MockRepository(); - } - - [TearDown] - public void TearDown() - { - mocks.VerifyAll(); - } - [Test] public void Constructor_ExpectedValues() { // Setup - var mockRepository = new MockRepository(); - var changeHandler = mockRepository.Stub>(); - mockRepository.ReplayAll(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); // Call - var properties = new GrassCoverErosionOutwardsHydraulicLoadsProperties(failureMechanism, changeHandler); + var properties = new GrassCoverErosionOutwardsHydraulicLoadsProperties(failureMechanism); // Assert Assert.IsInstanceOf>(properties); @@ -84,18 +64,12 @@ [Test] public void Constructor_Always_PropertiesHaveExpectedAttributeValues() - { - // Setup - var mockRepository = new MockRepository(); - var changeHandler = mockRepository.Stub>(); - mockRepository.ReplayAll(); + { // Call + var properties = new GrassCoverErosionOutwardsHydraulicLoadsProperties(new GrassCoverErosionOutwardsFailureMechanism()); - // Call - var properties = new GrassCoverErosionOutwardsHydraulicLoadsProperties(new GrassCoverErosionOutwardsFailureMechanism(), changeHandler); - // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(8, dynamicProperties.Count); + Assert.AreEqual(7, dynamicProperties.Count); const string generalCategory = "Algemeen"; const string modelSettingsCategory = "Modelinstellingen"; @@ -128,12 +102,6 @@ "Procentuele bijdrage van dit toetsspoor aan de totale overstromingskans van het traject.", 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]; Assert.IsInstanceOf(waveRunUpProperty.Converter); PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(waveRunUpProperty,