Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismProperties.cs =================================================================== diff -u -ra663d0eb4c24012fdfafc00ee7aaffb18e75cb96 -r361e46306c582319caa1c97e27bddc18492a68b6 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismProperties.cs (.../MacroStabilityInwardsFailureMechanismProperties.cs) (revision a663d0eb4c24012fdfafc00ee7aaffb18e75cb96) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsFailureMechanismProperties.cs (.../MacroStabilityInwardsFailureMechanismProperties.cs) (revision 361e46306c582319caa1c97e27bddc18492a68b6) @@ -20,14 +20,11 @@ // All rights reserved. using System; -using System.Collections.Generic; -using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Util.Attributes; using Ringtoets.Common.Data.Probability; -using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.MacroStabilityInwards.Data; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -38,62 +35,27 @@ /// public class MacroStabilityInwardsFailureMechanismProperties : ObjectProperties { - 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 input parameter is null. - public MacroStabilityInwardsFailureMechanismProperties(MacroStabilityInwardsFailureMechanism data, - IFailureMechanismPropertyChangeHandler handler) + /// Thrown when is null. + public MacroStabilityInwardsFailureMechanismProperties(MacroStabilityInwardsFailureMechanism data) { if (data == null) { throw new ArgumentNullException(nameof(data)); } - if (handler == null) - { - throw new ArgumentNullException(nameof(handler)); - } - Data = data; - propertyChangeHandler = handler; } [DynamicVisibleValidationMethod] public bool DynamicVisibleValidationMethod(string propertyName) { - if (!data.IsRelevant && ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName)) - { - return false; - } - - return true; + return data.IsRelevant || !ShouldHidePropertyWhenFailureMechanismIrrelevant(propertyName); } - private void ChangePropertyValueAndNotifyAffectedObjects( - SetFailureMechanismPropertyValueDelegate setPropertyValue, - TValue value) - { - IEnumerable affectedObjects = propertyChangeHandler.SetPropertyValueAfterConfirmation( - data, - value, - setPropertyValue); - - NotifyAffectedObjects(affectedObjects); - } - - private static void NotifyAffectedObjects(IEnumerable affectedObjects) - { - foreach (IObservable affectedObject in affectedObjects) - { - affectedObject.NotifyObservers(); - } - } - private bool ShouldHidePropertyWhenFailureMechanismIrrelevant(string propertyName) { return nameof(A).Equals(propertyName) Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs =================================================================== diff -u -rfc0a6de06f052bb48fa54c2fc0d592f0b311def5 -r361e46306c582319caa1c97e27bddc18492a68b6 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision fc0a6de06f052bb48fa54c2fc0d592f0b311def5) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Plugin/MacroStabilityInwardsPlugin.cs (.../MacroStabilityInwardsPlugin.cs) (revision 361e46306c582319caa1c97e27bddc18492a68b6) @@ -70,8 +70,7 @@ { yield return new PropertyInfo { - CreateInstance = context => new MacroStabilityInwardsFailureMechanismProperties(context.WrappedData, - new FailureMechanismPropertyChangeHandler()) + CreateInstance = context => new MacroStabilityInwardsFailureMechanismProperties(context.WrappedData) }; yield return new PropertyInfo { Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesTest.cs =================================================================== diff -u -r65ce8c5ab171b234e33e2291998c9d89276db896 -r361e46306c582319caa1c97e27bddc18492a68b6 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesTest.cs (.../MacroStabilityInwardsFailureMechanismPropertiesTest.cs) (revision 65ce8c5ab171b234e33e2291998c9d89276db896) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsFailureMechanismPropertiesTest.cs (.../MacroStabilityInwardsFailureMechanismPropertiesTest.cs) (revision 361e46306c582319caa1c97e27bddc18492a68b6) @@ -28,7 +28,6 @@ using Rhino.Mocks; using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Data.TestUtil; -using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.Forms.PropertyClasses; @@ -38,36 +37,17 @@ public class MacroStabilityInwardsFailureMechanismPropertiesTest { [Test] - public void Constructor_DataIsNull_ThrowArgumentNullException() + public void Constructor_DataNull_ThrowArgumentNullException() { - // Setup - var mocks = new MockRepository(); - var handler = mocks.Stub>(); - mocks.ReplayAll(); - // Call - TestDelegate test = () => new MacroStabilityInwardsFailureMechanismProperties(null, handler); + TestDelegate test = () => new MacroStabilityInwardsFailureMechanismProperties(null); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("data", paramName); - mocks.VerifyAll(); } [Test] - public void Constructor_ChangeHandlerIsNull_ThrowArgumentNullException() - { - // Call - TestDelegate test = () => new MacroStabilityInwardsFailureMechanismProperties( - new MacroStabilityInwardsFailureMechanism(), - null); - - // Assert - string paramName = Assert.Throws(test).ParamName; - Assert.AreEqual("handler", paramName); - } - - [Test] [TestCase(true)] [TestCase(false)] public void Constructor_ExpectedValues(bool isRelevant) @@ -78,14 +58,8 @@ IsRelevant = isRelevant }; - var mockRepository = new MockRepository(); - var handler = mockRepository.Stub>(); - mockRepository.ReplayAll(); - // Call - var properties = new MacroStabilityInwardsFailureMechanismProperties( - failureMechanism, - handler); + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism); // Assert Assert.IsInstanceOf>(properties); @@ -105,8 +79,6 @@ Assert.AreEqual(probabilityAssessmentInput.SectionLength, properties.SectionLength, properties.SectionLength.GetAccuracy()); - - mockRepository.VerifyAll(); } [Test] @@ -118,14 +90,8 @@ IsRelevant = true }; - var mockRepository = new MockRepository(); - var handler = mockRepository.Stub>(); - mockRepository.ReplayAll(); - // Call - var properties = new MacroStabilityInwardsFailureMechanismProperties( - failureMechanism, - handler); + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -181,8 +147,6 @@ "N* [-]", "De parameter 'N' die gebruikt wordt om het lengte-effect mee te nemen in de beoordeling (afgerond).", true); - - mockRepository.VerifyAll(); } [Test] @@ -194,15 +158,8 @@ IsRelevant = false }; - var mockRepository = new MockRepository(); - var handler = mockRepository.Stub>(); - - mockRepository.ReplayAll(); - // Call - var properties = new MacroStabilityInwardsFailureMechanismProperties( - failureMechanism, - handler); + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -230,8 +187,6 @@ "Is relevant", "Geeft aan of dit toetsspoor relevant is of niet.", true); - - mockRepository.VerifyAll(); } [Test] @@ -245,15 +200,12 @@ // Setup var mocks = new MockRepository(); var observer = mocks.StrictMock(); - var changeHandler = mocks.Stub>(); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); failureMechanism.Attach(observer); - var properties = new MacroStabilityInwardsFailureMechanismProperties( - failureMechanism, - changeHandler); + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism); // Call TestDelegate call = () => properties.A = value; @@ -275,16 +227,13 @@ // Setup var mocks = new MockRepository(); var observer = mocks.StrictMock(); - var changeHandler = mocks.Stub>(); observer.Expect(o => o.UpdateObserver()); mocks.ReplayAll(); var failureMechanism = new MacroStabilityInwardsFailureMechanism(); failureMechanism.Attach(observer); - var properties = new MacroStabilityInwardsFailureMechanismProperties( - failureMechanism, - changeHandler); + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism); // Call properties.A = value; @@ -300,17 +249,11 @@ public void DynamicVisibleValidationMethod_DependingOnRelevancy_ReturnExpectedVisibility(bool isRelevant) { // Setup - var mocks = new MockRepository(); - var changeHandler = mocks.Stub>(); - mocks.ReplayAll(); - var failureMechanism = new MacroStabilityInwardsFailureMechanism { IsRelevant = isRelevant }; - var properties = new MacroStabilityInwardsFailureMechanismProperties( - failureMechanism, - changeHandler); + var properties = new MacroStabilityInwardsFailureMechanismProperties(failureMechanism); // Call & Assert Assert.IsTrue(properties.DynamicVisibleValidationMethod(nameof(properties.Name))); @@ -323,8 +266,6 @@ Assert.AreEqual(isRelevant, properties.DynamicVisibleValidationMethod(nameof(properties.N))); Assert.IsTrue(properties.DynamicVisibleValidationMethod(null)); - - mocks.VerifyAll(); } } } \ No newline at end of file