Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs
===================================================================
diff -u -r09667b4737dfec082af4a6190f79996062eb6654 -r14504cbfd9e1f22ae5cc264f31bf6d85acc0bd12
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 09667b4737dfec082af4a6190f79996062eb6654)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 14504cbfd9e1f22ae5cc264f31bf6d85acc0bd12)
@@ -1878,6 +1878,42 @@
}
///
+ /// Looks up a localized string similar to Linker grens voor bepaling intredepunt van het glijvlak..
+ ///
+ public static string ZoneBoundaryLeft_Description {
+ get {
+ return ResourceManager.GetString("ZoneBoundaryLeft_Description", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Zoneringsgrens links.
+ ///
+ public static string ZoneBoundaryLeft_DisplayName {
+ get {
+ return ResourceManager.GetString("ZoneBoundaryLeft_DisplayName", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Rechter grens voor bepaling intredepunt van het glijvlak..
+ ///
+ public static string ZoneBoundaryRight_Description {
+ get {
+ return ResourceManager.GetString("ZoneBoundaryRight_Description", resourceCulture);
+ }
+ }
+
+ ///
+ /// Looks up a localized string similar to Zoneringsgrens rechts.
+ ///
+ public static string ZoneBoundaryRight_DisplayName {
+ get {
+ return ResourceManager.GetString("ZoneBoundaryRight_DisplayName", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Zoneringsgrenzen automatisch bepalen of handmatig invoeren?.
///
public static string ZoningBoundariesDeterminationType_Description {
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx
===================================================================
diff -u -r09667b4737dfec082af4a6190f79996062eb6654 -r14504cbfd9e1f22ae5cc264f31bf6d85acc0bd12
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 09667b4737dfec082af4a6190f79996062eb6654)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 14504cbfd9e1f22ae5cc264f31bf6d85acc0bd12)
@@ -724,4 +724,16 @@
Lamellen
+
+ Linker grens voor bepaling intredepunt van het glijvlak.
+
+
+ Zoneringsgrens links
+
+
+ Rechter grens voor bepaling intredepunt van het glijvlak.
+
+
+ Zoneringsgrens rechts
+
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsProperties.cs
===================================================================
diff -u -r774ce2424ba4ccab70c6dad6198472977e2a8ace -r14504cbfd9e1f22ae5cc264f31bf6d85acc0bd12
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsProperties.cs (.../MacroStabilityInwardsSlipPlaneSettingsProperties.cs) (revision 774ce2424ba4ccab70c6dad6198472977e2a8ace)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsProperties.cs (.../MacroStabilityInwardsSlipPlaneSettingsProperties.cs) (revision 14504cbfd9e1f22ae5cc264f31bf6d85acc0bd12)
@@ -21,6 +21,7 @@
using System;
using System.ComponentModel;
+using Core.Common.Base.Data;
using Core.Common.Gui.Attributes;
using Core.Common.Gui.PropertyBag;
using Core.Common.Utils;
@@ -40,6 +41,8 @@
{
private const int createZonesPropertyIndex = 1;
private const int zoningBoundariesDeterminationTypePropertyIndex = 2;
+ private const int zoneBoundaryLeftPropertyIndex = 3;
+ private const int zoneBoundaryRightPropertyIndex = 4;
private readonly IObservablePropertyChangeHandler propertyChangeHandler;
@@ -80,6 +83,7 @@
}
}
+ [DynamicReadOnly]
[PropertyOrder(zoningBoundariesDeterminationTypePropertyIndex)]
[ResourcesCategory(typeof(Resources), nameof(Resources.SlipPlaneSettings_DisplayName))]
[ResourcesDisplayName(typeof(Resources), nameof(Resources.ZoningBoundariesDeterminationType_DisplayName))]
@@ -91,8 +95,62 @@
{
return data.ZoningBoundariesDeterminationType;
}
+ set
+ {
+ PropertyChangeHelper.ChangePropertyAndNotify(() => data.ZoningBoundariesDeterminationType = value, propertyChangeHandler);
+ }
}
+ [DynamicReadOnly]
+ [PropertyOrder(zoneBoundaryLeftPropertyIndex)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.SlipPlaneSettings_DisplayName))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.ZoneBoundaryLeft_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.ZoneBoundaryLeft_Description))]
+ public RoundedDouble ZoneBoundaryLeft
+ {
+ get
+ {
+ return data.ZoneBoundaryLeft;
+ }
+ set
+ {
+ PropertyChangeHelper.ChangePropertyAndNotify(() => data.ZoneBoundaryLeft = value, propertyChangeHandler);
+ }
+ }
+
+ [DynamicReadOnly]
+ [PropertyOrder(zoneBoundaryRightPropertyIndex)]
+ [ResourcesCategory(typeof(Resources), nameof(Resources.SlipPlaneSettings_DisplayName))]
+ [ResourcesDisplayName(typeof(Resources), nameof(Resources.ZoneBoundaryRight_DisplayName))]
+ [ResourcesDescription(typeof(Resources), nameof(Resources.ZoneBoundaryRight_Description))]
+ public RoundedDouble ZoneBoundaryRight
+ {
+ get
+ {
+ return data.ZoneBoundaryRight;
+ }
+ set
+ {
+ PropertyChangeHelper.ChangePropertyAndNotify(() => data.ZoneBoundaryRight = value, propertyChangeHandler);
+ }
+ }
+
+ [DynamicReadOnlyValidationMethod]
+ public bool DynamicReadOnlyValidationMethod(string param)
+ {
+ if (param == nameof(ZoningBoundariesDeterminationType))
+ {
+ return CreateZones == false;
+ }
+
+ if (param == nameof(ZoneBoundaryLeft) || param == nameof(ZoneBoundaryRight))
+ {
+ return CreateZones == false || ZoningBoundariesDeterminationType == MacroStabilityInwardsZoningBoundariesDeterminationType.Automatic;
+ }
+
+ return false;
+ }
+
public override string ToString()
{
return string.Empty;
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsPropertiesTest.cs
===================================================================
diff -u -r3d30a9febb6492e54f2082bf0a21a1602717b098 -r14504cbfd9e1f22ae5cc264f31bf6d85acc0bd12
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsPropertiesTest.cs (.../MacroStabilityInwardsSlipPlaneSettingsPropertiesTest.cs) (revision 3d30a9febb6492e54f2082bf0a21a1602717b098)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsPropertiesTest.cs (.../MacroStabilityInwardsSlipPlaneSettingsPropertiesTest.cs) (revision 14504cbfd9e1f22ae5cc264f31bf6d85acc0bd12)
@@ -40,6 +40,8 @@
{
private const int expectedCreateZonesPropertyIndex = 0;
private const int expectedZoningBoundariesDeterminationTypePropertyIndex = 1;
+ private const int expectedZoneBoundayrLeftPropertyIndex = 2;
+ private const int expectedZoneBoundaryRightPropertyIndex = 3;
[Test]
public void Constructor_ExpectedValues()
@@ -107,7 +109,7 @@
// Assert
PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);
- Assert.AreEqual(2, dynamicProperties.Count);
+ Assert.AreEqual(4, dynamicProperties.Count);
const string category = "Zonering glijvlak";
@@ -124,9 +126,24 @@
zoningBoundariesDeterminationTypeProperty,
category,
"Methode",
- "Zoneringsgrenzen automatisch bepalen of handmatig invoeren?",
+ "Zoneringsgrenzen automatisch bepalen of handmatig invoeren?");
+
+ PropertyDescriptor zoneBoundaryLeftProperty = dynamicProperties[expectedZoneBoundayrLeftPropertyIndex];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
+ zoneBoundaryLeftProperty,
+ category,
+ "Zoneringsgrens links",
+ "Linker grens voor bepaling intredepunt van het glijvlak.",
true);
+ PropertyDescriptor zoneBoundaryRightProperty = dynamicProperties[expectedZoneBoundaryRightPropertyIndex];
+ PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(
+ zoneBoundaryRightProperty,
+ category,
+ "Zoneringsgrens rechts",
+ "Rechter grens voor bepaling intredepunt van het glijvlak.",
+ true);
+
mocks.VerifyAll();
}
@@ -146,6 +163,8 @@
// Assert
Assert.AreEqual(input.CreateZones, properties.CreateZones);
Assert.AreEqual(input.ZoningBoundariesDeterminationType, properties.ZoningBoundariesDeterminationType);
+ Assert.AreEqual(input.ZoneBoundaryLeft, properties.ZoneBoundaryLeft);
+ Assert.AreEqual(input.ZoneBoundaryRight, properties.ZoneBoundaryRight);
mocks.VerifyAll();
}
@@ -172,45 +191,126 @@
[Test]
public void CreateZones_SetValidValue_SetsValueAndUpdatesObservers()
{
+ // Call & Assert
+ SetPropertyAndVerifyNotifications(properties => properties.CreateZones = false);
+ }
+
+ [Test]
+ public void ZoningBoundariesDeterminationType_SetValidValue_SetsValueAndUpdatesObservers()
+ {
+ // Call & Assert
+ SetPropertyAndVerifyNotifications(properties => properties.ZoningBoundariesDeterminationType = MacroStabilityInwardsZoningBoundariesDeterminationType.Manual);
+ }
+
+ [Test]
+ public void ZoneBoundaryLeft_SetValidValue_SetsValueAndUpdatesObservers()
+ {
+ // Call & Assert
+ SetPropertyAndVerifyNotifications(properties => properties.ZoneBoundaryLeft = new Random(39).NextRoundedDouble());
+ }
+
+ [Test]
+ public void ZoneBoundaryRight_SetValidValue_SetsValueAndUpdatesObservers()
+ {
+ // Call & Assert
+ SetPropertyAndVerifyNotifications(properties => properties.ZoneBoundaryRight = new Random(39).NextRoundedDouble());
+ }
+
+ [Test]
+ public void ToString_Always_ReturnEmptyString()
+ {
// Setup
var mocks = new MockRepository();
- var observable = mocks.StrictMock();
- observable.Expect(o => o.NotifyObservers());
+ var changeHandler = mocks.Stub();
mocks.ReplayAll();
var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties());
+ var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler);
- var handler = new SetPropertyValueAfterConfirmationParameterTester(new[]
+ // Call
+ string toString = properties.ToString();
+
+ // Assert
+ Assert.AreEqual(string.Empty, toString);
+ }
+
+ [Test]
+ [TestCase(true, MacroStabilityInwardsZoningBoundariesDeterminationType.Automatic, false, true)]
+ [TestCase(true, MacroStabilityInwardsZoningBoundariesDeterminationType.Manual, false, false)]
+ [TestCase(false, MacroStabilityInwardsZoningBoundariesDeterminationType.Automatic, true, true)]
+ [TestCase(false, MacroStabilityInwardsZoningBoundariesDeterminationType.Manual, true, true)]
+ public void DynamicReadOnlyValidationMethod_WithCreateZonesAndZoningBoundariesDeterminationType_ReturnsExpectedValues(
+ bool createZones,
+ MacroStabilityInwardsZoningBoundariesDeterminationType zoningBoundariesDeterminationType,
+ bool expectedDeterminationTypeReadOnly,
+ bool expectedZoneBoundariesReadOnly)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var changeHandler = mocks.Stub();
+ mocks.ReplayAll();
+
+ var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties())
{
- observable
- });
+ CreateZones = createZones,
+ ZoningBoundariesDeterminationType = zoningBoundariesDeterminationType
+ };
- var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, handler);
+ var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler);
// Call
- properties.CreateZones = false;
+ bool isZoningBoundariesDeterminationTypeReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoningBoundariesDeterminationType));
+ bool isZoneBoundaryLeftReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoneBoundaryLeft));
+ bool isZoneBoundaryRightReadOnly = properties.DynamicReadOnlyValidationMethod(nameof(properties.ZoneBoundaryRight));
// Assert
- Assert.IsTrue(handler.Called);
- mocks.VerifyAll();
+ Assert.AreEqual(expectedDeterminationTypeReadOnly, isZoningBoundariesDeterminationTypeReadOnly);
+ Assert.AreEqual(expectedZoneBoundariesReadOnly, isZoneBoundaryLeftReadOnly);
+ Assert.AreEqual(expectedZoneBoundariesReadOnly, isZoneBoundaryRightReadOnly);
}
[Test]
- public void ToString_Always_ReturnEmptyString()
+ public void DynamicReadOnlyValidationMethod_AnyOtherParameter_ReturnsFalse()
{
// Setup
var mocks = new MockRepository();
var changeHandler = mocks.Stub();
mocks.ReplayAll();
var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties());
+
var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler);
// Call
- string toString = properties.ToString();
+ bool isReadOnly = properties.DynamicReadOnlyValidationMethod("test parameter name 123");
// Assert
- Assert.AreEqual(string.Empty, toString);
+ Assert.IsFalse(isReadOnly);
}
+
+ private static void SetPropertyAndVerifyNotifications(Action setProperty)
+ {
+ // Setup
+ var mocks = new MockRepository();
+ var observable = mocks.StrictMock();
+ observable.Expect(o => o.NotifyObservers());
+ mocks.ReplayAll();
+
+ var input = new MacroStabilityInwardsInput(new MacroStabilityInwardsInput.ConstructionProperties());
+
+ var handler = new SetPropertyValueAfterConfirmationParameterTester(new[]
+ {
+ observable
+ });
+
+ var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, handler);
+
+ // Call
+ setProperty(properties);
+
+ // Assert
+ Assert.IsTrue(handler.Called);
+ mocks.VerifyAll();
+ }
}
}
\ No newline at end of file