Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresFailureMechanismProperties.cs =================================================================== diff -u -r5f8541d2a46730d67fc2d859caa6de2921bbc820 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresFailureMechanismProperties.cs (.../ClosingStructuresFailureMechanismProperties.cs) (revision 5f8541d2a46730d67fc2d859caa6de2921bbc820) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/PropertyClasses/ClosingStructuresFailureMechanismProperties.cs (.../ClosingStructuresFailureMechanismProperties.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -28,6 +28,7 @@ using Core.Common.Utils.Attributes; using Ringtoets.ClosingStructures.Data; using Ringtoets.ClosingStructures.Forms.Properties; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PropertyClasses; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; @@ -51,7 +52,7 @@ private const int modelFactorSubCriticalFlowPropertyIndex = 9; private const int modelFactorInflowVolumePropertyIndex = 10; - private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; + private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; /// /// Creates a new instance of . @@ -61,7 +62,7 @@ /// Thrown when any input parameter is null. public ClosingStructuresFailureMechanismProperties( ClosingStructuresFailureMechanism data, - IFailureMechanismPropertyChangeHandler handler) + IFailureMechanismPropertyChangeHandler handler) { if (data == null) { Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresFailureMechanismPropertiesTest.cs =================================================================== diff -u -r5f8541d2a46730d67fc2d859caa6de2921bbc820 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresFailureMechanismPropertiesTest.cs (.../ClosingStructuresFailureMechanismPropertiesTest.cs) (revision 5f8541d2a46730d67fc2d859caa6de2921bbc820) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/PropertyClasses/ClosingStructuresFailureMechanismPropertiesTest.cs (.../ClosingStructuresFailureMechanismPropertiesTest.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -29,6 +29,7 @@ using Rhino.Mocks; using Ringtoets.ClosingStructures.Data; using Ringtoets.ClosingStructures.Forms.PropertyClasses; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PropertyClasses; namespace Ringtoets.ClosingStructures.Forms.Test.PropertyClasses @@ -41,7 +42,7 @@ { // Setup var mocks = new MockRepository(); - IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(mocks); + IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(mocks); mocks.ReplayAll(); // Call @@ -71,7 +72,7 @@ { // Setup MockRepository mocks = new MockRepository(); - IFailureMechanismPropertyChangeHandler changeHandler = CreateSimpleHandler(mocks); + IFailureMechanismPropertyChangeHandler changeHandler = CreateSimpleHandler(mocks); mocks.ReplayAll(); var failureMechanism = new ClosingStructuresFailureMechanism(); @@ -214,7 +215,7 @@ var mockRepository = new MockRepository(); var observerMock = mockRepository.StrictMock(); - var handler = mockRepository.Stub(); + var handler = mockRepository.Stub>(); handler.Expect(h => h.ConfirmPropertyChange()).Return(true); mockRepository.ReplayAll(); @@ -249,7 +250,7 @@ var observableMock = mockRepository.StrictMock(); observableMock.Expect(o => o.NotifyObservers()); - var handler = mockRepository.Stub(); + var handler = mockRepository.Stub>(); handler.Expect(h => h.ConfirmPropertyChange()).Return(true); handler.Expect(h => h.PropertyChanged(failureMechanism)).Return(new[] { observableMock }); @@ -282,7 +283,7 @@ var mockRepository = new MockRepository(); var observerMock = mockRepository.StrictMock(); - var handler = mockRepository.Stub(); + var handler = mockRepository.Stub>(); handler.Expect(h => h.ConfirmPropertyChange()).Return(false); mockRepository.ReplayAll(); @@ -302,9 +303,9 @@ mockRepository.VerifyAll(); } - private IFailureMechanismPropertyChangeHandler CreateSimpleHandler(MockRepository mockRepository) + private IFailureMechanismPropertyChangeHandler CreateSimpleHandler(MockRepository mockRepository) { - var handler = mockRepository.Stub(); + var handler = mockRepository.Stub>(); handler.Stub(h => h.ConfirmPropertyChange()).Return(true); handler.Stub(h => h.PropertyChanged(Arg.Is.NotNull)).Return(Enumerable.Empty()); Index: Ringtoets/Common/src/Ringtoets.Common.Forms/FailureMechanismPropertyChangeHandler.cs =================================================================== diff -u -r782c3e6bb64a0a674b33d6251b745dd71dade7bb -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/Common/src/Ringtoets.Common.Forms/FailureMechanismPropertyChangeHandler.cs (.../FailureMechanismPropertyChangeHandler.cs) (revision 782c3e6bb64a0a674b33d6251b745dd71dade7bb) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/FailureMechanismPropertyChangeHandler.cs (.../FailureMechanismPropertyChangeHandler.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -14,17 +14,17 @@ /// Class which properly handles data model changes due to a change of a /// failure mechanism property. /// - public class FailureMechanismPropertyChangeHandler : IFailureMechanismPropertyChangeHandler + public class FailureMechanismPropertyChangeHandler : IFailureMechanismPropertyChangeHandler { public bool ConfirmPropertyChange() { - DialogResult result = MessageBox.Show(Resources.FailureMechanismPropertyChangeHandler_Confirm_change_composition_and_clear_dependent_data, + DialogResult result = MessageBox.Show(ConfirmationMessage, CoreCommonBaseResources.Confirm, MessageBoxButtons.OKCancel); return result == DialogResult.OK; } - public IEnumerable PropertyChanged(IFailureMechanism failureMechanism) + public virtual IEnumerable PropertyChanged(IFailureMechanism failureMechanism) { if (failureMechanism == null) { @@ -38,5 +38,16 @@ } return affected; } + + /// + /// Gets the message that is shown when conformation is inquired. + /// + protected virtual string ConfirmationMessage + { + get + { + return Resources.FailureMechanismPropertyChangeHandler_Confirm_change_composition_and_clear_dependent_data; + } + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IFailureMechanismPropertyChangeHandler.cs =================================================================== diff -u -r816744aa249d90e7460b9c2844292b2e0cf13669 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IFailureMechanismPropertyChangeHandler.cs (.../IFailureMechanismPropertyChangeHandler.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IFailureMechanismPropertyChangeHandler.cs (.../IFailureMechanismPropertyChangeHandler.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -9,7 +9,7 @@ /// Interface for an object that can properly handle data model changes due to a change of a /// failure mechanism property. /// - public interface IFailureMechanismPropertyChangeHandler + public interface IFailureMechanismPropertyChangeHandler where T : IFailureMechanism { /// /// Checks to see if the change of the failure mechanism property should occur or not. @@ -25,6 +25,6 @@ /// All objects that have been affected by the change. /// Thrown when /// is null. - IEnumerable PropertyChanged(IFailureMechanism failureMechanism); + IEnumerable PropertyChanged(T failureMechanism); } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs =================================================================== diff -u -r545b105a213ed85564861b4bcf6d2d6425dbde50 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs (.../GrassCoverErosionInwardsFailureMechanismContextProperties.cs) (revision 545b105a213ed85564861b4bcf6d2d6425dbde50) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs (.../GrassCoverErosionInwardsFailureMechanismContextProperties.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -26,6 +26,7 @@ using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.GrassCoverErosionInwards.Forms.PresentationObjects; using Ringtoets.GrassCoverErosionInwards.Forms.Properties; @@ -38,7 +39,7 @@ /// public class GrassCoverErosionInwardsFailureMechanismContextProperties : ObjectProperties { - private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; + private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; private const int namePropertyIndex = 1; private const int codePropertyIndex = 2; private const int lengthEffectPropertyIndex = 3; @@ -55,7 +56,7 @@ /// Thrown when any input parameter is null. public GrassCoverErosionInwardsFailureMechanismContextProperties( GrassCoverErosionInwardsFailureMechanismContext data, - IFailureMechanismPropertyChangeHandler handler) + IFailureMechanismPropertyChangeHandler handler) { if (data == null) { Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs =================================================================== diff -u -r5f8541d2a46730d67fc2d859caa6de2921bbc820 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs) (revision 5f8541d2a46730d67fc2d859caa6de2921bbc820) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -27,6 +27,7 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.GrassCoverErosionInwards.Data; using Ringtoets.GrassCoverErosionInwards.Data.Properties; @@ -57,7 +58,7 @@ public void Constructor_DataIsNull_ThrowArgumentNullException() { // Setup - IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(); + IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(); mockRepository.ReplayAll(); // Call @@ -92,7 +93,7 @@ { // Setup var assessmentSectionMock = mockRepository.StrictMock(); - IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(); + IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(); mockRepository.ReplayAll(); @@ -126,7 +127,7 @@ { // Setup var assessmentSectionMock = mockRepository.StrictMock(); - IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(); + IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(); mockRepository.ReplayAll(); var failureMechanism = new GrassCoverErosionInwardsFailureMechanism(); @@ -207,7 +208,7 @@ { // Setup var observerMock = mockRepository.StrictMock(); - var changeHandler = mockRepository.StrictMock(); + var changeHandler = mockRepository.StrictMock>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(true); var assessmentSectionMock = mockRepository.StrictMock(); @@ -244,7 +245,7 @@ var observableMock = mockRepository.StrictMock(); observableMock.Expect(o => o.NotifyObservers()); - var changeHandler = mockRepository.StrictMock(); + var changeHandler = mockRepository.StrictMock>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(true); changeHandler.Expect(h => h.PropertyChanged(failureMechanism)).Return(new[] { observableMock }); @@ -278,7 +279,7 @@ // Setup var observerMock = mockRepository.StrictMock(); - var changeHandler = mockRepository.StrictMock(); + var changeHandler = mockRepository.StrictMock>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(false); var assessmentSectionMock = mockRepository.StrictMock(); @@ -291,7 +292,7 @@ var properties = new GrassCoverErosionInwardsFailureMechanismContextProperties( new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSectionMock), changeHandler); - var oldValue = properties.LengthEffect; + int oldValue = properties.LengthEffect; // Call properties.LengthEffect = newLengthEffect; @@ -301,9 +302,9 @@ mockRepository.VerifyAll(); } - private IFailureMechanismPropertyChangeHandler CreateSimpleHandler() + private IFailureMechanismPropertyChangeHandler CreateSimpleHandler() { - var handler = mockRepository.Stub(); + var handler = mockRepository.Stub>(); handler.Stub(h => h.ConfirmPropertyChange()).Return(true); handler.Stub(h => h.PropertyChanged(Arg.Is.NotNull)).Return(Enumerable.Empty()); Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs =================================================================== diff -u -r816744aa249d90e7460b9c2844292b2e0cf13669 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs (.../GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs (.../GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -1,30 +1,27 @@ using System; using System.Collections.Generic; using System.Linq; -using System.Windows.Forms; using Core.Common.Base; using Ringtoets.Common.Forms; +using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Service; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.Properties; -using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; namespace Ringtoets.GrassCoverErosionOutwards.Forms { /// /// Class which properly handles data model changes due to a change of a /// grass cover erosion outwards failure mechanism property. /// - public class GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler : IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler + public class GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler : FailureMechanismPropertyChangeHandler, IFailureMechanismPropertyChangeHandler { - private readonly FailureMechanismPropertyChangeHandler failureMechanismPropertyChangeHandler = new FailureMechanismPropertyChangeHandler(); - - public bool ConfirmPropertyChange() + protected override string ConfirmationMessage { - DialogResult result = MessageBox.Show(Resources.GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler_Confirm_change_composition_and_clear_dependent_data, - CoreCommonBaseResources.Confirm, - MessageBoxButtons.OKCancel); - return result == DialogResult.OK; + get + { + return Resources.GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler_Confirm_change_composition_and_clear_dependent_data; + } } public IEnumerable PropertyChanged(GrassCoverErosionOutwardsFailureMechanism failureMechanism) @@ -36,7 +33,7 @@ var affectedObjects = RingtoetsCommonDataSynchronizationService.ClearHydraulicBoundaryLocationOutput( failureMechanism.HydraulicBoundaryLocations); - return affectedObjects.Concat(failureMechanismPropertyChangeHandler.PropertyChanged(failureMechanism)); + return affectedObjects.Concat(base.PropertyChanged(failureMechanism)); } } } \ No newline at end of file Fisheye: Tag 4d77063761342b4686ef4a56c47874558a53dec7 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs =================================================================== diff -u -rcb477e2df943ac099f2792bf51a0e697fbff9077 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs (.../GrassCoverErosionOutwardsFailureMechanismProperties.cs) (revision cb477e2df943ac099f2792bf51a0e697fbff9077) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs (.../GrassCoverErosionOutwardsFailureMechanismProperties.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -25,6 +25,7 @@ using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; using log4net; +using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Service; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Forms.PresentationObjects; @@ -40,7 +41,7 @@ public class GrassCoverErosionOutwardsFailureMechanismProperties : ObjectProperties { private static readonly ILog log = LogManager.GetLogger(typeof(GrassCoverErosionOutwardsFailureMechanismProperties)); - private readonly IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler changeHandler; + private readonly IFailureMechanismPropertyChangeHandler changeHandler; /// /// Creates a new instance of . @@ -50,7 +51,7 @@ /// Thrown when is null. public GrassCoverErosionOutwardsFailureMechanismProperties( GrassCoverErosionOutwardsFailureMechanism failureMechanism, - IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler changeHandler) + IFailureMechanismPropertyChangeHandler changeHandler) { if (failureMechanism == null) { Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj =================================================================== diff -u -r816744aa249d90e7460b9c2844292b2e0cf13669 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 816744aa249d90e7460b9c2844292b2e0cf13669) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -47,7 +47,6 @@ - Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs =================================================================== diff -u -r5f8541d2a46730d67fc2d859caa6de2921bbc820 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (.../GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs) (revision 5f8541d2a46730d67fc2d859caa6de2921bbc820) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (.../GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -26,6 +26,7 @@ using Core.Common.Gui.PropertyBag; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.GrassCoverErosionOutwards.Data.Properties; using Ringtoets.GrassCoverErosionOutwards.Forms.PropertyClasses; @@ -169,7 +170,7 @@ var mockRepository = new MockRepository(); var observerMock = mockRepository.StrictMock(); - var changeHandler = mockRepository.StrictMock(); + var changeHandler = mockRepository.StrictMock>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(true); mockRepository.ReplayAll(); @@ -202,7 +203,7 @@ var observableMock = mockRepository.StrictMock(); observableMock.Expect(o => o.NotifyObservers()); - var changeHandler = mockRepository.StrictMock(); + var changeHandler = mockRepository.StrictMock>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(true); changeHandler.Expect(h => h.PropertyChanged(failureMechanism)).Return(new[] { observableMock }); @@ -230,7 +231,7 @@ var mockRepository = new MockRepository(); var observerMock = mockRepository.StrictMock(); - var changeHandler = mockRepository.StrictMock(); + var changeHandler = mockRepository.StrictMock>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(false); mockRepository.ReplayAll(); @@ -239,7 +240,7 @@ failureMechanism.Attach(observerMock); var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism, changeHandler); - var oldValue = properties.LengthEffect; + int oldValue = properties.LengthEffect; // Call properties.LengthEffect = newLengthEffect; @@ -249,9 +250,9 @@ mockRepository.VerifyAll(); } - private IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler CreateSimpleHandler(MockRepository mockRepository) + private IFailureMechanismPropertyChangeHandler CreateSimpleHandler(MockRepository mockRepository) { - var handler = mockRepository.Stub(); + var handler = mockRepository.Stub>(); handler.Stub(h => h.ConfirmPropertyChange()).Return(true); handler.Stub(h => h.PropertyChanged(Arg.Is.NotNull)).Return(Enumerable.Empty()); Fisheye: Tag 4d77063761342b4686ef4a56c47874558a53dec7 refers to a dead (removed) revision in file `Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/FailureMechanismContributionPropertiesIntegrationTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismContributionPropertiesIntegrationTest.cs =================================================================== diff -u --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismContributionPropertiesIntegrationTest.cs (revision 0) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismContributionPropertiesIntegrationTest.cs (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -0,0 +1,573 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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.Linq; +using Core.Common.Base; +using Core.Common.TestUtil; +using NUnit.Extensions.Forms; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.Contribution; +using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.Probability; +using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.Data.TestUtil; +using Ringtoets.HeightStructures.Data; +using Ringtoets.Integration.Data; +using Ringtoets.Integration.Forms.PropertyClasses; +using Ringtoets.Integration.Plugin.Handlers; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.KernelWrapper.TestUtil; + +namespace Ringtoets.Integration.Forms.Test.PropertyClasses +{ + [TestFixture] + public class FailureMechanismContributionPropertiesIntegrationTest : NUnitFormTest + { + private const string messageAllHydraulicBoundaryLocationOutputCleared = + "Alle berekende resultaten voor alle hydraulische randvoorwaardenlocaties zijn verwijderd."; + + private const string messageCalculationsremoved = "De resultaten van {0} berekeningen zijn verwijderd."; + + [Test] + public void ReturnPeriodProperty_ValueChanged_ClearsDependentDataAndNotifiesObserversAndLogsMessages() + { + // Setup + const int newReturnPeriod = 200; + const int numberOfCalculations = 3; + + var hydraulicBoundaryLocation = TestHydraulicBoundaryLocation.CreateFullyCalculated(); + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + hydraulicBoundaryLocation + } + }; + + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = hydraulicBoundaryDatabase + }; + + var emptyPipingCalculation = new PipingCalculation(new GeneralPipingInput()); + var pipingCalculation = new PipingCalculation(new GeneralPipingInput()) + { + Output = new TestPipingOutput(), + SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput() + }; + var emptyGrassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation(); + var grassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(0, false, new ProbabilityAssessmentOutput(0, 0, 0, 0, 0), + new TestDikeHeightAssessmentOutput(0)) + }; + var emptyHeightStructuresCalculation = new StructuresCalculation(); + var heightStructuresCalculation = new StructuresCalculation + { + Output = new ProbabilityAssessmentOutput(0, 0, 0, 0, 0) + }; + + var grassCoverErosionOutwardsHydraulicBoundaryLocation = hydraulicBoundaryLocation; + grassCoverErosionOutwardsHydraulicBoundaryLocation.WaveHeightOutput = new TestHydraulicBoundaryLocationOutput( + hydraulicBoundaryLocation.WaveHeight); + grassCoverErosionOutwardsHydraulicBoundaryLocation.DesignWaterLevelOutput = new TestHydraulicBoundaryLocationOutput( + hydraulicBoundaryLocation.DesignWaterLevel); + + assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations.Add(grassCoverErosionOutwardsHydraulicBoundaryLocation); + + assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(emptyPipingCalculation); + assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(pipingCalculation); + assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(emptyGrassCoverErosionInwardsCalculation); + assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(grassCoverErosionInwardsCalculation); + assessmentSection.HeightStructures.CalculationsGroup.Children.Add(emptyHeightStructuresCalculation); + assessmentSection.HeightStructures.CalculationsGroup.Children.Add(heightStructuresCalculation); + + FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; + + MockRepository mockRepository = new MockRepository(); + IObserver observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + + IObserver pipingCalculationObserver = mockRepository.StrictMock(); + pipingCalculationObserver.Expect(o => o.UpdateObserver()); + IObserver grassCoverErosionInwardsCalculationObserver = mockRepository.StrictMock(); + grassCoverErosionInwardsCalculationObserver.Expect(o => o.UpdateObserver()); + IObserver heightStructuresCalculationObserver = mockRepository.StrictMock(); + heightStructuresCalculationObserver.Expect(o => o.UpdateObserver()); + IObserver emptyPipingCalculationObserver = mockRepository.StrictMock(); + IObserver emptyGrassCoverErosionInwardsCalculationObserver = mockRepository.StrictMock(); + IObserver emptyHeightStructuresCalculationObserver = mockRepository.StrictMock(); + + IObserver hydraulicBoundaryDatabaseObserver = mockRepository.StrictMock(); + hydraulicBoundaryDatabaseObserver.Expect(hbdo => hbdo.UpdateObserver()); + IObserver grassCoverErosionOutwardsObserver = mockRepository.StrictMock(); + grassCoverErosionOutwardsObserver.Expect(o => o.UpdateObserver()); + mockRepository.ReplayAll(); + + failureMechanismContribution.Attach(observerMock); + hydraulicBoundaryDatabase.Attach(hydraulicBoundaryDatabaseObserver); + + emptyPipingCalculation.Attach(emptyPipingCalculationObserver); + emptyGrassCoverErosionInwardsCalculation.Attach(emptyGrassCoverErosionInwardsCalculationObserver); + emptyHeightStructuresCalculation.Attach(emptyHeightStructuresCalculationObserver); + + pipingCalculation.Attach(pipingCalculationObserver); + grassCoverErosionInwardsCalculation.Attach(grassCoverErosionInwardsCalculationObserver); + heightStructuresCalculation.Attach(heightStructuresCalculationObserver); + + assessmentSection.GrassCoverErosionOutwards.HydraulicBoundaryLocations.Attach(grassCoverErosionOutwardsObserver); + + var properties = new FailureMechanismContributionProperties( + failureMechanismContribution, + assessmentSection, + new FailureMechanismContributionNormChangeHandler(), + new AssessmentSectionCompositionChangeHandler()); + + // Precondition + int originalReturnPeriodValue = Convert.ToInt32(1.0/failureMechanismContribution.Norm); + Assert.AreEqual(originalReturnPeriodValue, properties.ReturnPeriod); + Assert.IsFalse(double.IsNaN(hydraulicBoundaryLocation.WaveHeight)); + Assert.IsFalse(double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel)); + Assert.IsFalse(double.IsNaN(grassCoverErosionOutwardsHydraulicBoundaryLocation.WaveHeight)); + Assert.IsFalse(double.IsNaN(grassCoverErosionOutwardsHydraulicBoundaryLocation.DesignWaterLevel)); + Assert.IsNotNull(pipingCalculation.Output); + Assert.IsNotNull(pipingCalculation.SemiProbabilisticOutput); + Assert.IsNotNull(grassCoverErosionInwardsCalculation.Output); + Assert.IsNotNull(heightStructuresCalculation.Output); + + DialogBoxHandler = (name, wnd) => + { + var dialogTester = new MessageBoxTester(wnd); + dialogTester.ClickOk(); + }; + + // Call + Action call = () => properties.ReturnPeriod = newReturnPeriod; + + // Assert + TestHelper.AssertLogMessages(call, msgs => + { + string[] messages = msgs.ToArray(); + Assert.AreEqual(string.Format(messageCalculationsremoved, numberOfCalculations), messages[0]); + Assert.AreEqual(messageAllHydraulicBoundaryLocationOutputCleared, messages[1]); + }); + Assert.AreEqual(1.0/newReturnPeriod, failureMechanismContribution.Norm); + Assert.IsNaN(hydraulicBoundaryLocation.WaveHeight); + Assert.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel); + Assert.IsNaN(grassCoverErosionOutwardsHydraulicBoundaryLocation.WaveHeight); + Assert.IsNaN(grassCoverErosionOutwardsHydraulicBoundaryLocation.DesignWaterLevel); + Assert.IsNull(pipingCalculation.Output); + Assert.IsNull(pipingCalculation.SemiProbabilisticOutput); + Assert.IsNull(grassCoverErosionInwardsCalculation.Output); + Assert.IsNull(heightStructuresCalculation.Output); + + mockRepository.VerifyAll(); + } + + [Test] + public void ReturnPeriodProperty_HydraulicBoundarySetAndCalculationsNoOutput_HydraulicBoundaryDatabaseObserversNotifiedAndMessagesLogged() + { + // Setup + const int newReturnPeriod = 200; + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase + { + Locations = + { + TestHydraulicBoundaryLocation.CreateFullyCalculated() + } + }; + + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = hydraulicBoundaryDatabase + }; + + var emptyPipingCalculation = new PipingCalculation(new GeneralPipingInput()); + var emptyGrassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation(); + var emptyHeightStructuresCalculation = new StructuresCalculation(); + + assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(emptyPipingCalculation); + assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(emptyGrassCoverErosionInwardsCalculation); + assessmentSection.HeightStructures.CalculationsGroup.Children.Add(emptyHeightStructuresCalculation); + + FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; + + var mockRepository = new MockRepository(); + IObserver observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + IObserver calculationObserver = mockRepository.StrictMock(); // No update observers expected. + IObserver hydraulicBoundaryDatabaseObserver = mockRepository.StrictMock(); + hydraulicBoundaryDatabaseObserver.Expect(hbdo => hbdo.UpdateObserver()); + mockRepository.ReplayAll(); + + failureMechanismContribution.Attach(observerMock); + hydraulicBoundaryDatabase.Attach(hydraulicBoundaryDatabaseObserver); + + emptyPipingCalculation.Attach(calculationObserver); + emptyGrassCoverErosionInwardsCalculation.Attach(calculationObserver); + emptyHeightStructuresCalculation.Attach(calculationObserver); + + var properties = new FailureMechanismContributionProperties( + failureMechanismContribution, + assessmentSection, + new FailureMechanismContributionNormChangeHandler(), + new AssessmentSectionCompositionChangeHandler()); + + HydraulicBoundaryLocation hydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations[0]; + + // Precondition + int originalReturnPeriodValue = Convert.ToInt32(1.0/failureMechanismContribution.Norm); + Assert.AreEqual(originalReturnPeriodValue, properties.ReturnPeriod); + Assert.IsFalse(double.IsNaN(hydraulicBoundaryLocation.WaveHeight)); + Assert.IsFalse(double.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel)); + + DialogBoxHandler = (name, wnd) => + { + var dialogTester = new MessageBoxTester(wnd); + dialogTester.ClickOk(); + }; + + // Call + Action call = () => properties.ReturnPeriod = newReturnPeriod; + + // Assert + TestHelper.AssertLogMessageIsGenerated(call, messageAllHydraulicBoundaryLocationOutputCleared, 1); + + Assert.AreEqual(1.0/newReturnPeriod, failureMechanismContribution.Norm); + Assert.IsNaN(hydraulicBoundaryLocation.WaveHeight); + Assert.IsNaN(hydraulicBoundaryLocation.DesignWaterLevel); + + mockRepository.VerifyAll(); + } + + [Test] + public void ReturnPeriodProperty_HydraulicBoundaryLocationNoOutputAndCalculationWithOutputAndValueChanged_CalculationObserverNotifiedAndMessageLogged() + { + // Setup + const int newReturnPeriod = 200; + const int numberOfCalculations = 3; + + HydraulicBoundaryDatabase hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + hydraulicBoundaryDatabase.Locations.Add(new TestHydraulicBoundaryLocation()); + + AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = hydraulicBoundaryDatabase + }; + + PipingCalculation emptyPipingCalculation = new PipingCalculation(new GeneralPipingInput()); + PipingCalculation pipingCalculation = new PipingCalculation(new GeneralPipingInput()) + { + Output = new TestPipingOutput(), + SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput() + }; + GrassCoverErosionInwardsCalculation emptyGrassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation(); + GrassCoverErosionInwardsCalculation grassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(0, false, new ProbabilityAssessmentOutput(0, 0, 0, 0, 0), + new TestDikeHeightAssessmentOutput(0)) + }; + var emptyHeightStructuresCalculation = new StructuresCalculation(); + var heightStructuresCalculation = new StructuresCalculation + { + Output = new ProbabilityAssessmentOutput(0, 0, 0, 0, 0) + }; + + assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(emptyPipingCalculation); + assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(pipingCalculation); + assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(emptyGrassCoverErosionInwardsCalculation); + assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(grassCoverErosionInwardsCalculation); + assessmentSection.HeightStructures.CalculationsGroup.Children.Add(emptyHeightStructuresCalculation); + assessmentSection.HeightStructures.CalculationsGroup.Children.Add(heightStructuresCalculation); + + FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; + + MockRepository mockRepository = new MockRepository(); + IObserver observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + + IObserver pipingCalculationObserver = mockRepository.StrictMock(); + pipingCalculationObserver.Expect(o => o.UpdateObserver()); + IObserver grassCoverErosionInwardsCalculationObserver = mockRepository.StrictMock(); + grassCoverErosionInwardsCalculationObserver.Expect(o => o.UpdateObserver()); + IObserver heightStructuresCalculationObserver = mockRepository.StrictMock(); + heightStructuresCalculationObserver.Expect(o => o.UpdateObserver()); + IObserver emptyPipingCalculationObserver = mockRepository.StrictMock(); + IObserver emptyGrassCoverErosionInwardsCalculationObserver = mockRepository.StrictMock(); + IObserver emptyHeightStructuresCalculationObserver = mockRepository.StrictMock(); + + IObserver hydraulicBoundaryDatabaseObserver = mockRepository.StrictMock(); // No update observer expected. + mockRepository.ReplayAll(); + + failureMechanismContribution.Attach(observerMock); + hydraulicBoundaryDatabase.Attach(hydraulicBoundaryDatabaseObserver); + + emptyPipingCalculation.Attach(emptyPipingCalculationObserver); + emptyGrassCoverErosionInwardsCalculation.Attach(emptyGrassCoverErosionInwardsCalculationObserver); + emptyHeightStructuresCalculation.Attach(emptyHeightStructuresCalculationObserver); + + pipingCalculation.Attach(pipingCalculationObserver); + grassCoverErosionInwardsCalculation.Attach(grassCoverErosionInwardsCalculationObserver); + heightStructuresCalculation.Attach(heightStructuresCalculationObserver); + + var properties = new FailureMechanismContributionProperties( + failureMechanismContribution, + assessmentSection, + new FailureMechanismContributionNormChangeHandler(), + new AssessmentSectionCompositionChangeHandler()); + + // Precondition + int originalReturnPeriodValue = Convert.ToInt32(1.0/failureMechanismContribution.Norm); + Assert.AreEqual(originalReturnPeriodValue, properties.ReturnPeriod); + Assert.IsNotNull(pipingCalculation.Output); + Assert.IsNotNull(pipingCalculation.SemiProbabilisticOutput); + Assert.IsNotNull(grassCoverErosionInwardsCalculation.Output); + Assert.IsNotNull(heightStructuresCalculation.Output); + + DialogBoxHandler = (name, wnd) => + { + var dialogTester = new MessageBoxTester(wnd); + dialogTester.ClickOk(); + }; + + // Call + Action call = () => properties.ReturnPeriod = newReturnPeriod; + + // Assert + string expectedMessage = string.Format(messageCalculationsremoved, + numberOfCalculations); + TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); + + Assert.AreEqual(1.0/newReturnPeriod, failureMechanismContribution.Norm); + Assert.IsNull(pipingCalculation.Output); + Assert.IsNull(pipingCalculation.SemiProbabilisticOutput); + Assert.IsNull(grassCoverErosionInwardsCalculation.Output); + Assert.IsNull(heightStructuresCalculation.Output); + + mockRepository.VerifyAll(); + } + + [Test] + public void ReturnPeriodProperty_NoHydraulicBoundaryLocationNoOutputAndCalculationWithOutputAndValueChanged_CalculationObserverNotifiedAndMessageLogged() + { + // Setup + const int newReturnPeriod = 200; + const int numberOfCalculations = 3; + + AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + + PipingCalculation emptyPipingCalculation = new PipingCalculation(new GeneralPipingInput()); + PipingCalculation pipingCalculation = new PipingCalculation(new GeneralPipingInput()) + { + Output = new TestPipingOutput(), + SemiProbabilisticOutput = new TestPipingSemiProbabilisticOutput() + }; + GrassCoverErosionInwardsCalculation emptyGrassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation(); + GrassCoverErosionInwardsCalculation grassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation + { + Output = new GrassCoverErosionInwardsOutput(0, false, new ProbabilityAssessmentOutput(0, 0, 0, 0, 0), + new TestDikeHeightAssessmentOutput(0)) + }; + var emptyHeightStructuresCalculation = new StructuresCalculation(); + var heightStructuresCalculation = new StructuresCalculation + { + Output = new ProbabilityAssessmentOutput(0, 0, 0, 0, 0) + }; + + assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(emptyPipingCalculation); + assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(pipingCalculation); + assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(emptyGrassCoverErosionInwardsCalculation); + assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(grassCoverErosionInwardsCalculation); + assessmentSection.HeightStructures.CalculationsGroup.Children.Add(emptyHeightStructuresCalculation); + assessmentSection.HeightStructures.CalculationsGroup.Children.Add(heightStructuresCalculation); + + FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; + + MockRepository mockRepository = new MockRepository(); + IObserver observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + + IObserver pipingCalculationObserver = mockRepository.StrictMock(); + pipingCalculationObserver.Expect(o => o.UpdateObserver()); + IObserver grassCoverErosionInwardsCalculationObserver = mockRepository.StrictMock(); + grassCoverErosionInwardsCalculationObserver.Expect(o => o.UpdateObserver()); + IObserver heightStructuresCalculationObserver = mockRepository.StrictMock(); + heightStructuresCalculationObserver.Expect(o => o.UpdateObserver()); + IObserver emptyPipingCalculationObserver = mockRepository.StrictMock(); + IObserver emptyGrassCoverErosionInwardsCalculationObserver = mockRepository.StrictMock(); + IObserver emptyHeightStructuresCalculationObserver = mockRepository.StrictMock(); + + mockRepository.ReplayAll(); + + failureMechanismContribution.Attach(observerMock); + + emptyPipingCalculation.Attach(emptyPipingCalculationObserver); + emptyGrassCoverErosionInwardsCalculation.Attach(emptyGrassCoverErosionInwardsCalculationObserver); + emptyHeightStructuresCalculation.Attach(emptyHeightStructuresCalculationObserver); + + pipingCalculation.Attach(pipingCalculationObserver); + grassCoverErosionInwardsCalculation.Attach(grassCoverErosionInwardsCalculationObserver); + heightStructuresCalculation.Attach(heightStructuresCalculationObserver); + + var properties = new FailureMechanismContributionProperties( + failureMechanismContribution, + assessmentSection, + new FailureMechanismContributionNormChangeHandler(), + new AssessmentSectionCompositionChangeHandler()); + + // Precondition + int originalReturnPeriodValue = Convert.ToInt32(1.0/failureMechanismContribution.Norm); + Assert.AreEqual(originalReturnPeriodValue, properties.ReturnPeriod); + Assert.IsNotNull(pipingCalculation.Output); + Assert.IsNotNull(pipingCalculation.SemiProbabilisticOutput); + Assert.IsNotNull(grassCoverErosionInwardsCalculation.Output); + Assert.IsNotNull(heightStructuresCalculation.Output); + + DialogBoxHandler = (name, wnd) => + { + var dialogTester = new MessageBoxTester(wnd); + dialogTester.ClickOk(); + }; + + // Call + Action call = () => properties.ReturnPeriod = newReturnPeriod; + + // Assert + string expectedMessage = string.Format(messageCalculationsremoved, + numberOfCalculations); + TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1); + + Assert.AreEqual(1.0/newReturnPeriod, failureMechanismContribution.Norm); + Assert.IsNull(pipingCalculation.Output); + Assert.IsNull(pipingCalculation.SemiProbabilisticOutput); + Assert.IsNull(grassCoverErosionInwardsCalculation.Output); + Assert.IsNull(heightStructuresCalculation.Output); + + mockRepository.VerifyAll(); + } + + [Test] + public void ReturnPeriodProperty_HydraulicBoundaryLocationNoOutputAndNoCalculationsWithOutputAndValueChanged_NoObserversNotifiedAndMessagesLogged() + { + // Setup + const int newReturnPeriod = 200; + + HydraulicBoundaryDatabase hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase(); + hydraulicBoundaryDatabase.Locations.Add(new TestHydraulicBoundaryLocation()); + + AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike) + { + HydraulicBoundaryDatabase = hydraulicBoundaryDatabase + }; + + PipingCalculation emptyPipingCalculation = new PipingCalculation(new GeneralPipingInput()); + GrassCoverErosionInwardsCalculation emptyGrassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation(); + var emptyHeightStructuresCalculation = new StructuresCalculation(); + + assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(emptyPipingCalculation); + assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(emptyGrassCoverErosionInwardsCalculation); + assessmentSection.HeightStructures.CalculationsGroup.Children.Add(emptyHeightStructuresCalculation); + + FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; + + MockRepository mockRepository = new MockRepository(); + IObserver observerMock = mockRepository.StrictMock(); + observerMock.Expect(o => o.UpdateObserver()); + IObserver calculationObserver = mockRepository.StrictMock(); + IObserver hydraulicBoundaryDatabaseObserver = mockRepository.StrictMock(); + mockRepository.ReplayAll(); + + failureMechanismContribution.Attach(observerMock); + emptyPipingCalculation.Attach(calculationObserver); + emptyGrassCoverErosionInwardsCalculation.Attach(calculationObserver); + emptyHeightStructuresCalculation.Attach(calculationObserver); + hydraulicBoundaryDatabase.Attach(hydraulicBoundaryDatabaseObserver); + + var properties = new FailureMechanismContributionProperties( + failureMechanismContribution, + assessmentSection, + new FailureMechanismContributionNormChangeHandler(), + new AssessmentSectionCompositionChangeHandler()); + + // Precondition + int originalReturnPeriodValue = Convert.ToInt32(1.0/failureMechanismContribution.Norm); + Assert.AreEqual(originalReturnPeriodValue, properties.ReturnPeriod); + + DialogBoxHandler = (name, wnd) => + { + var dialogTester = new MessageBoxTester(wnd); + dialogTester.ClickOk(); + }; + + // Call + Action call = () => properties.ReturnPeriod = newReturnPeriod; + + // Assert + TestHelper.AssertLogMessagesCount(call, 0); + Assert.AreEqual(1.0/newReturnPeriod, failureMechanismContribution.Norm); + + mockRepository.VerifyAll(); // No update observer expected. + } + + [Test] + public void ReturnPeriodProperty_NoHydraulicBoundaryDatabaseAndNoCalculationsWithOutputAndValueChanged_NoObserversNotifiedAndMessagesLogged() + { + // Setup + const int newReturnPeriod = 200; + + AssessmentSection assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + + PipingCalculation emptyPipingCalculation = new PipingCalculation(new GeneralPipingInput()); + GrassCoverErosionInwardsCalculation emptyGrassCoverErosionInwardsCalculation = new GrassCoverErosionInwardsCalculation(); + var emptyHeightStructuresCalculation = new StructuresCalculation(); + + assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(emptyPipingCalculation); + assessmentSection.GrassCoverErosionInwards.CalculationsGroup.Children.Add(emptyGrassCoverErosionInwardsCalculation); + assessmentSection.HeightStructures.CalculationsGroup.Children.Add(emptyHeightStructuresCalculation); + + FailureMechanismContribution failureMechanismContribution = assessmentSection.FailureMechanismContribution; + + var properties = new FailureMechanismContributionProperties( + failureMechanismContribution, + assessmentSection, + new FailureMechanismContributionNormChangeHandler(), + new AssessmentSectionCompositionChangeHandler()); + + // Precondition + int originalReturnPeriodValue = Convert.ToInt32(1.0/failureMechanismContribution.Norm); + Assert.AreEqual(originalReturnPeriodValue, properties.ReturnPeriod); + + // Call + failureMechanismContribution.Norm = 1.0/newReturnPeriod; + Action call = () => failureMechanismContribution.NotifyObservers(); + + // Assert + TestHelper.AssertLogMessagesCount(call, 0); + Assert.AreEqual(1.0/newReturnPeriod, failureMechanismContribution.Norm); + } + } +} \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismContributionPropertiesTest.cs =================================================================== diff -u -r545b105a213ed85564861b4bcf6d2d6425dbde50 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismContributionPropertiesTest.cs (.../FailureMechanismContributionPropertiesTest.cs) (revision 545b105a213ed85564861b4bcf6d2d6425dbde50) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/FailureMechanismContributionPropertiesTest.cs (.../FailureMechanismContributionPropertiesTest.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -43,101 +43,121 @@ [Test] public void Constructor_WithoutFailureMechanismContribution_ThrowsArgumentNullException() { + // Setup + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + var failureMechanismChangeHandler = mockRepository.Stub(); + var assessmentSectionChangeHandler = mockRepository.Stub(); + mockRepository.ReplayAll(); + // Call TestDelegate test = () => new FailureMechanismContributionProperties( null, - new AssessmentSection(AssessmentSectionComposition.Dike), - new FailureMechanismContributionNormChangeHandler(), - new AssessmentSectionCompositionChangeHandler()); + assessmentSection, + failureMechanismChangeHandler, + assessmentSectionChangeHandler); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("failureMechanismContribution", paramName); + mockRepository.VerifyAll(); } [Test] public void Constructor_WithoutAssessmentSection_ThrowsArgumentNullException() { + // Setup + var mockRepository = new MockRepository(); + var failureMechanismChangeHandler = mockRepository.Stub(); + var assessmentSectionChangeHandler = mockRepository.Stub(); + mockRepository.ReplayAll(); + + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), double.NaN, 0); + // Call TestDelegate test = () => new FailureMechanismContributionProperties( - new AssessmentSection(AssessmentSectionComposition.Dike).FailureMechanismContribution, + failureMechanismContribution, null, - new FailureMechanismContributionNormChangeHandler(), - new AssessmentSectionCompositionChangeHandler()); + failureMechanismChangeHandler, + assessmentSectionChangeHandler); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("assessmentSection", paramName); + mockRepository.VerifyAll(); } [Test] public void Constructor_WithoutFailureMechanismContributionNormChangeHandler_ThrowsArgumentNullException() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + var assessmentSectionChangeHandler = mockRepository.Stub(); + mockRepository.ReplayAll(); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), double.NaN, 0); + // Call TestDelegate test = () => new FailureMechanismContributionProperties( - assessmentSection.FailureMechanismContribution, + failureMechanismContribution, assessmentSection, - null, - new AssessmentSectionCompositionChangeHandler()); + null, + assessmentSectionChangeHandler); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("normChangeHandler", paramName); + mockRepository.VerifyAll(); } [Test] public void Constructor_WithoutAssessmentSectionCompositionChangeHandler_ThrowsArgumentNullException() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + var failureMechanismChangeHandler = mockRepository.Stub(); + mockRepository.ReplayAll(); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), double.NaN, 0); + // Call TestDelegate test = () => new FailureMechanismContributionProperties( - assessmentSection.FailureMechanismContribution, + failureMechanismContribution, assessmentSection, - new FailureMechanismContributionNormChangeHandler(), + failureMechanismChangeHandler, null); // Assert string paramName = Assert.Throws(test).ParamName; Assert.AreEqual("compositionChangeHandler", paramName); + mockRepository.VerifyAll(); } [Test] public void Constructor_WithValidParameters_DataSet() { // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var mockRepository = new MockRepository(); + var assessmentSection = mockRepository.Stub(); + var failureMechanismChangeHandler = mockRepository.Stub(); + var assessmentSectionChangeHandler = mockRepository.Stub(); + mockRepository.ReplayAll(); + var failureMechanismContribution = new FailureMechanismContribution(Enumerable.Empty(), double.NaN, 0); + // Call var properties = new FailureMechanismContributionProperties( - assessmentSection.FailureMechanismContribution, + failureMechanismContribution, assessmentSection, - new FailureMechanismContributionNormChangeHandler(), - new AssessmentSectionCompositionChangeHandler()); + failureMechanismChangeHandler, + assessmentSectionChangeHandler); // Assert Assert.IsInstanceOf>(properties); - Assert.AreSame(assessmentSection.FailureMechanismContribution, properties.Data); - } + Assert.AreSame(failureMechanismContribution, properties.Data); - [Test] - public void Constructor_Always_PropertiesHaveExpectedAttributeValues() - { - // Setup - var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); - - // Call - var properties = new FailureMechanismContributionProperties( - assessmentSection.FailureMechanismContribution, - assessmentSection, - new FailureMechanismContributionNormChangeHandler(), - new AssessmentSectionCompositionChangeHandler()); - - // Assert var dynamicPropertyBag = new DynamicPropertyBag(properties); PropertyDescriptorCollection dynamicProperties = dynamicPropertyBag.GetProperties(new Attribute[] { @@ -169,25 +189,23 @@ var assessmentSectionComposition = AssessmentSectionComposition.DikeAndDune; var assessmentSection = mocks.Stub(); assessmentSection.Stub(section => section.Composition).Return(assessmentSectionComposition); + var failureMechanismChangeHandler = mocks.Stub(); + var assessmentSectionChangeHandler = mocks.Stub(); mocks.ReplayAll(); int returnPeriod = 30000; - var failureMechanisms = Enumerable.Empty(); - var contribution = new FailureMechanismContribution(failureMechanisms, 1.1, 1.0/returnPeriod); + var contribution = new FailureMechanismContribution(Enumerable.Empty(), 1.1, 1.0/returnPeriod); + // Call var properties = new FailureMechanismContributionProperties( contribution, assessmentSection, - new FailureMechanismContributionNormChangeHandler(), - new AssessmentSectionCompositionChangeHandler()); + failureMechanismChangeHandler, + assessmentSectionChangeHandler); - // Call - int returnPeriodPropertyValue = properties.ReturnPeriod; - AssessmentSectionComposition compositionPropertyValue = properties.AssessmentSectionComposition; - // Assert - Assert.AreEqual(returnPeriod, returnPeriodPropertyValue); - Assert.AreEqual(assessmentSectionComposition, compositionPropertyValue); + Assert.AreEqual(returnPeriod, properties.ReturnPeriod); + Assert.AreEqual(assessmentSectionComposition, properties.AssessmentSectionComposition); mocks.VerifyAll(); } Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj =================================================================== diff -u -r586d097de0087256cb5cf3dda3a3c612721fee9c -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 586d097de0087256cb5cf3dda3a3c612721fee9c) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Ringtoets.Integration.Forms.Test.csproj (.../Ringtoets.Integration.Forms.Test.csproj) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -66,7 +66,7 @@ - + Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs =================================================================== diff -u -r5f8541d2a46730d67fc2d859caa6de2921bbc820 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs (.../PipingFailureMechanismContextProperties.cs) (revision 5f8541d2a46730d67fc2d859caa6de2921bbc820) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs (.../PipingFailureMechanismContextProperties.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -25,6 +25,7 @@ using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; using Core.Common.Utils.Attributes; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Piping.Forms.PresentationObjects; using Ringtoets.Piping.Forms.Properties; @@ -37,7 +38,7 @@ /// public class PipingFailureMechanismContextProperties : ObjectProperties { - private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; + private readonly IFailureMechanismPropertyChangeHandler propertyChangeHandler; /// /// Creates a new instance of . @@ -47,7 +48,7 @@ /// Thrown when any input parameter is null. public PipingFailureMechanismContextProperties( PipingFailureMechanismContext data, - IFailureMechanismPropertyChangeHandler handler) + IFailureMechanismPropertyChangeHandler handler) { if (data == null) { Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismContextPropertiesTest.cs =================================================================== diff -u -r5f8541d2a46730d67fc2d859caa6de2921bbc820 -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismContextPropertiesTest.cs (.../PipingFailureMechanismContextPropertiesTest.cs) (revision 5f8541d2a46730d67fc2d859caa6de2921bbc820) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismContextPropertiesTest.cs (.../PipingFailureMechanismContextPropertiesTest.cs) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -29,6 +29,7 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Piping.Data; @@ -45,7 +46,7 @@ { // Setup var mocks = new MockRepository(); - IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(mocks); + IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(mocks); mocks.ReplayAll(); // Call @@ -84,7 +85,7 @@ var mockRepository = new MockRepository(); IAssessmentSection assessmentSectionStub = mockRepository.Stub(); - IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(mockRepository); + IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(mockRepository); mockRepository.ReplayAll(); // Call @@ -127,7 +128,7 @@ var mockRepository = new MockRepository(); IAssessmentSection assessmentSectionStub = mockRepository.Stub(); - IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(mockRepository); + IFailureMechanismPropertyChangeHandler handler = CreateSimpleHandler(mockRepository); mockRepository.ReplayAll(); @@ -265,7 +266,7 @@ var assessmentSection = mocks.Stub(); var observerMock = mocks.StrictMock(); - var changeHandler = mocks.Stub(); + var changeHandler = mocks.Stub>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(true); mocks.ReplayAll(); @@ -306,7 +307,7 @@ var observableMock = mocks.StrictMock(); observableMock.Expect(o => o.NotifyObservers()); - var changeHandler = mocks.Stub(); + var changeHandler = mocks.Stub>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(true); changeHandler.Expect(h => h.PropertyChanged(failureMechanism)).Return(new [] { observableMock }); @@ -342,7 +343,7 @@ var mockRepository = new MockRepository(); var observerMock = mockRepository.StrictMock(); - var changeHandler = mockRepository.StrictMock(); + var changeHandler = mockRepository.StrictMock>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(false); var assessmentSection = mockRepository.Stub(); @@ -355,7 +356,7 @@ var properties = new PipingFailureMechanismContextProperties( new PipingFailureMechanismContext(failureMechanism, assessmentSection), changeHandler); - var oldValue = properties.A; + double oldValue = properties.A; // Call properties.A = value; @@ -379,7 +380,7 @@ var observerMock = mocks.StrictMock(); var assessmentSection = mocks.Stub(); - var changeHandler = mocks.Stub(); + var changeHandler = mocks.Stub>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(true); mocks.ReplayAll(); @@ -416,7 +417,7 @@ var observableMock = mocks.StrictMock(); observableMock.Expect(o => o.NotifyObservers()); - var handler = mocks.Stub(); + var handler = mocks.Stub>(); handler.Expect(h => h.ConfirmPropertyChange()).Return(true); handler.Expect(h => h.PropertyChanged(failureMechanism)).Return(new[] { observableMock }); @@ -452,7 +453,7 @@ var observerMock = mocks.StrictMock(); var assessmentSection = mocks.Stub(); - var changeHandler = mocks.StrictMock(); + var changeHandler = mocks.StrictMock>(); changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(false); mocks.ReplayAll(); @@ -464,7 +465,7 @@ new PipingFailureMechanismContext(failureMechanism, assessmentSection), changeHandler); - var oldValue = properties.WaterVolumetricWeight; + RoundedDouble oldValue = properties.WaterVolumetricWeight; // Call properties.WaterVolumetricWeight = (RoundedDouble) value; @@ -474,9 +475,9 @@ mocks.VerifyAll(); } - private IFailureMechanismPropertyChangeHandler CreateSimpleHandler(MockRepository mockRepository) + private IFailureMechanismPropertyChangeHandler CreateSimpleHandler(MockRepository mockRepository) { - var handler = mockRepository.Stub(); + var handler = mockRepository.Stub>(); handler.Stub(h => h.ConfirmPropertyChange()).Return(true); handler.Stub(h => h.PropertyChanged(Arg.Is.NotNull)).Return(Enumerable.Empty()); Index: Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Ringtoets.Revetment.Forms.csproj =================================================================== diff -u -rc48f16746209f799f93c6fc79a5202a9e3fd419f -r4d77063761342b4686ef4a56c47874558a53dec7 --- Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Ringtoets.Revetment.Forms.csproj (.../Ringtoets.Revetment.Forms.csproj) (revision c48f16746209f799f93c6fc79a5202a9e3fd419f) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.Forms/Ringtoets.Revetment.Forms.csproj (.../Ringtoets.Revetment.Forms.csproj) (revision 4d77063761342b4686ef4a56c47874558a53dec7) @@ -91,6 +91,7 @@ {D951D6DA-FE83-4920-9FDB-63BF96480B54} Ringtoets.Common.Service + False {87C2C553-C0BC-40BF-B1EA-B83BFF357F27}