Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs =================================================================== diff -u -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc -re727a4e22432d443b1bd2d24667e1e8c9746d73c --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs (.../GrassCoverErosionOutwardsFailurePathProperties.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailurePathProperties.cs (.../GrassCoverErosionOutwardsFailurePathProperties.cs) (revision e727a4e22432d443b1bd2d24667e1e8c9746d73c) @@ -20,12 +20,9 @@ // 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; @@ -41,31 +38,20 @@ private const int groupPropertyIndex = 3; private const int contributionPropertyIndex = 4; private const int nPropertyIndex = 5; - private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; /// /// 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. - public GrassCoverErosionOutwardsFailurePathProperties( - GrassCoverErosionOutwardsFailureMechanism data, - IFailureMechanismPropertyChangeHandler handler) : base(data, new ConstructionProperties - { - NamePropertyIndex = namePropertyIndex, - CodePropertyIndex = codePropertyIndex, - GroupPropertyIndex = groupPropertyIndex, - ContributionPropertyIndex = contributionPropertyIndex - }) - { - if (handler == null) + public GrassCoverErosionOutwardsFailurePathProperties(GrassCoverErosionOutwardsFailureMechanism data) + : base(data, new ConstructionProperties { - throw new ArgumentNullException(nameof(handler)); - } - - propertyChangeHandler = handler; - } + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex, + GroupPropertyIndex = groupPropertyIndex, + ContributionPropertyIndex = contributionPropertyIndex + }) {} #region Length effect parameters @@ -81,23 +67,11 @@ } set { - IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( - data, - value, - (f, v) => f.GeneralInput.N = v); - - NotifyAffectedObjects(affectedObjects); + data.GeneralInput.N = value; + data.NotifyObservers(); } } #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 -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc -re727a4e22432d443b1bd2d24667e1e8c9746d73c --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsProperties.cs (.../GrassCoverErosionOutwardsHydraulicLoadsProperties.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsProperties.cs (.../GrassCoverErosionOutwardsHydraulicLoadsProperties.cs) (revision e727a4e22432d443b1bd2d24667e1e8c9746d73c) @@ -48,14 +48,14 @@ /// /// The instance to show the properties of. /// Thrown when is null. - public GrassCoverErosionOutwardsHydraulicLoadsProperties( - GrassCoverErosionOutwardsFailureMechanism data) : base(data, new ConstructionProperties - { - NamePropertyIndex = namePropertyIndex, - CodePropertyIndex = codePropertyIndex, - GroupPropertyIndex = groupPropertyIndex, - ContributionPropertyIndex = contributionPropertyIndex - }) {} + public GrassCoverErosionOutwardsHydraulicLoadsProperties(GrassCoverErosionOutwardsFailureMechanism data) + : base(data, new ConstructionProperties + { + NamePropertyIndex = namePropertyIndex, + CodePropertyIndex = codePropertyIndex, + GroupPropertyIndex = groupPropertyIndex, + ContributionPropertyIndex = contributionPropertyIndex + }) {} #region Model settings Index: Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs =================================================================== diff -u -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc -re727a4e22432d443b1bd2d24667e1e8c9746d73c --- Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) +++ Riskeer/GrassCoverErosionOutwards/src/Riskeer.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision e727a4e22432d443b1bd2d24667e1e8c9746d73c) @@ -77,8 +77,7 @@ yield return new PropertyInfo { CreateInstance = context => new GrassCoverErosionOutwardsFailurePathProperties( - context.WrappedData, - new FailureMechanismPropertyChangeHandler()) + context.WrappedData) }; yield return new PropertyInfo Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs =================================================================== diff -u -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc -re727a4e22432d443b1bd2d24667e1e8c9746d73c --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionOutwardsFailurePathPropertiesTest.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailurePathPropertiesTest.cs (.../GrassCoverErosionOutwardsFailurePathPropertiesTest.cs) (revision e727a4e22432d443b1bd2d24667e1e8c9746d73c) @@ -28,8 +28,6 @@ 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; @@ -45,28 +43,13 @@ private const int nPropertyIndex = 4; [Test] - public void Constructor_ChangeHandlerNull_ThrowsArgumentNullException() - { - // Call - void Call() => new GrassCoverErosionOutwardsFailurePathProperties(new GrassCoverErosionOutwardsFailureMechanism(), null); - - // 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(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); // Call - var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism, handler); + var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism); // Assert Assert.IsInstanceOf(properties); @@ -80,22 +63,16 @@ 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(); - var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); // Call - var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism, handler); + var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -137,8 +114,6 @@ lengthEffectCategory, "N [-]", "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling."); - - mocks.VerifyAll(); } [Test] @@ -150,27 +125,20 @@ { // Setup var mocks = new MockRepository(); - var observable = mocks.StrictMock(); + var observer = mocks.StrictMock(); mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var handler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( - failureMechanism, - newN, - new[] - { - observable - }); + failureMechanism.Attach(observer); - var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism, handler); + var properties = new GrassCoverErosionOutwardsFailurePathProperties(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(); } @@ -183,27 +151,20 @@ { // Setup var mocks = new MockRepository(); - var observable = mocks.StrictMock(); - observable.Expect(o => o.NotifyObservers()); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); - var handler = new FailureMechanismSetPropertyValueAfterConfirmationParameterTester( - failureMechanism, - newN, - new[] - { - observable - }); + failureMechanism.Attach(observer); - var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism, handler); + var properties = new GrassCoverErosionOutwardsFailurePathProperties(failureMechanism); // Call properties.N = (RoundedDouble) newN; // Assert - Assert.AreEqual(newN, failureMechanism.GeneralInput.N); - Assert.IsTrue(handler.Called); + Assert.AreEqual(newN, failureMechanism.GeneralInput.N, failureMechanism.GeneralInput.N.GetAccuracy()); mocks.VerifyAll(); } Index: Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs =================================================================== diff -u -re0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc -re727a4e22432d443b1bd2d24667e1e8c9746d73c --- Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs (.../GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs) (revision e0dbdfb3d8e3e614cefb7aa240f92a0fc2309ccc) +++ Riskeer/GrassCoverErosionOutwards/test/Riskeer.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs (.../GrassCoverErosionOutwardsHydraulicLoadsPropertiesTest.cs) (revision e727a4e22432d443b1bd2d24667e1e8c9746d73c) @@ -64,7 +64,8 @@ [Test] public void Constructor_Always_PropertiesHaveExpectedAttributeValues() - { // Call + { + // Call var properties = new GrassCoverErosionOutwardsHydraulicLoadsProperties(new GrassCoverErosionOutwardsFailureMechanism()); // Assert