Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IFailureMechanismPropertyChangeHandler.cs
===================================================================
diff -u -r9a001397536d9dcca5d009c8518478cdfcddbeca -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IFailureMechanismPropertyChangeHandler.cs (.../IFailureMechanismPropertyChangeHandler.cs) (revision 9a001397536d9dcca5d009c8518478cdfcddbeca)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/IFailureMechanismPropertyChangeHandler.cs (.../IFailureMechanismPropertyChangeHandler.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -9,21 +9,19 @@
/// Interface for an object that can properly handle data model changes due to a change of a
/// failure mechanism property.
///
-
public interface IFailureMechanismPropertyChangeHandler
{
///
- /// Checks to see if the replacement of the norm variable of the assessment section
- /// should occur or not.
+ /// Checks to see if the change of the failure mechanism property should occur or not.
///
/// true if the change should occur, false otherwise.
bool ConfirmPropertyChange();
///
- /// propagates the necessary changes to underlying data structure when a property has
+ /// Propagates the necessary changes to underlying data structure when a property has
/// been changed for a failure mechanism.
///
- /// The section to be updated.
+ /// The failure mechanism to be updated.
/// All objects that have been affected by the change.
/// Thrown when
/// is null.
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/FailureMechanismPropertyChangeHandlerTest.cs
===================================================================
diff -u -rbb80820ff4a4e09793da242cb7b36ca2bce59c32 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/FailureMechanismPropertyChangeHandlerTest.cs (.../FailureMechanismPropertyChangeHandlerTest.cs) (revision bb80820ff4a4e09793da242cb7b36ca2bce59c32)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/FailureMechanismPropertyChangeHandlerTest.cs (.../FailureMechanismPropertyChangeHandlerTest.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -93,8 +93,8 @@
}
[Test]
- [TestCaseSource("ChangeCompositionTestCases")]
- public void ChangeComposition_FailureMechanismWithDifferentCalculationCollections_ReturnsCalculationsWhichHadOutput(ChangeCompositionTestCase testCase)
+ [TestCaseSource("ChangePropertyTestCases")]
+ public void ChangeComposition_FailureMechanismWithDifferentCalculationCollections_ReturnsCalculationsWhichHadOutput(ChangePropertyTestCase testCase)
{
// Setup
var handler = new FailureMechanismPropertyChangeHandler();
@@ -107,9 +107,9 @@
CollectionAssert.AreEquivalent(testCase.ExpectedAffectedCalculations, result);
}
- public class ChangeCompositionTestCase
+ public class ChangePropertyTestCase
{
- public ChangeCompositionTestCase(ICollection calculations)
+ public ChangePropertyTestCase(ICollection calculations)
{
Calculations = calculations;
ExpectedAffectedCalculations = calculations.Where(c => c.HasOutput).ToArray();
@@ -119,48 +119,48 @@
public ICollection ExpectedAffectedCalculations { get; private set; }
}
- static IEnumerable ChangeCompositionTestCases()
+ static IEnumerable ChangePropertyTestCases()
{
yield return new TestCaseData(
- new ChangeCompositionTestCase(new[]
+ new ChangePropertyTestCase(new[]
{
CreateCalculationWithOutput()
})
).SetName("ChangeComposition Single calculation with output");
yield return new TestCaseData(
- new ChangeCompositionTestCase(new[]
+ new ChangePropertyTestCase(new[]
{
CreateCalculationWithoutOutput()
})
).SetName("ChangeComposition Single calculation without output");
yield return new TestCaseData(
- new ChangeCompositionTestCase(new[]
+ new ChangePropertyTestCase(new[]
{
CreateCalculationWithoutOutput(),
CreateCalculationWithoutOutput()
})
).SetName("ChangeComposition Two calculations without output");
yield return new TestCaseData(
- new ChangeCompositionTestCase(new[]
+ new ChangePropertyTestCase(new[]
{
CreateCalculationWithOutput(),
CreateCalculationWithoutOutput()
})
).SetName("ChangeComposition Calculation without and calculation with output");
yield return new TestCaseData(
- new ChangeCompositionTestCase(new[]
+ new ChangePropertyTestCase(new[]
{
CreateCalculationWithOutput(),
CreateCalculationWithOutput()
})
).SetName("ChangeComposition Two calculations with output");
yield return new TestCaseData(
- new ChangeCompositionTestCase(new[]
+ new ChangePropertyTestCase(new[]
{
CreateCalculationWithOutput(),
CreateCalculationWithOutput(),
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs
===================================================================
diff -u -r819a4413e76659295c4f62a5ccf204c19d2e7161 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs (.../GrassCoverErosionInwardsFailureMechanismContextProperties.cs) (revision 819a4413e76659295c4f62a5ccf204c19d2e7161)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextProperties.cs (.../GrassCoverErosionInwardsFailureMechanismContextProperties.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -85,13 +85,7 @@
if (propertyChangeHandler.ConfirmPropertyChange())
{
data.WrappedData.GeneralInput.N = value;
-
- var changedObjects = propertyChangeHandler.PropertyChanged(data.WrappedData);
- foreach (IObservable changedObject in changedObjects)
- {
- changedObject.NotifyObservers();
- }
- data.WrappedData.NotifyObservers();
+ ClearOutputAndNotifyObservers();
}
}
}
@@ -193,5 +187,15 @@
}
#endregion
+
+ private void ClearOutputAndNotifyObservers()
+ {
+ var changedObjects = propertyChangeHandler.PropertyChanged(data.WrappedData);
+ foreach (IObservable changedObject in changedObjects)
+ {
+ changedObject.NotifyObservers();
+ }
+ data.WrappedData.NotifyObservers();
+ }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs
===================================================================
diff -u -r819a4413e76659295c4f62a5ccf204c19d2e7161 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs) (revision 819a4413e76659295c4f62a5ccf204c19d2e7161)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/PropertyClasses/GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs (.../GrassCoverErosionInwardsFailureMechanismContextPropertiesTest.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -123,23 +123,32 @@
}
[Test]
- public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
+ [TestCase(1)]
+ [TestCase(10)]
+ [TestCase(20)]
+ public void LengthEffect_SetValidValue_UpdateDataAndNotifyObservers(int newLengthEffect)
{
// Setup
var observerMock = mockRepository.StrictMock();
- var handler = CreateSimpleHandler();
- int numberOfChangedProperties = 1;
- observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties);
+ observerMock.Expect(o => o.UpdateObserver());
+
+ var observableMock = mockRepository.StrictMock();
+ observableMock.Expect(o => o.NotifyObservers());
+
+ var changeHandler = mockRepository.StrictMock();
+ changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(true);
+ changeHandler.Expect(h => h.PropertyChanged(Arg.Matches(z => true))).Return(new[] { observableMock });
+
var assessmentSectionMock = mockRepository.StrictMock();
+
mockRepository.ReplayAll();
var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
failureMechanism.Attach(observerMock);
+
var properties = new GrassCoverErosionInwardsFailureMechanismContextProperties(
new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSectionMock),
- handler
- );
- const int newLengthEffect = 10;
+ changeHandler);
// Call
properties.LengthEffect = newLengthEffect;
@@ -150,6 +159,39 @@
}
[Test]
+ [TestCase(1)]
+ [TestCase(10)]
+ [TestCase(20)]
+ public void LengthEffect_SetValidValueNoConfirmation_NoValueChangeNoUpdates(int newLengthEffect)
+ {
+ // Setup
+ var observerMock = mockRepository.StrictMock();
+
+ var changeHandler = mockRepository.StrictMock();
+ changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(false);
+
+ var assessmentSectionMock = mockRepository.StrictMock();
+
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionInwardsFailureMechanism();
+
+ failureMechanism.Attach(observerMock);
+
+ var properties = new GrassCoverErosionInwardsFailureMechanismContextProperties(
+ new GrassCoverErosionInwardsFailureMechanismContext(failureMechanism, assessmentSectionMock),
+ changeHandler);
+ var oldValue = properties.LengthEffect;
+
+ // Call
+ properties.LengthEffect = newLengthEffect;
+
+ // Assert
+ Assert.AreEqual(oldValue, failureMechanism.GeneralInput.N);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
{
// Setup
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs (revision 0)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -0,0 +1,42 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Windows.Forms;
+using Core.Common.Base;
+using Ringtoets.Common.Forms;
+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
+ {
+ private readonly FailureMechanismPropertyChangeHandler failureMechanismPropertyChangeHandler = new FailureMechanismPropertyChangeHandler();
+
+ public bool ConfirmPropertyChange()
+ {
+ DialogResult result = MessageBox.Show(Resources.GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler_Confirm_change_composition_and_clear_dependent_data,
+ CoreCommonBaseResources.Confirm,
+ MessageBoxButtons.OKCancel);
+ return result == DialogResult.OK;
+ }
+
+ public IEnumerable PropertyChanged(GrassCoverErosionOutwardsFailureMechanism failureMechanism)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+
+ var affectedObjects = RingtoetsCommonDataSynchronizationService.ClearHydraulicBoundaryLocationOutput(
+ failureMechanism.HydraulicBoundaryLocations);
+ return affectedObjects.Concat(failureMechanismPropertyChangeHandler.PropertyChanged(failureMechanism));
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs (revision 0)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler.cs (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -0,0 +1,26 @@
+using System;
+using System.Collections.Generic;
+using Core.Common.Base;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+
+namespace Ringtoets.GrassCoverErosionOutwards.Forms
+{
+ public interface IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler
+ {
+ ///
+ /// Checks to see if the change of the failure mechanism property should occur or not.
+ ///
+ /// true if the change should occur, false otherwise.
+ bool ConfirmPropertyChange();
+
+ ///
+ /// Propagates the necessary changes to underlying data structure when a property has
+ /// been changed for a grass cover erosion outwards failure mechanism.
+ ///
+ /// The failure mechanism to be updated.
+ /// All objects that have been affected by the change.
+ /// Thrown when
+ /// is null.
+ IEnumerable PropertyChanged(GrassCoverErosionOutwardsFailureMechanism failureMechanism);
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r86b6ce2b77450d63016858e8e18796c02bdaad52 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 86b6ce2b77450d63016858e8e18796c02bdaad52)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -22,7 +22,7 @@
//------------------------------------------------------------------------------
//
// This code was generated by a tool.
-// Runtime Version:4.0.30319.17929
+// Runtime Version:4.0.30319.42000
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
@@ -110,6 +110,18 @@
}
///
+ /// Looks up a localized string similar to Als u een parameter in een toetsspoor wijzigt, zal de uitvoer van alle randvoorwaarden locaties en berekeningen in dit toetsspoor verwijderd worden.
+ ///
+ ///Weet u zeker dat u wilt doorgaan?.
+ ///
+ public static string GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler_Confirm_change_composition_and_clear_dependent_data {
+ get {
+ return ResourceManager.GetString("GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler_Confirm_change_com" +
+ "position_and_clear_dependent_data", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Is convergentie bereikt in de berekening van de waterstand bij doorsnede-eis?.
///
public static string GrassCoverErosionOutwardsHydraulicBoundaryLocation_Convergence_DesignWaterLevel_Description {
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Properties/Resources.resx
===================================================================
diff -u -r86b6ce2b77450d63016858e8e18796c02bdaad52 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 86b6ce2b77450d63016858e8e18796c02bdaad52)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -183,4 +183,9 @@
Golfhoogte bij doorsnede-eis
+
+ Als u een parameter in een toetsspoor wijzigt, zal de uitvoer van alle randvoorwaarden locaties en berekeningen in dit toetsspoor verwijderd worden.
+
+Weet u zeker dat u wilt doorgaan?
+
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties.cs
===================================================================
diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using System.Linq;
using Core.Common.Base;
@@ -37,6 +38,20 @@
///
public class GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties : ObjectProperties>
{
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The locations to show the properties for.
+ /// Thrown when is null.
+ public GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties(ObservableList locations)
+ {
+ if (locations == null)
+ {
+ throw new ArgumentNullException("locations");
+ }
+ Data = locations;
+ }
+
[TypeConverter(typeof(ExpandableArrayConverter))]
[ResourcesCategory(typeof(Resources), "Categories_General")]
[ResourcesDisplayName(typeof(Resources), "HydraulicBoundaryDatabase_Locations_DisplayName")]
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs
===================================================================
diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs (.../GrassCoverErosionOutwardsFailureMechanismProperties.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismProperties.cs (.../GrassCoverErosionOutwardsFailureMechanismProperties.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Core.Common.Base.Data;
using Core.Common.Gui.Attributes;
using Core.Common.Gui.PropertyBag;
@@ -39,7 +40,30 @@
public class GrassCoverErosionOutwardsFailureMechanismProperties : ObjectProperties
{
private static readonly ILog log = LogManager.GetLogger(typeof(GrassCoverErosionOutwardsFailureMechanismProperties));
+ private readonly IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler changeHandler;
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The failure mechanism to show the properties for.
+ /// Handler responsible for handling effects of a property change.
+ /// Thrown when is null.
+ public GrassCoverErosionOutwardsFailureMechanismProperties(
+ GrassCoverErosionOutwardsFailureMechanism failureMechanism,
+ IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler changeHandler)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+ if (changeHandler == null)
+ {
+ throw new ArgumentNullException("changeHandler");
+ }
+ Data = failureMechanism;
+ this.changeHandler = changeHandler;
+ }
+
#region Length effect parameters
[PropertyOrder(3)]
@@ -54,21 +78,16 @@
}
set
{
- data.GeneralInput.N = value;
- ClearHydraulicBoundaryLocationOutput();
- data.NotifyObservers();
+ if (changeHandler.ConfirmPropertyChange())
+ {
+ data.GeneralInput.N = value;
+ ClearOutputAndNotifyObservers();
+ }
}
}
#endregion
- private void ClearHydraulicBoundaryLocationOutput()
- {
- RingtoetsCommonDataSynchronizationService.ClearHydraulicBoundaryLocationOutput(data.HydraulicBoundaryLocations);
- data.HydraulicBoundaryLocations.NotifyObservers();
- log.Info(Resources.GrassCoverErosionOutwards_NormValueChanged_Waveheight_and_design_water_level_results_cleared);
- }
-
#region General
[PropertyOrder(1)]
@@ -136,5 +155,14 @@
}
#endregion
+
+ private void ClearOutputAndNotifyObservers()
+ {
+ foreach (var observable in changeHandler.PropertyChanged(data))
+ {
+ observable.NotifyObservers();
+ }
+ data.NotifyObservers();
+ }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveHeightLocationsContextProperties.cs
===================================================================
diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveHeightLocationsContextProperties.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextProperties.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/PropertyClasses/GrassCoverErosionOutwardsWaveHeightLocationsContextProperties.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextProperties.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using System.Linq;
using Core.Common.Base;
@@ -37,6 +38,20 @@
///
public class GrassCoverErosionOutwardsWaveHeightLocationsContextProperties : ObjectProperties>
{
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The locations to show the properties for.
+ /// Thrown when is null.
+ public GrassCoverErosionOutwardsWaveHeightLocationsContextProperties(ObservableList locations)
+ {
+ if (locations == null)
+ {
+ throw new ArgumentNullException("locations");
+ }
+ Data = locations;
+ }
+
[TypeConverter(typeof(ExpandableArrayConverter))]
[ResourcesCategory(typeof(Resources), "Categories_General")]
[ResourcesDisplayName(typeof(Resources), "HydraulicBoundaryDatabase_Locations_DisplayName")]
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj
===================================================================
diff -u -r23d1e296e2da4364fbfe346e68d582dfcf966bb0 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 23d1e296e2da4364fbfe346e68d582dfcf966bb0)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Ringtoets.GrassCoverErosionOutwards.Forms.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.csproj) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -45,7 +45,9 @@
Properties\GlobalAssembly.cs
+
+
Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs
===================================================================
diff -u -rbb80820ff4a4e09793da242cb7b36ca2bce59c32 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision bb80820ff4a4e09793da242cb7b36ca2bce59c32)
+++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Plugin/GrassCoverErosionOutwardsPlugin.cs (.../GrassCoverErosionOutwardsPlugin.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -71,24 +71,17 @@
{
yield return new PropertyInfo
{
- CreateInstance = context => new GrassCoverErosionOutwardsFailureMechanismProperties
- {
- Data = context.WrappedData
- }
+ CreateInstance = context => new GrassCoverErosionOutwardsFailureMechanismProperties(
+ context.WrappedData,
+ new GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler())
};
yield return new PropertyInfo
{
- CreateInstance = context => new GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties
- {
- Data = context.WrappedData
- }
+ CreateInstance = context => new GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties(context.WrappedData)
};
yield return new PropertyInfo
{
- CreateInstance = context => new GrassCoverErosionOutwardsWaveHeightLocationsContextProperties
- {
- Data = context.WrappedData
- }
+ CreateInstance = context => new GrassCoverErosionOutwardsWaveHeightLocationsContextProperties(context.WrappedData)
};
yield return new PropertyInfo();
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandlerTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandlerTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandlerTest.cs (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -0,0 +1,240 @@
+using System;
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base;
+using NUnit.Extensions.Forms;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.Data.TestUtil;
+using Ringtoets.Common.Forms.TestUtil;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.Revetment.Data;
+
+namespace Ringtoets.GrassCoverErosionOutwards.Forms.Test
+{
+ [TestFixture]
+ public class GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandlerTest : NUnitFormTest
+ {
+ [Test]
+ public void ConfirmPropertyChange_Always_ShowMessageBox()
+ {
+ // Setup
+ string title = "";
+ string message = "";
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var tester = new MessageBoxTester(wnd);
+ title = tester.Title;
+ message = tester.Text;
+
+ tester.ClickOk();
+ };
+
+ var handler = new GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler();
+
+ // Call
+ handler.ConfirmPropertyChange();
+
+ // Assert
+ Assert.AreEqual("Bevestigen", title);
+ string expectedMessage = "Als u een parameter in een toetsspoor wijzigt, zal de uitvoer van alle randvoorwaarden locaties en berekeningen in dit toetsspoor verwijderd worden." + Environment.NewLine +
+ Environment.NewLine +
+ "Weet u zeker dat u wilt doorgaan?";
+ Assert.AreEqual(expectedMessage, message);
+ }
+
+ [Test]
+ public void ConfirmPropertyChange_MessageBoxOk_ReturnTrue()
+ {
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var tester = new MessageBoxTester(wnd);
+ tester.ClickOk();
+ };
+
+ var handler = new GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler();
+
+ // Call
+ bool result = handler.ConfirmPropertyChange();
+
+ // Assert
+ Assert.IsTrue(result);
+ }
+
+ [Test]
+ public void ConfirmPropertyChange_MessageBoxCancel_ReturnFalse()
+ {
+ DialogBoxHandler = (name, wnd) =>
+ {
+ var tester = new MessageBoxTester(wnd);
+ tester.ClickCancel();
+ };
+
+ var handler = new GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler();
+
+ // Call
+ bool result = handler.ConfirmPropertyChange();
+
+ // Assert
+ Assert.IsFalse(result);
+ }
+
+ [Test]
+ public void ChangeComposition_WithoutFailureMechanism_ThrowsArgumentNullException()
+ {
+ // Setup
+ var handler = new GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler();
+
+ // Call
+ TestDelegate test = () => handler.PropertyChanged(null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("failureMechanism", paramName);
+ }
+
+ [Test]
+ [TestCaseSource("ChangePropertyTestCases")]
+ public void ChangeComposition_FailureMechanismWithDifferentCalculationCollections_ReturnsCalculationsWhichHadOutput(ChangePropertyTestCase testCase)
+ {
+ // Setup
+ var handler = new GrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler();
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+ foreach (var calculation in testCase.Calculations)
+ {
+ failureMechanism.WaveConditionsCalculationGroup.Children.Add(calculation);
+ }
+ failureMechanism.HydraulicBoundaryLocations.AddRange(testCase.Locations);
+
+ // Call
+ IEnumerable result = handler.PropertyChanged(failureMechanism);
+
+ // Assert
+ CollectionAssert.AreEquivalent(testCase.ExpectedAffectedCalculations.Concat(testCase.ExpectedAffectedLocations), result);
+ }
+
+ public class ChangePropertyTestCase
+ {
+ public ChangePropertyTestCase(ICollection locations, ICollection calculations)
+ {
+ Calculations = calculations;
+ ExpectedAffectedCalculations = calculations.Where(c => c.HasOutput).ToArray();
+ Locations = locations;
+ ExpectedAffectedLocations = locations.Where(c => c.DesignWaterLevelOutput != null || c.WaveHeightOutput != null).ToArray();
+ }
+
+ public ICollection Locations { get; private set; }
+ public ICollection ExpectedAffectedLocations { get; private set; }
+
+ public ICollection Calculations { get; private set; }
+
+ public ICollection ExpectedAffectedCalculations { get; private set; }
+ }
+
+ static IEnumerable ChangePropertyTestCases()
+ {
+ yield return new TestCaseData(
+ new ChangePropertyTestCase(new[]
+ {
+ CreateHydraulicBoundaryLocationWithoutOutput()
+ }, new[]
+ {
+ CreateCalculationWithOutput()
+ })
+ ).SetName("ChangeComposition Single location without output, calculation with output");
+
+ yield return new TestCaseData(
+ new ChangePropertyTestCase(new[]
+ {
+ CreateHydraulicBoundaryLocationWithOutput()
+ },
+ new[]
+ {
+ CreateCalculationWithoutOutput()
+ })
+ ).SetName("ChangeComposition Single location with output, single calculation without output");
+
+ yield return new TestCaseData(
+ new ChangePropertyTestCase(new[]
+ {
+ CreateHydraulicBoundaryLocationWithoutOutput(),
+ CreateHydraulicBoundaryLocationWithoutOutput()
+ },
+ new[]
+ {
+ CreateCalculationWithoutOutput(),
+ CreateCalculationWithoutOutput()
+ })
+ ).SetName("ChangeComposition Two locations without output, calculations without output");
+
+ yield return new TestCaseData(
+ new ChangePropertyTestCase(new[]
+ {
+ CreateHydraulicBoundaryLocationWithOutput(),
+ CreateHydraulicBoundaryLocationWithoutOutput()
+ },
+ new[]
+ {
+ CreateCalculationWithOutput(),
+ CreateCalculationWithoutOutput()
+ })
+ ).SetName("ChangeComposition Location with, location without, calculation without and calculation with output");
+
+ yield return new TestCaseData(
+ new ChangePropertyTestCase(new[]
+ {
+ CreateHydraulicBoundaryLocationWithOutput(),
+ CreateHydraulicBoundaryLocationWithOutput()
+ },
+ new[]
+ {
+ CreateCalculationWithOutput(),
+ CreateCalculationWithOutput()
+ })
+ ).SetName("ChangeComposition Two locations with output, two calculations with output");
+
+ yield return new TestCaseData(
+ new ChangePropertyTestCase(new[]
+ {
+ CreateHydraulicBoundaryLocationWithOutput(),
+ CreateHydraulicBoundaryLocationWithoutOutput(),
+ CreateHydraulicBoundaryLocationWithOutput()
+ },
+ new[]
+ {
+ CreateCalculationWithOutput(),
+ CreateCalculationWithOutput(),
+ CreateCalculationWithoutOutput()
+ })
+ ).SetName("ChangeComposition Two locations with, one location without, two calculations with and one calculation without output");
+ }
+
+ private static GrassCoverErosionOutwardsWaveConditionsCalculation CreateCalculationWithoutOutput()
+ {
+ return new GrassCoverErosionOutwardsWaveConditionsCalculation();
+ }
+
+ private static GrassCoverErosionOutwardsWaveConditionsCalculation CreateCalculationWithOutput()
+ {
+ return new GrassCoverErosionOutwardsWaveConditionsCalculation
+ {
+ Output = new GrassCoverErosionOutwardsWaveConditionsOutput(Enumerable.Empty())
+ };
+ }
+
+ private static TestHydraulicBoundaryLocation CreateHydraulicBoundaryLocationWithoutOutput()
+ {
+ return new TestHydraulicBoundaryLocation();
+ }
+
+ private static TestHydraulicBoundaryLocation CreateHydraulicBoundaryLocationWithOutput()
+ {
+ return new TestHydraulicBoundaryLocation
+ {
+ WaveHeightOutput = new TestHydraulicBoundaryLocationOutput(0.5),
+ DesignWaterLevelOutput = new TestHydraulicBoundaryLocationOutput(2.3)
+ };
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextPropertiesTest.cs
===================================================================
diff -u -rcfca0be21e050ae7ed7626ef4e3b1472eecc69a1 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextPropertiesTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextPropertiesTest.cs) (revision cfca0be21e050ae7ed7626ef4e3b1472eecc69a1)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsDesignWaterLevelLocationsContextPropertiesTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsContextPropertiesTest.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -19,6 +19,7 @@
// 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.Gui.Converters;
@@ -35,50 +36,30 @@
public class GrassCoverErosionOutwardsDesignWaterLevelLocationsContextPropertiesTest
{
[Test]
- public void DefaultConstructor_ExpectedValues()
+ public void Constructor_WithoutLocations_ExpectedValues()
{
// Call
- var properties = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties();
+ TestDelegate test = () => new GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties(null);
// Assert
- Assert.IsInstanceOf>>(properties);
- Assert.IsNull(properties.Data);
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("locations", paramName);
}
[Test]
- public void GetProperties_WithData_ReturnExpectedValues()
+ public void Constructor_WithLocations_ExpectedValues()
{
// Setup
- HydraulicBoundaryLocation location = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(1.2);
+ var hydraulicBoundaryLocations = new ObservableList();
// Call
- var properties = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties
- {
- Data = new ObservableList
- {
- location
- }
- };
+ var properties = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties(
+ hydraulicBoundaryLocations);
// Assert
- Assert.AreEqual(1, properties.Locations.Length);
- Assert.IsTrue(TypeUtils.HasTypeConverter(p => p.Locations));
- GrassCoverErosionOutwardsDesignWaterLevelLocationContextProperties locationProperties = properties.Locations[0];
- Assert.AreEqual(location.Name, locationProperties.Name);
- Assert.AreEqual(location.Id, locationProperties.Id);
- Assert.AreEqual(location.Location, locationProperties.Location);
- Assert.AreEqual(location.DesignWaterLevel, locationProperties.DesignWaterLevel, location.DesignWaterLevel.GetAccuracy());
- Assert.AreEqual("Ja", locationProperties.Convergence);
- }
+ Assert.IsInstanceOf>>(properties);
+ Assert.AreSame(hydraulicBoundaryLocations, properties.Data);
- [Test]
- public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
- {
- // Call
- var properties = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties();
-
- // Assert
var dynamicPropertyBag = new DynamicPropertyBag(properties);
const string expectedLocationsDisplayName = "Locaties";
const string expectedLocationsDescription = "Locaties uit de hydraulische randvoorwaardendatabase.";
@@ -97,5 +78,30 @@
Assert.AreEqual(expectedLocationsDescription, locationsProperty.Description);
Assert.AreEqual(expectedLocationsCategory, locationsProperty.Category);
}
+
+ [Test]
+ public void GetProperties_WithData_ReturnExpectedValues()
+ {
+ // Setup
+ HydraulicBoundaryLocation location = TestHydraulicBoundaryLocation.CreateDesignWaterLevelCalculated(1.2);
+
+ // Call
+ var properties = new GrassCoverErosionOutwardsDesignWaterLevelLocationsContextProperties(
+ new ObservableList
+ {
+ location
+ });
+
+ // Assert
+ Assert.AreEqual(1, properties.Locations.Length);
+ Assert.IsTrue(TypeUtils.HasTypeConverter(p => p.Locations));
+ GrassCoverErosionOutwardsDesignWaterLevelLocationContextProperties locationProperties = properties.Locations[0];
+ Assert.AreEqual(location.Name, locationProperties.Name);
+ Assert.AreEqual(location.Id, locationProperties.Id);
+ Assert.AreEqual(location.Location, locationProperties.Location);
+ Assert.AreEqual(location.DesignWaterLevel, locationProperties.DesignWaterLevel, location.DesignWaterLevel.GetAccuracy());
+ Assert.AreEqual("Ja", locationProperties.Convergence);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs
===================================================================
diff -u -rcfca0be21e050ae7ed7626ef4e3b1472eecc69a1 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (.../GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs) (revision cfca0be21e050ae7ed7626ef4e3b1472eecc69a1)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs (.../GrassCoverErosionOutwardsFailureMechanismPropertiesTest.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -21,6 +21,7 @@
using System;
using System.ComponentModel;
+using System.Linq;
using Core.Common.Base;
using Core.Common.Gui.PropertyBag;
using Core.Common.TestUtil;
@@ -45,27 +46,48 @@
private const int cPropertyIndex = 5;
[Test]
- public void Constructor_ExpectedValues()
+ public void Constructor_WithoutFailureMechanism_ThrowsArgumentNullException()
{
+ // Setup
+ var mockRepository = new MockRepository();
+ var changeHandler = CreateSimpleHandler(mockRepository);
+ mockRepository.ReplayAll();
+
// Call
- var properties = new GrassCoverErosionOutwardsFailureMechanismProperties();
+ TestDelegate test = () => new GrassCoverErosionOutwardsFailureMechanismProperties(null, changeHandler);
// Assert
- Assert.IsInstanceOf>(properties);
- Assert.IsNull(properties.Data);
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("failureMechanism", paramName);
}
[Test]
- public void Data_SetNewFailureMechanismContextInstance_ReturnCorrectPropertyValues()
+ public void Constructor_WithoutChangeHandler_ThrowsArgumentNullException()
{
+ // Call
+ TestDelegate test = () => new GrassCoverErosionOutwardsFailureMechanismProperties(new GrassCoverErosionOutwardsFailureMechanism(), null);
+
+ // Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("changeHandler", paramName);
+ }
+
+ [Test]
+ public void Constructor_WithFailureMechanism_ExpectedValues()
+ {
// Setup
- var properties = new GrassCoverErosionOutwardsFailureMechanismProperties();
+ var mockRepository = new MockRepository();
+ var changeHandler = CreateSimpleHandler(mockRepository);
+ mockRepository.ReplayAll();
+
var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
// Call
- properties.Data = failureMechanism;
+ var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism, changeHandler);
// Assert
+ Assert.IsInstanceOf>(properties);
+ Assert.AreSame(failureMechanism, properties.Data);
Assert.AreEqual(Resources.GrassCoverErosionOutwardsFailureMechanism_DisplayName, properties.Name);
Assert.AreEqual(Resources.GrassCoverErosionOutwardsFailureMechanism_Code, properties.Code);
Assert.AreEqual(failureMechanism.GeneralInput.GeneralWaveConditionsInput.A, properties.A);
@@ -75,23 +97,30 @@
}
[Test]
- public void SetProperties_IndividualProperties_UpdateDataAndNotifyObservers()
+ [TestCase(1)]
+ [TestCase(10)]
+ [TestCase(20)]
+ public void LengthEffect_SetValidValue_UpdateDataAndNotifyObservers(int newLengthEffect)
{
// Setup
var mockRepository = new MockRepository();
var observerMock = mockRepository.StrictMock();
- int numberOfChangedProperties = 1;
- observerMock.Expect(o => o.UpdateObserver()).Repeat.Times(numberOfChangedProperties);
+ observerMock.Expect(o => o.UpdateObserver());
+
+ var observableMock = mockRepository.StrictMock();
+ observableMock.Expect(o => o.NotifyObservers());
+
+ var changeHandler = mockRepository.StrictMock();
+ changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(true);
+ changeHandler.Expect(h => h.PropertyChanged(Arg.Matches(z => true))).Return(new[] { observableMock });
+
mockRepository.ReplayAll();
var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
failureMechanism.Attach(observerMock);
- var properties = new GrassCoverErosionOutwardsFailureMechanismProperties
- {
- Data = failureMechanism
- };
- const int newLengthEffect = 10;
+ var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism, changeHandler);
+
// Call
properties.LengthEffect = newLengthEffect;
@@ -101,13 +130,46 @@
}
[Test]
+ [TestCase(1)]
+ [TestCase(10)]
+ [TestCase(20)]
+ public void LengthEffect_SetValidValueNoConfirmation_NoValueChangeNoUpdates(int newLengthEffect)
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var observerMock = mockRepository.StrictMock();
+
+ var changeHandler = mockRepository.StrictMock();
+ changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(false);
+
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism();
+ failureMechanism.Attach(observerMock);
+
+ var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(failureMechanism, changeHandler);
+ var oldValue = properties.LengthEffect;
+
+ // Call
+ properties.LengthEffect = newLengthEffect;
+
+ // Assert
+ Assert.AreEqual(oldValue, failureMechanism.GeneralInput.N);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
{
+ // Setup
+ var mockRepository = new MockRepository();
+ var changeHandler = CreateSimpleHandler(mockRepository);
+ mockRepository.ReplayAll();
+
// Call
- var properties = new GrassCoverErosionOutwardsFailureMechanismProperties
- {
- Data = new GrassCoverErosionOutwardsFailureMechanism()
- };
+ var properties = new GrassCoverErosionOutwardsFailureMechanismProperties(
+ new GrassCoverErosionOutwardsFailureMechanism(),
+ changeHandler);
// Assert
var dynamicPropertyBag = new DynamicPropertyBag(properties);
@@ -158,50 +220,16 @@
Assert.AreEqual("Modelinstellingen", cProperty.Category);
Assert.AreEqual("c", cProperty.DisplayName);
Assert.AreEqual("De waarde van de parameter 'c' in de berekening voor golf condities.", cProperty.Description);
+ mockRepository.VerifyAll();
}
-
- [Test]
- [TestCase(1)]
- [TestCase(10)]
- [TestCase(20)]
- public void LengthEffect_NewValueSet_ClearHydraulicBoundaryLocationsNotifyObserversAndLog(int value)
+
+ private IGrassCoverErosionOutwardsFailureMechanismPropertyChangeHandler CreateSimpleHandler(MockRepository mockRepository)
{
- // Setup
- var mockRepository = new MockRepository();
- var observerMock = mockRepository.StrictMock();
- observerMock.Expect(o => o.UpdateObserver());
- mockRepository.ReplayAll();
+ var handler = mockRepository.Stub();
+ handler.Stub(h => h.ConfirmPropertyChange()).Return(true);
+ handler.Stub(h => h.PropertyChanged(Arg.Matches(z => true))).Return(Enumerable.Empty());
- var hydraulicLocation = TestHydraulicBoundaryLocation.CreateFullyCalculated();
-
- var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism
- {
- HydraulicBoundaryLocations =
- {
- hydraulicLocation
- }
- };
-
- failureMechanism.HydraulicBoundaryLocations.Attach(observerMock);
-
- var properties = new GrassCoverErosionOutwardsFailureMechanismProperties
- {
- Data = failureMechanism
- };
-
- // Call
- Action action = () => properties.LengthEffect = value;
-
- // Assert
- const string expectedMessage = "De berekende waterstanden en golfhoogtes bij doorsnede-eis voor alle hydraulische randvoorwaarden locaties zijn verwijderd.";
- TestHelper.AssertLogMessageIsGenerated(action, expectedMessage);
- Assert.AreEqual(value, properties.LengthEffect);
- Assert.AreEqual(value, failureMechanism.GeneralInput.N);
- Assert.IsNaN(hydraulicLocation.DesignWaterLevel);
- Assert.IsNaN(hydraulicLocation.WaveHeight);
- Assert.AreEqual(CalculationConvergence.NotCalculated, hydraulicLocation.DesignWaterLevelCalculationConvergence);
- Assert.AreEqual(CalculationConvergence.NotCalculated, hydraulicLocation.WaveHeightCalculationConvergence);
- mockRepository.VerifyAll();
+ return handler;
}
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveHeightLocationsContextPropertiesTest.cs
===================================================================
diff -u -rcfca0be21e050ae7ed7626ef4e3b1472eecc69a1 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveHeightLocationsContextPropertiesTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextPropertiesTest.cs) (revision cfca0be21e050ae7ed7626ef4e3b1472eecc69a1)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsWaveHeightLocationsContextPropertiesTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsContextPropertiesTest.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using System.Linq;
using Core.Common.Base;
@@ -36,50 +37,29 @@
public class GrassCoverErosionOutwardsWaveHeightLocationsContextPropertiesTest
{
[Test]
- public void DefaultConstructor_ExpectedValues()
+ public void Constructor_WithoutLocations_ExpectedValues()
{
// Call
- var properties = new GrassCoverErosionOutwardsWaveHeightLocationsContextProperties();
+ TestDelegate test = () => new GrassCoverErosionOutwardsWaveHeightLocationsContextProperties(null);
// Assert
- Assert.IsInstanceOf>>(properties);
- Assert.IsNull(properties.Data);
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("locations", paramName);
}
[Test]
- public void GetProperties_WithData_ReturnExpectedValues()
+ public void Constructor_WithLocations_ExpectedValues()
{
// Setup
- HydraulicBoundaryLocation location = TestHydraulicBoundaryLocation.CreateWaveHeightCalculated(1.2);
+ var hydraulicBoundaryLocations = new ObservableList();
// Call
- var properties = new GrassCoverErosionOutwardsWaveHeightLocationsContextProperties
- {
- Data = new ObservableList
- {
- location
- }
- };
+ var properties = new GrassCoverErosionOutwardsWaveHeightLocationsContextProperties(
+ hydraulicBoundaryLocations);
// Assert
- Assert.AreEqual(1, properties.Locations.Length);
- Assert.IsTrue(TypeUtils.HasTypeConverter(p => p.Locations));
- GrassCoverErosionOutwardsWaveHeightLocationContextProperties locationProperties = properties.Locations.First();
- Assert.AreEqual(location.Name, locationProperties.Name);
- Assert.AreEqual(location.Id, locationProperties.Id);
- Assert.AreEqual(location.Location, locationProperties.Location);
- Assert.AreEqual(location.WaveHeight, locationProperties.WaveHeight, location.WaveHeight.GetAccuracy());
- Assert.AreEqual("Ja", locationProperties.Convergence);
- }
-
- [Test]
- public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
- {
- // Call
- var properties = new GrassCoverErosionOutwardsWaveHeightLocationsContextProperties();
-
- // Assert
+ Assert.IsInstanceOf>>(properties);
+ Assert.AreSame(hydraulicBoundaryLocations, properties.Data);
var dynamicPropertyBag = new DynamicPropertyBag(properties);
const string expectedLocationsDisplayName = "Locaties";
const string expectedLocationsDescription = "Locaties uit de hydraulische randvoorwaardendatabase.";
@@ -98,5 +78,30 @@
Assert.AreEqual(expectedLocationsDescription, locationsProperty.Description);
Assert.AreEqual(expectedLocationsCategory, locationsProperty.Category);
}
+
+ [Test]
+ public void GetProperties_WithData_ReturnExpectedValues()
+ {
+ // Setup
+ HydraulicBoundaryLocation location = TestHydraulicBoundaryLocation.CreateWaveHeightCalculated(1.2);
+
+ // Call
+ var properties = new GrassCoverErosionOutwardsWaveHeightLocationsContextProperties(
+ new ObservableList
+ {
+ location
+ });
+
+ // Assert
+ Assert.AreEqual(1, properties.Locations.Length);
+ Assert.IsTrue(TypeUtils.HasTypeConverter(p => p.Locations));
+ GrassCoverErosionOutwardsWaveHeightLocationContextProperties locationProperties = properties.Locations.First();
+ Assert.AreEqual(location.Name, locationProperties.Name);
+ Assert.AreEqual(location.Id, locationProperties.Id);
+ Assert.AreEqual(location.Location, locationProperties.Location);
+ Assert.AreEqual(location.WaveHeight, locationProperties.WaveHeight, location.WaveHeight.GetAccuracy());
+ Assert.AreEqual("Ja", locationProperties.Convergence);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj
===================================================================
diff -u -r586d097de0087256cb5cf3dda3a3c612721fee9c -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 586d097de0087256cb5cf3dda3a3c612721fee9c)
+++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj (.../Ringtoets.GrassCoverErosionOutwards.Forms.Test.csproj) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -65,6 +65,7 @@
+
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/DesignWaterLevelLocationsContextProperties.cs
===================================================================
diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/DesignWaterLevelLocationsContextProperties.cs (.../DesignWaterLevelLocationsContextProperties.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/DesignWaterLevelLocationsContextProperties.cs (.../DesignWaterLevelLocationsContextProperties.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using System.Linq;
using Core.Common.Gui.Converters;
@@ -36,6 +37,20 @@
///
public class DesignWaterLevelLocationsContextProperties : ObjectProperties
{
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The database to set as data.
+ /// Thrown when is null.
+ public DesignWaterLevelLocationsContextProperties(HydraulicBoundaryDatabase database)
+ {
+ if (database == null)
+ {
+ throw new ArgumentNullException("database");
+ }
+ Data = database;
+ }
+
[TypeConverter(typeof(ExpandableArrayConverter))]
[ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")]
[ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "HydraulicBoundaryDatabase_Locations_DisplayName")]
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismContributionProperties.cs
===================================================================
diff -u -r1b04d8b730017db5c2a205203432f0b13f8d4192 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismContributionProperties.cs (.../FailureMechanismContributionProperties.cs) (revision 1b04d8b730017db5c2a205203432f0b13f8d4192)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/FailureMechanismContributionProperties.cs (.../FailureMechanismContributionProperties.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -50,6 +50,7 @@
/// The assessment section for which the properties are shown.
/// The for when the norm changes.
/// The for when the composition changes.
+ /// Thrown when any parameter is null.
public FailureMechanismContributionProperties(
FailureMechanismContribution failureMechanismContribution,
IAssessmentSection assessmentSection,
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/IFailureMechanismContributionNormChangeHandler.cs
===================================================================
diff -u -r9a001397536d9dcca5d009c8518478cdfcddbeca -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/IFailureMechanismContributionNormChangeHandler.cs (.../IFailureMechanismContributionNormChangeHandler.cs) (revision 9a001397536d9dcca5d009c8518478cdfcddbeca)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/IFailureMechanismContributionNormChangeHandler.cs (.../IFailureMechanismContributionNormChangeHandler.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -23,6 +23,7 @@
using System.Collections.Generic;
using Core.Common.Base;
using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.Data.Contribution;
namespace Ringtoets.Integration.Forms.PropertyClasses
{
Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/WaveHeightLocationsContextProperties.cs
===================================================================
diff -u -re182f6f394aa75e739467a77e7bcacd9a8b25429 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/WaveHeightLocationsContextProperties.cs (.../WaveHeightLocationsContextProperties.cs) (revision e182f6f394aa75e739467a77e7bcacd9a8b25429)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/PropertyClasses/WaveHeightLocationsContextProperties.cs (.../WaveHeightLocationsContextProperties.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using System.Linq;
using Core.Common.Gui.Converters;
@@ -36,6 +37,20 @@
///
public class WaveHeightLocationsContextProperties : ObjectProperties
{
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The database to set as data.
+ /// Thrown when is null.
+ public WaveHeightLocationsContextProperties(HydraulicBoundaryDatabase database)
+ {
+ if (database == null)
+ {
+ throw new ArgumentNullException("database");
+ }
+ Data = database;
+ }
+
[TypeConverter(typeof(ExpandableArrayConverter))]
[ResourcesCategory(typeof(RingtoetsCommonFormsResources), "Categories_General")]
[ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), "HydraulicBoundaryDatabase_Locations_DisplayName")]
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs
===================================================================
diff -u -rce9e1d476f00cfb42ce2a8ab6c762baf5abfd97b -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision ce9e1d476f00cfb42ce2a8ab6c762baf5abfd97b)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsPlugin.cs (.../RingtoetsPlugin.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -287,18 +287,14 @@
yield return new PropertyInfo();
yield return new PropertyInfo
{
- CreateInstance = context => new DesignWaterLevelLocationsContextProperties
- {
- Data = context.WrappedData.HydraulicBoundaryDatabase
- }
+ CreateInstance = context => new DesignWaterLevelLocationsContextProperties(
+ context.WrappedData.HydraulicBoundaryDatabase)
};
yield return new PropertyInfo();
yield return new PropertyInfo
{
- CreateInstance = context => new WaveHeightLocationsContextProperties
- {
- Data = context.WrappedData.HydraulicBoundaryDatabase
- }
+ CreateInstance = context => new WaveHeightLocationsContextProperties(
+ context.WrappedData.HydraulicBoundaryDatabase)
};
yield return new PropertyInfo();
yield return new PropertyInfo();
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationsContextPropertiesTest.cs
===================================================================
diff -u -re1d4d3fe987bfa6504703952ea0dbd8a18f5a698 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationsContextPropertiesTest.cs (.../DesignWaterLevelLocationsContextPropertiesTest.cs) (revision e1d4d3fe987bfa6504703952ea0dbd8a18f5a698)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/DesignWaterLevelLocationsContextPropertiesTest.cs (.../DesignWaterLevelLocationsContextPropertiesTest.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using System.Linq;
using Core.Common.Gui.Converters;
@@ -35,14 +36,27 @@
public class DesignWaterLevelLocationsContextPropertiesTest
{
[Test]
- public void DefaultConstructor_ExpectedValues()
+ public void Constructor_WithoutDatabase_ExpectedValues()
{
// Call
- var properties = new DesignWaterLevelLocationsContextProperties();
+ TestDelegate test = () => new DesignWaterLevelLocationsContextProperties(null);
// Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("database", paramName);
+ }
+ [Test]
+ public void Constructor_WithDatabase_ExpectedValues()
+ {
+ // Setup
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+
+ // Call
+ var properties = new DesignWaterLevelLocationsContextProperties(hydraulicBoundaryDatabase);
+
+ // Assert
Assert.IsInstanceOf>(properties);
- Assert.IsNull(properties.Data);
+ Assert.AreSame(hydraulicBoundaryDatabase, properties.Data);
}
[Test]
@@ -59,10 +73,7 @@
};
// Call
- DesignWaterLevelLocationsContextProperties properties = new DesignWaterLevelLocationsContextProperties
- {
- Data = hydraulicBoundaryDatabase
- };
+ var properties = new DesignWaterLevelLocationsContextProperties(hydraulicBoundaryDatabase);
// Assert
CollectionAssert.AllItemsAreInstancesOfType(properties.Locations, typeof(DesignWaterLevelLocationContextProperties));
@@ -81,7 +92,7 @@
public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
{
// Call
- var properties = new DesignWaterLevelLocationsContextProperties();
+ var properties = new DesignWaterLevelLocationsContextProperties(new HydraulicBoundaryDatabase());
// Assert
var dynamicPropertyBag = new DynamicPropertyBag(properties);
Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/WaveHeightLocationsContextPropertiesTest.cs
===================================================================
diff -u -re1d4d3fe987bfa6504703952ea0dbd8a18f5a698 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/WaveHeightLocationsContextPropertiesTest.cs (.../WaveHeightLocationsContextPropertiesTest.cs) (revision e1d4d3fe987bfa6504703952ea0dbd8a18f5a698)
+++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/WaveHeightLocationsContextPropertiesTest.cs (.../WaveHeightLocationsContextPropertiesTest.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using System.ComponentModel;
using System.Linq;
using Core.Common.Gui.Converters;
@@ -35,14 +36,27 @@
public class WaveHeightLocationsContextPropertiesTest
{
[Test]
- public void DefaultConstructor_ExpectedValues()
+ public void Constructor_WithoutDatabase_ExpectedValues()
{
// Call
- var properties = new WaveHeightLocationsContextProperties();
+ TestDelegate test = () => new WaveHeightLocationsContextProperties(null);
// Assert
+ var paramName = Assert.Throws(test).ParamName;
+ Assert.AreEqual("database", paramName);
+ }
+ [Test]
+ public void Constructor_WithDatabase_ExpectedValues()
+ {
+ // Setup
+ var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase();
+
+ // Call
+ var properties = new WaveHeightLocationsContextProperties(hydraulicBoundaryDatabase);
+
+ // Assert
Assert.IsInstanceOf>(properties);
- Assert.IsNull(properties.Data);
+ Assert.AreSame(hydraulicBoundaryDatabase, properties.Data);
}
[Test]
@@ -59,10 +73,7 @@
};
// Call
- var properties = new WaveHeightLocationsContextProperties
- {
- Data = hydraulicBoundaryDatabase
- };
+ var properties = new WaveHeightLocationsContextProperties(hydraulicBoundaryDatabase);
// Assert
CollectionAssert.AllItemsAreInstancesOfType(properties.Locations, typeof(WaveHeightLocationContextProperties));
@@ -81,7 +92,7 @@
public void Constructor_Always_PropertiesHaveExpectedAttributesValues()
{
// Call
- var properties = new WaveHeightLocationsContextProperties();
+ var properties = new WaveHeightLocationsContextProperties(new HydraulicBoundaryDatabase());
// Assert
var dynamicPropertyBag = new DynamicPropertyBag(properties);
Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs
===================================================================
diff -u -r819a4413e76659295c4f62a5ccf204c19d2e7161 -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs (.../PipingFailureMechanismContextProperties.cs) (revision 819a4413e76659295c4f62a5ccf204c19d2e7161)
+++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingFailureMechanismContextProperties.cs (.../PipingFailureMechanismContextProperties.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using Core.Common.Base;
using Core.Common.Base.Data;
using Core.Common.Gui.Attributes;
@@ -118,7 +119,7 @@
if (propertyChangeHandler.ConfirmPropertyChange())
{
data.WrappedData.GeneralInput.WaterVolumetricWeight = value;
- OnPropertyChanged();
+ ClearOutputAndNotifyObservers();
}
}
}
@@ -170,7 +171,7 @@
if (propertyChangeHandler.ConfirmPropertyChange())
{
data.WrappedData.PipingProbabilityAssessmentInput.A = value;
- OnPropertyChanged();
+ ClearOutputAndNotifyObservers();
}
}
}
@@ -277,10 +278,9 @@
#endregion
- private void OnPropertyChanged()
+ private void ClearOutputAndNotifyObservers()
{
- var changedObjects = propertyChangeHandler.PropertyChanged(data.WrappedData);
- foreach (IObservable changedObject in changedObjects)
+ foreach (IObservable changedObject in propertyChangeHandler.PropertyChanged(data.WrappedData))
{
changedObject.NotifyObservers();
}
Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismContextPropertiesTest.cs
===================================================================
diff -u -rf423289729b381361eed8bb5eacc7596a710d78a -r816744aa249d90e7460b9c2844292b2e0cf13669
--- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismContextPropertiesTest.cs (.../PipingFailureMechanismContextPropertiesTest.cs) (revision f423289729b381361eed8bb5eacc7596a710d78a)
+++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingFailureMechanismContextPropertiesTest.cs (.../PipingFailureMechanismContextPropertiesTest.cs) (revision 816744aa249d90e7460b9c2844292b2e0cf13669)
@@ -295,14 +295,24 @@
var observerMock = mocks.StrictMock();
observerMock.Expect(o => o.UpdateObserver());
- var failureMechanism = new PipingFailureMechanism();
- var properties = new PipingFailureMechanismContextProperties(
- new PipingFailureMechanismContext(failureMechanism, mocks.Stub()),
- CreateSimpleHandler(mocks));
+ var observableMock = mocks.StrictMock();
+ observableMock.Expect(o => o.NotifyObservers());
+
+ var handler = mocks.Stub();
+ handler.Expect(h => h.ConfirmPropertyChange()).Return(true);
+ handler.Expect(h => h.PropertyChanged(Arg.Matches(z => true))).Return(new [] { observableMock });
+
+ var assessmentSection = mocks.Stub();
+
mocks.ReplayAll();
+ var failureMechanism = new PipingFailureMechanism();
failureMechanism.Attach(observerMock);
+ var properties = new PipingFailureMechanismContextProperties(
+ new PipingFailureMechanismContext(failureMechanism, assessmentSection),
+ handler);
+
// Call
properties.A = value;
@@ -312,6 +322,39 @@
}
[Test]
+ [TestCase(1)]
+ [TestCase(10)]
+ [TestCase(20)]
+ public void A_SetValidValueNoConfirmation_NoValueChangeNoUpdates(int newLengthEffect)
+ {
+ // Setup
+ var mockRepository = new MockRepository();
+ var observerMock = mockRepository.StrictMock();
+
+ var changeHandler = mockRepository.StrictMock();
+ changeHandler.Expect(h => h.ConfirmPropertyChange()).Return(false);
+
+ var assessmentSection = mockRepository.Stub();
+
+ mockRepository.ReplayAll();
+
+ var failureMechanism = new PipingFailureMechanism();
+ failureMechanism.Attach(observerMock);
+
+ var properties = new PipingFailureMechanismContextProperties(
+ new PipingFailureMechanismContext(failureMechanism, assessmentSection),
+ changeHandler);
+ var oldValue = properties.A;
+
+ // Call
+ properties.A = newLengthEffect;
+
+ // Assert
+ Assert.AreEqual(oldValue, failureMechanism.PipingProbabilityAssessmentInput.A);
+ mockRepository.VerifyAll();
+ }
+
+ [Test]
[TestCase(5)]
[TestCase(-0.004)]
[TestCase(20.004)]