Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -rc103be805b6763fb0fd91404f54e7a855a9bb974 -r30f6264ff7a34ebd761395af491b8a89f8016810 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision c103be805b6763fb0fd91404f54e7a855a9bb974) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 30f6264ff7a34ebd761395af491b8a89f8016810) @@ -531,6 +531,96 @@ } /// + /// Looks up a localized string similar to Offsets PL1 eigenschappen.. + /// + public static string Offsets_Description { + get { + return ResourceManager.GetString("Offsets_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Offsets PL1. + /// + public static string Offsets_DisplayName { + get { + return ResourceManager.GetString("Offsets_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Waterstandsverschil tussen het maaiveld en de freatische lijn onder teen dijk binnenwaarts.. + /// + public static string PhreaticLineOffsetBelowDikeToeAtPolder_Description { + get { + return ResourceManager.GetString("PhreaticLineOffsetBelowDikeToeAtPolder_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to PL1 offset onder teen dijk binnenwaarts [m]. + /// + public static string PhreaticLineOffsetBelowDikeToeAtPolder_DisplayName { + get { + return ResourceManager.GetString("PhreaticLineOffsetBelowDikeToeAtPolder_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Waterstandsverschil tussen toetspeil en de freatische lijn onder kruin binnentalud.. + /// + public static string PhreaticLineOffsetBelowDikeTopAtPolder_Description { + get { + return ResourceManager.GetString("PhreaticLineOffsetBelowDikeTopAtPolder_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to PL1 offset onder binnenkruin [m]. + /// + public static string PhreaticLineOffsetBelowDikeTopAtPolder_DisplayName { + get { + return ResourceManager.GetString("PhreaticLineOffsetBelowDikeTopAtPolder_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Waterstandsverschil tussen toetspeil en de freatische lijn onder kruin buitentalud.. + /// + public static string PhreaticLineOffsetBelowDikeTopAtRiver_Description { + get { + return ResourceManager.GetString("PhreaticLineOffsetBelowDikeTopAtRiver_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to PL1 offset onder buitenkruin [m]. + /// + public static string PhreaticLineOffsetBelowDikeTopAtRiver_DisplayName { + get { + return ResourceManager.GetString("PhreaticLineOffsetBelowDikeTopAtRiver_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Waterstandsverschil tussen het maaiveld en de freatische lijn onder insteek binnenberm.. + /// + public static string PhreaticLineOffsetBelowShoulderBaseInside_Description { + get { + return ResourceManager.GetString("PhreaticLineOffsetBelowShoulderBaseInside_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to PL1 offset onder insteek binnenberm [m]. + /// + public static string PhreaticLineOffsetBelowShoulderBaseInside_DisplayName { + get { + return ResourceManager.GetString("PhreaticLineOffsetBelowShoulderBaseInside_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized resource of type System.Drawing.Bitmap. /// public static System.Drawing.Bitmap SoilProfileIcon { @@ -714,6 +804,24 @@ } /// + /// Looks up a localized string similar to Gebruik standaard waterstandsverschillen voor het bepalen van de freatische lijn?. + /// + public static string UseDefaultOffset_Description { + get { + return ResourceManager.GetString("UseDefaultOffset_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Gebruik default waarden voor offsets van PL1. + /// + public static string UseDefaultOffset_DisplayName { + get { + return ResourceManager.GetString("UseDefaultOffset_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Het niveau van het oppervlaktewater binnen een beheersgebied.. /// public static string WaterLevelPolder_Description { Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx =================================================================== diff -u -rc103be805b6763fb0fd91404f54e7a855a9bb974 -r30f6264ff7a34ebd761395af491b8a89f8016810 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision c103be805b6763fb0fd91404f54e7a855a9bb974) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 30f6264ff7a34ebd761395af491b8a89f8016810) @@ -343,6 +343,42 @@ PL 1 initiele hoogte onder buitenkruin [m+NAP] + + Offsets PL1 eigenschappen. + + + Offsets PL1 + + + Waterstandsverschil tussen het maaiveld en de freatische lijn onder teen dijk binnenwaarts. + + + PL1 offset onder teen dijk binnenwaarts [m] + + + Waterstandsverschil tussen toetspeil en de freatische lijn onder kruin binnentalud. + + + PL1 offset onder binnenkruin [m] + + + Waterstandsverschil tussen toetspeil en de freatische lijn onder kruin buitentalud. + + + PL1 offset onder buitenkruin [m] + + + Waterstandsverschil tussen het maaiveld en de freatische lijn onder insteek binnenberm. + + + PL1 offset onder insteek binnenberm [m] + + + Gebruik standaard waterstandsverschillen voor het bepalen van de freatische lijn? + + + Gebruik default waarden voor offsets van PL1 + X-coordinaat van het middelpunt van de drainage (in lokale coordinaten). Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsOffsetsProperties.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsOffsetsProperties.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsOffsetsProperties.cs (revision 30f6264ff7a34ebd761395af491b8a89f8016810) @@ -0,0 +1,163 @@ +// Copyright (C) Stichting Deltares 2017. 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 Core.Common.Base.Data; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.Common.Forms.ChangeHandlers; +using Ringtoets.Common.Forms.PropertyClasses; +using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.Forms.PresentationObjects; +using Ringtoets.MacroStabilityInwards.Forms.Properties; + +namespace Ringtoets.MacroStabilityInwards.Forms.PropertyClasses +{ + /// + /// ViewModel of drainage properties in for properties panel. + /// + public class MacroStabilityInwardsOffsetsProperties : ObjectProperties + { + private const int useDefaultOffsetPropertyIndex = 1; + private const int phreaticLineOffsetBelowDikeTopAtRiverPropertyIndex = 2; + private const int phreaticLineOffsetBelowDikeTopAtPolderPropertyIndex = 3; + private const int phreaticLineOffsetBelowShoulderBaseInsidePropertyIndex = 4; + private const int phreaticLineOffsetBelowDikeToeAtPolderPropertyIndex = 5; + + private IObservablePropertyChangeHandler propertyChangeHandler; + + /// + /// Creates a new instance of . + /// + /// The data of the properties + /// The handler responsible for handling effects of a property change. + /// Thrown when any parameter is null. + public MacroStabilityInwardsOffsetsProperties(MacroStabilityInwardsInput data, IObservablePropertyChangeHandler handler) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + if (handler == null) + { + throw new ArgumentNullException(nameof(handler)); + } + this.data = data; + propertyChangeHandler = handler; + } + + [PropertyOrder(useDefaultOffsetPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Offsets_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.UseDefaultOffset_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.UseDefaultOffset_Description))] + public bool UseDefaultOffset + { + get + { + return data.UseDefaultOffset; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.UseDefaultOffset = value, propertyChangeHandler); + } + } + + [DynamicReadOnly] + [PropertyOrder(phreaticLineOffsetBelowDikeTopAtRiverPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Offsets_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PhreaticLineOffsetBelowDikeTopAtRiver_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PhreaticLineOffsetBelowDikeTopAtRiver_Description))] + public RoundedDouble PhreaticLineOffsetBelowDikeTopAtRiver + { + get + { + return data.PhreaticLineOffsetBelowDikeTopAtRiver; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.PhreaticLineOffsetBelowDikeTopAtRiver = value, propertyChangeHandler); + } + } + + [DynamicReadOnly] + [PropertyOrder(phreaticLineOffsetBelowDikeTopAtPolderPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Offsets_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PhreaticLineOffsetBelowDikeTopAtPolder_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PhreaticLineOffsetBelowDikeTopAtPolder_Description))] + public RoundedDouble PhreaticLineOffsetBelowDikeTopAtPolder + { + get + { + return data.PhreaticLineOffsetBelowDikeTopAtPolder; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.PhreaticLineOffsetBelowDikeTopAtPolder = value, propertyChangeHandler); + } + } + + [DynamicReadOnly] + [PropertyOrder(phreaticLineOffsetBelowShoulderBaseInsidePropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Offsets_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PhreaticLineOffsetBelowShoulderBaseInside_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PhreaticLineOffsetBelowShoulderBaseInside_Description))] + public RoundedDouble PhreaticLineOffsetBelowShoulderBaseInside + { + get + { + return data.PhreaticLineOffsetBelowShoulderBaseInside; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.PhreaticLineOffsetBelowShoulderBaseInside = value, propertyChangeHandler); + } + } + + [DynamicReadOnly] + [PropertyOrder(phreaticLineOffsetBelowDikeToeAtPolderPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Offsets_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.PhreaticLineOffsetBelowDikeToeAtPolder_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.PhreaticLineOffsetBelowDikeToeAtPolder_Description))] + public RoundedDouble PhreaticLineOffsetBelowDikeToeAtPolder + { + get + { + return data.PhreaticLineOffsetBelowDikeToeAtPolder; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.PhreaticLineOffsetBelowDikeToeAtPolder = value, propertyChangeHandler); + } + } + + [DynamicReadOnlyValidationMethod] + public bool DynamicReadOnlyValidationMethod(string propertyName) + { + return !UseDefaultOffset; + } + + public override string ToString() + { + return string.Empty; + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsWaterStressesProperties.cs =================================================================== diff -u -rc103be805b6763fb0fd91404f54e7a855a9bb974 -r30f6264ff7a34ebd761395af491b8a89f8016810 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsWaterStressesProperties.cs (.../MacroStabilityInwardsWaterStressesProperties.cs) (revision c103be805b6763fb0fd91404f54e7a855a9bb974) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsWaterStressesProperties.cs (.../MacroStabilityInwardsWaterStressesProperties.cs) (revision 30f6264ff7a34ebd761395af491b8a89f8016810) @@ -38,11 +38,12 @@ /// public class MacroStabilityInwardsWaterStressesProperties : ObjectProperties { - private const int waterLevelRiverAveragePropertyIndex = 0; - private const int waterLevelPolderPropertyIndex = 1; - private const int drainagePropertyIndex = 2; - private const int minimumLevelPhreaticLineAtDikeTopRiverPropertyIndex = 3; - private const int minimumLevelPhreaticLineAtDikeTopPolderPropertyIndex = 4; + private const int waterLevelRiverAveragePropertyIndex = 1; + private const int waterLevelPolderPropertyIndex = 2; + private const int drainagePropertyIndex = 3; + private const int minimumLevelPhreaticLineAtDikeTopRiverPropertyIndex = 4; + private const int minimumLevelPhreaticLineAtDikeTopPolderPropertyIndex = 5; + private const int offsetsPropertyIndex = 6; private readonly IObservablePropertyChangeHandler propertyChangeHandler; @@ -143,6 +144,19 @@ } } + [PropertyOrder(offsetsPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Waterstresses_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.Offsets_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.Offsets_Description))] + [TypeConverter(typeof(ExpandableObjectConverter))] + public MacroStabilityInwardsOffsetsProperties Offsets + { + get + { + return new MacroStabilityInwardsOffsetsProperties(data, propertyChangeHandler); + } + } + public override string ToString() { return string.Empty; Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj =================================================================== diff -u -r626da40a6865fc35d4a579b74e3f5cff3372b890 -r30f6264ff7a34ebd761395af491b8a89f8016810 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 30f6264ff7a34ebd761395af491b8a89f8016810) @@ -68,6 +68,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsDrainagePropertiesTest.cs =================================================================== diff -u -r1ab5c5f5743797918f2c11a57035d0eb8b49049c -r30f6264ff7a34ebd761395af491b8a89f8016810 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsDrainagePropertiesTest.cs (.../MacroStabilityInwardsDrainagePropertiesTest.cs) (revision 1ab5c5f5743797918f2c11a57035d0eb8b49049c) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsDrainagePropertiesTest.cs (.../MacroStabilityInwardsDrainagePropertiesTest.cs) (revision 30f6264ff7a34ebd761395af491b8a89f8016810) @@ -235,10 +235,10 @@ var properties = new MacroStabilityInwardsDrainageProperties(input, handler); // Call - bool result = properties.DynamicReadOnlyValidationMethod("AssessmentLevel"); + bool result = properties.DynamicReadOnlyValidationMethod(""); // Assert - Assert.AreNotEqual(drainageConstructionPresent, result); + Assert.AreEqual(!drainageConstructionPresent, result); } [Test] Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsOffsetsPropertiesTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsOffsetsPropertiesTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsOffsetsPropertiesTest.cs (revision 30f6264ff7a34ebd761395af491b8a89f8016810) @@ -0,0 +1,334 @@ +// Copyright (C) Stichting Deltares 2017. 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.ComponentModel; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Forms.ChangeHandlers; +using Ringtoets.Common.Forms.PropertyClasses; +using Ringtoets.Common.Forms.TestUtil; +using Ringtoets.MacroStabilityInwards.Data; +using Ringtoets.MacroStabilityInwards.Forms.PropertyClasses; + +namespace Ringtoets.MacroStabilityInwards.Forms.Test.PropertyClasses +{ + [TestFixture] + public class MacroStabilityInwardsOffsetsPropertiesTest + { + private const int expectedUseDefaultOffsetPropertyIndex = 0; + private const int expectedPhreaticLineOffsetBelowDikeTopAtRiverPropertyIndex = 1; + private const int expectedPhreaticLineOffsetBelowDikeTopAtPolderPropertyIndex = 2; + private const int expectedPhreaticLineOffsetBelowShoulderBaseInsidePropertyIndex = 3; + private const int expectedPhreaticLineOffsetBelowDikeToeAtPolderPropertyIndex = 4; + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(new GeneralMacroStabilityInwardsInput()); + + // Call + var properties = new MacroStabilityInwardsOffsetsProperties(input, changeHandler); + + // Assert + Assert.IsInstanceOf>(properties); + Assert.AreSame(input, properties.Data); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_DataNull_ThrowsArgumentNullException() + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub(); + mocks.ReplayAll(); + + // Call + TestDelegate call = () => new MacroStabilityInwardsOffsetsProperties(null, changeHandler); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("data", exception.ParamName); + mocks.VerifyAll(); + } + + [Test] + public void Constructor_HandlerNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => new MacroStabilityInwardsOffsetsProperties(new MacroStabilityInwardsInput(new GeneralMacroStabilityInwardsInput()), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("handler", exception.ParamName); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void Constructor_ValidData_PropertiesHaveExpectedAttributesValues(bool useDefaultOffset) + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(new GeneralMacroStabilityInwardsInput()) + { + UseDefaultOffset = useDefaultOffset + }; + + // Call + var properties = new MacroStabilityInwardsOffsetsProperties(input, changeHandler); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + + Assert.AreEqual(5, dynamicProperties.Count); + + const string offsetCategory = "Offsets PL1"; + + PropertyDescriptor useDefaultOffsetProperty = dynamicProperties[expectedUseDefaultOffsetPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + useDefaultOffsetProperty, + offsetCategory, + "Gebruik default waarden voor offsets van PL1", + "Gebruik standaard waterstandsverschillen voor het bepalen van de freatische lijn?"); + + PropertyDescriptor phreaticLineOffsetBelowDikeTopAtRiverProperty = dynamicProperties[expectedPhreaticLineOffsetBelowDikeTopAtRiverPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + phreaticLineOffsetBelowDikeTopAtRiverProperty, + offsetCategory, + "PL1 offset onder buitenkruin [m]", + "Waterstandsverschil tussen toetspeil en de freatische lijn onder kruin buitentalud.", + !useDefaultOffset); + + PropertyDescriptor phreaticLineOffsetBelowDikeTopAtPolderProperty = dynamicProperties[expectedPhreaticLineOffsetBelowDikeTopAtPolderPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + phreaticLineOffsetBelowDikeTopAtPolderProperty, + offsetCategory, + "PL1 offset onder binnenkruin [m]", + "Waterstandsverschil tussen toetspeil en de freatische lijn onder kruin binnentalud.", + !useDefaultOffset); + + PropertyDescriptor phreaticLineOffsetBelowShoulderBaseInsideProperty = dynamicProperties[expectedPhreaticLineOffsetBelowShoulderBaseInsidePropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + phreaticLineOffsetBelowShoulderBaseInsideProperty, + offsetCategory, + "PL1 offset onder insteek binnenberm [m]", + "Waterstandsverschil tussen het maaiveld en de freatische lijn onder insteek binnenberm.", + !useDefaultOffset); + + PropertyDescriptor phreaticLineOffsetBelowDikeToeAtPolderProperty = dynamicProperties[expectedPhreaticLineOffsetBelowDikeToeAtPolderPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + phreaticLineOffsetBelowDikeToeAtPolderProperty, + offsetCategory, + "PL1 offset onder teen dijk binnenwaarts [m]", + "Waterstandsverschil tussen het maaiveld en de freatische lijn onder teen dijk binnenwaarts.", + !useDefaultOffset); + + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(new GeneralMacroStabilityInwardsInput()); + + // Call + var properties = new MacroStabilityInwardsOffsetsProperties(input, changeHandler); + + // Assert + Assert.AreEqual(input.UseDefaultOffset, properties.UseDefaultOffset); + Assert.AreEqual(input.PhreaticLineOffsetBelowDikeTopAtRiver, properties.PhreaticLineOffsetBelowDikeTopAtRiver); + Assert.AreEqual(input.PhreaticLineOffsetBelowDikeTopAtPolder, properties.PhreaticLineOffsetBelowDikeTopAtPolder); + Assert.AreEqual(input.PhreaticLineOffsetBelowShoulderBaseInside, properties.PhreaticLineOffsetBelowShoulderBaseInside); + Assert.AreEqual(input.PhreaticLineOffsetBelowDikeToeAtPolder, properties.PhreaticLineOffsetBelowDikeToeAtPolder); + mocks.VerifyAll(); + } + + [Test] + public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() + { + // Given + var calculationItem = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + MacroStabilityInwardsInput input = calculationItem.InputParameters; + + var handler = new ObservablePropertyChangeHandler(calculationItem, input); + var properties = new MacroStabilityInwardsOffsetsProperties(input, handler); + + var random = new Random(); + bool useDefaultOffset = random.NextBoolean(); + double phreaticLineOffsetBelowDikeTopAtRiver = random.Next(); + double phreaticLineOffsetBelowDikeTopAtPolder = random.Next(); + double phreaticLineOffsetBelowShoulderBaseInside = random.Next(); + double phreaticLineOffsetBelowDikeToeAtPolder = random.Next(); + + // When + properties.UseDefaultOffset = useDefaultOffset; + properties.PhreaticLineOffsetBelowDikeTopAtRiver = (RoundedDouble) phreaticLineOffsetBelowDikeTopAtRiver; + properties.PhreaticLineOffsetBelowDikeTopAtPolder = (RoundedDouble) phreaticLineOffsetBelowDikeTopAtPolder; + properties.PhreaticLineOffsetBelowShoulderBaseInside = (RoundedDouble)phreaticLineOffsetBelowShoulderBaseInside; + properties.PhreaticLineOffsetBelowDikeToeAtPolder = (RoundedDouble)phreaticLineOffsetBelowDikeToeAtPolder; + + // Then + Assert.AreEqual(useDefaultOffset, input.UseDefaultOffset); + Assert.AreEqual(phreaticLineOffsetBelowDikeTopAtRiver, input.PhreaticLineOffsetBelowDikeTopAtRiver.Value); + Assert.AreEqual(phreaticLineOffsetBelowDikeTopAtPolder, input.PhreaticLineOffsetBelowDikeTopAtPolder.Value); + Assert.AreEqual(phreaticLineOffsetBelowShoulderBaseInside, input.PhreaticLineOffsetBelowShoulderBaseInside.Value); + Assert.AreEqual(phreaticLineOffsetBelowDikeToeAtPolder, input.PhreaticLineOffsetBelowDikeToeAtPolder.Value); + } + + [Test] + public void UseDefaultOffset_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsForCalculation(properties => properties.UseDefaultOffset = true, calculation); + } + + [Test] + public void PhreaticLineOffsetBelowDikeTopAtRiver_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsForCalculation(properties => properties.PhreaticLineOffsetBelowDikeTopAtRiver = (RoundedDouble) 1, calculation); + } + + [Test] + public void PhreaticLineOffsetBelowDikeTopAtPolder_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsForCalculation(properties => properties.PhreaticLineOffsetBelowDikeTopAtPolder = (RoundedDouble) 1, calculation); + } + + [Test] + public void PhreaticLineOffsetBelowShoulderBaseInside_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsForCalculation(properties => properties.PhreaticLineOffsetBelowShoulderBaseInside = (RoundedDouble) 1, calculation); + } + + [Test] + public void PhreaticLineOffsetBelowDikeToeAtPolder_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsForCalculation(properties => properties.PhreaticLineOffsetBelowDikeToeAtPolder = (RoundedDouble) 1, calculation); + } + + [Test] + [TestCase(true)] + [TestCase(false)] + public void DynamicReadOnlyValidationMethod_Always_DependsDrainageConstructionPresent(bool useDefaultOffset) + { + // Setup + var mocks = new MockRepository(); + var handler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(new GeneralMacroStabilityInwardsInput()) + { + UseDefaultOffset = useDefaultOffset + }; + + var properties = new MacroStabilityInwardsOffsetsProperties(input, handler); + + // Call + bool result = properties.DynamicReadOnlyValidationMethod(""); + + // Assert + Assert.AreEqual(!useDefaultOffset, result); + } + + [Test] + public void ToString_Always_ReturnEmptyString() + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(new GeneralMacroStabilityInwardsInput()); + var properties = new MacroStabilityInwardsOffsetsProperties(input, changeHandler); + + // Call + string toString = properties.ToString(); + + // Assert + Assert.AreEqual(string.Empty, toString); + } + + private static void SetPropertyAndVerifyNotifcationsForCalculation(Action setProperty, + MacroStabilityInwardsCalculation calculation) + { + // Setup + var mocks = new MockRepository(); + var observable = mocks.StrictMock(); + observable.Expect(o => o.NotifyObservers()); + mocks.ReplayAll(); + + MacroStabilityInwardsInput input = calculation.InputParameters; + + var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); + + var properties = new MacroStabilityInwardsOffsetsProperties(input, handler); + + // Call + setProperty(properties); + + // Assert + Assert.IsTrue(handler.Called); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsWaterStressesPropertiesTest.cs =================================================================== diff -u -rc103be805b6763fb0fd91404f54e7a855a9bb974 -r30f6264ff7a34ebd761395af491b8a89f8016810 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsWaterStressesPropertiesTest.cs (.../MacroStabilityInwardsWaterStressesPropertiesTest.cs) (revision c103be805b6763fb0fd91404f54e7a855a9bb974) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsWaterStressesPropertiesTest.cs (.../MacroStabilityInwardsWaterStressesPropertiesTest.cs) (revision 30f6264ff7a34ebd761395af491b8a89f8016810) @@ -43,6 +43,7 @@ private const int expectedDrainagePropertyIndex = 2; private const int expectedMinimumLevelPhreaticLineAtDikeTopRiverPropertyIndex = 3; private const int expectedMinimumLevelPhreaticLineAtDikeTopPolderPropertyIndex = 4; + private const int expecteOffsetPropertyIndex = 5; [Test] public void Constructor_ExpectedValues() @@ -108,7 +109,7 @@ // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(5, dynamicProperties.Count); + Assert.AreEqual(6, dynamicProperties.Count); const string waterStressesCategory = "Waterspanningen"; @@ -149,6 +150,15 @@ "PL 1 initiele hoogte onder binnenkruin [m+NAP]", "Minimale hoogte van de freatische lijn onder kruin binnentalud."); + PropertyDescriptor offsetProperty = dynamicProperties[expecteOffsetPropertyIndex]; + Assert.AreEqual(typeof(ExpandableObjectConverter), offsetProperty.Converter.GetType()); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + offsetProperty, + waterStressesCategory, + "Offsets PL1", + "Offsets PL1 eigenschappen.", + true); + mocks.VerifyAll(); } @@ -171,6 +181,7 @@ Assert.AreSame(input, properties.Drainage.Data); Assert.AreEqual(input.MinimumLevelPhreaticLineAtDikeTopRiver, properties.MinimumLevelPhreaticLineAtDikeTopRiver); Assert.AreEqual(input.MinimumLevelPhreaticLineAtDikeTopPolder, properties.MinimumLevelPhreaticLineAtDikeTopPolder); + Assert.AreSame(input, properties.Offsets.Data); mocks.VerifyAll(); } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj =================================================================== diff -u -r626da40a6865fc35d4a579b74e3f5cff3372b890 -r30f6264ff7a34ebd761395af491b8a89f8016810 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision 30f6264ff7a34ebd761395af491b8a89f8016810) @@ -70,6 +70,7 @@ +