Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r79b21a40895beb5fd233c3e3cb20d82e6ab5be56 -r626da40a6865fc35d4a579b74e3f5cff3372b890 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 79b21a40895beb5fd233c3e3cb20d82e6ab5be56) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) @@ -109,6 +109,42 @@ } /// + /// Looks up a localized string similar to Drainage constructie eigenschappen.. + /// + public static string DrainageConstruction_Description { + get { + return ResourceManager.GetString("DrainageConstruction_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Drainage. + /// + public static string DrainageConstruction_DisplayName { + get { + return ResourceManager.GetString("DrainageConstruction_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Is drainage aanwezig?. + /// + public static string DrainageConstructionPresent_Description { + get { + return ResourceManager.GetString("DrainageConstructionPresent_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Aanwezig. + /// + public static string DrainageConstructionPresent_DisplayName { + get { + return ResourceManager.GetString("DrainageConstructionPresent_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to De parameter 'a' die gebruikt wordt voor het lengte-effect in berekening van de maximaal toelaatbare faalkans.. /// public static string GeneralMacroStabilityInwardsInput_A_Description { @@ -642,6 +678,24 @@ } /// + /// Looks up a localized string similar to Het niveau van het oppervlaktewater binnen een beheersgebied.. + /// + public static string WaterLevelPolder_Description { + get { + return ResourceManager.GetString("WaterLevelPolder_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Polderpeil [m+NAP]. + /// + public static string WaterLevelPolder_DisplayName { + get { + return ResourceManager.GetString("WaterLevelPolder_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Gemiddeld hoog water.. /// public static string WaterLevelRiverAverage_Description { @@ -676,5 +730,41 @@ return ResourceManager.GetString("Waterstresses_DisplayName", resourceCulture); } } + + /// + /// Looks up a localized string similar to X-coordinaat van het middelpunt van de drainage (in lokale coordinaten).. + /// + public static string XCoordinateDrainageConstruction_Description { + get { + return ResourceManager.GetString("XCoordinateDrainageConstruction_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to X [m]. + /// + public static string XCoordinateDrainageConstruction_DisplayName { + get { + return ResourceManager.GetString("XCoordinateDrainageConstruction_DisplayName", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Z-coordinaat (hoogte) van het middelpunt van de drainage.. + /// + public static string ZCoordinateDrainageConstruction_Description { + get { + return ResourceManager.GetString("ZCoordinateDrainageConstruction_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Z [m+NAP]. + /// + public static string ZCoordinateDrainageConstruction_DisplayName { + get { + return ResourceManager.GetString("ZCoordinateDrainageConstruction_DisplayName", resourceCulture); + } + } } } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx =================================================================== diff -u -r79b21a40895beb5fd233c3e3cb20d82e6ab5be56 -r626da40a6865fc35d4a579b74e3f5cff3372b890 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 79b21a40895beb5fd233c3e3cb20d82e6ab5be56) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) @@ -313,4 +313,34 @@ De waterspanning eigenschappen. + + Is drainage aanwezig? + + + Aanwezig + + + Drainage + + + Het niveau van het oppervlaktewater binnen een beheersgebied. + + + Polderpeil [m+NAP] + + + Drainage constructie eigenschappen. + + + X-coordinaat van het middelpunt van de drainage (in lokale coordinaten). + + + X [m] + + + Z-coordinaat (hoogte) van het middelpunt van de drainage. + + + Z [m+NAP] + \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsDrainageProperties.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsDrainageProperties.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsDrainageProperties.cs (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) @@ -0,0 +1,119 @@ +// 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 MacroStabilityInwardsDrainageProperties : ObjectProperties + { + private const int drainageConstructionPresentPropertyIndex = 0; + private const int xCoordinateDrainageConstructionPropertyIndex = 1; + private const int zCoordinateDrainageConstructionPropertyIndex = 2; + + private readonly 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 MacroStabilityInwardsDrainageProperties(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(drainageConstructionPresentPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.DrainageConstruction_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.DrainageConstructionPresent_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.DrainageConstructionPresent_Description))] + public bool DrainageConstructionPresent + { + get + { + return data.DrainageConstructionPresent; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.DrainageConstructionPresent = value, propertyChangeHandler); + } + } + + [PropertyOrder(xCoordinateDrainageConstructionPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.DrainageConstruction_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.XCoordinateDrainageConstruction_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.XCoordinateDrainageConstruction_Description))] + public RoundedDouble XCoordinateDrainageConstruction + { + get + { + return data.XCoordinateDrainageConstruction; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.XCoordinateDrainageConstruction = value, propertyChangeHandler); + } + } + + [PropertyOrder(zCoordinateDrainageConstructionPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.DrainageConstruction_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.ZCoordinateDrainageConstruction_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.ZCoordinateDrainageConstruction_Description))] + public RoundedDouble ZCoordinateDrainageConstruction + { + get + { + return data.ZCoordinateDrainageConstruction; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.ZCoordinateDrainageConstruction = value, propertyChangeHandler); + } + } + + 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 -r79b21a40895beb5fd233c3e3cb20d82e6ab5be56 -r626da40a6865fc35d4a579b74e3f5cff3372b890 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsWaterStressesProperties.cs (.../MacroStabilityInwardsWaterStressesProperties.cs) (revision 79b21a40895beb5fd233c3e3cb20d82e6ab5be56) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsWaterStressesProperties.cs (.../MacroStabilityInwardsWaterStressesProperties.cs) (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.ComponentModel; using Core.Common.Base.Data; using Core.Common.Gui.Attributes; using Core.Common.Gui.PropertyBag; @@ -38,6 +39,8 @@ public class MacroStabilityInwardsWaterStressesProperties : ObjectProperties { private const int waterLevelRiverAveragePropertyIndex = 0; + private const int waterLevelPolderPropertyIndex = 1; + private const int drainagePropertyIndex = 2; private readonly IObservablePropertyChangeHandler propertyChangeHandler; @@ -77,6 +80,35 @@ } } + [PropertyOrder(waterLevelPolderPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Waterstresses_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.WaterLevelPolder_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.WaterLevelPolder_Description))] + public RoundedDouble WaterLevelPolder + { + get + { + return data.WaterLevelPolder; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.WaterLevelPolder = value, propertyChangeHandler); + } + } + + [PropertyOrder(drainagePropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Waterstresses_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.DrainageConstruction_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.DrainageConstruction_Description))] + [TypeConverter(typeof(ExpandableObjectConverter))] + public MacroStabilityInwardsDrainageProperties Drainage + { + get + { + return new MacroStabilityInwardsDrainageProperties(data, propertyChangeHandler); + } + } + public override string ToString() { return string.Empty; Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj =================================================================== diff -u -r79b21a40895beb5fd233c3e3cb20d82e6ab5be56 -r626da40a6865fc35d4a579b74e3f5cff3372b890 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 79b21a40895beb5fd233c3e3cb20d82e6ab5be56) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) @@ -65,6 +65,7 @@ True Resources.resx + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsDrainagePropertiesTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsDrainagePropertiesTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsDrainagePropertiesTest.cs (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) @@ -0,0 +1,257 @@ +// 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 MacroStabilityInwardsDrainagePropertiesTest + { + private const int expectedDrainageConstructionPresentPropertyIndex = 0; + private const int expectedXCoordinateDrainageConstructionPropertyIndex = 1; + private const int expectedZCoordinateDrainageConstructionPropertyIndex = 2; + + [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 MacroStabilityInwardsDrainageProperties(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 MacroStabilityInwardsDrainageProperties(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 MacroStabilityInwardsDrainageProperties(new MacroStabilityInwardsInput(new GeneralMacroStabilityInwardsInput()), + null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("handler", exception.ParamName); + } + + [Test] + public void Constructor_ValidData_PropertiesHaveExpectedAttributesValues() + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(new GeneralMacroStabilityInwardsInput()); + + // Call + var properties = new MacroStabilityInwardsDrainageProperties(input, changeHandler); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + + Assert.AreEqual(3, dynamicProperties.Count); + + const string drainageCategory = "Drainage"; + + PropertyDescriptor drainagePresentProperty = dynamicProperties[expectedDrainageConstructionPresentPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + drainagePresentProperty, + drainageCategory, + "Aanwezig", + "Is drainage aanwezig?"); + + PropertyDescriptor drainageXProperty = dynamicProperties[expectedXCoordinateDrainageConstructionPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + drainageXProperty, + drainageCategory, + "X [m]", + "X-coordinaat van het middelpunt van de drainage (in lokale coordinaten)."); + + PropertyDescriptor drainageZProperty = dynamicProperties[expectedZCoordinateDrainageConstructionPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + drainageZProperty, + drainageCategory, + "Z [m+NAP]", + "Z-coordinaat (hoogte) van het middelpunt van de drainage."); + + 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 MacroStabilityInwardsDrainageProperties(input, changeHandler); + + // Assert + Assert.AreEqual(input.DrainageConstructionPresent, properties.DrainageConstructionPresent); + Assert.AreEqual(input.XCoordinateDrainageConstruction, properties.XCoordinateDrainageConstruction); + Assert.AreEqual(input.ZCoordinateDrainageConstruction, properties.ZCoordinateDrainageConstruction); + 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 MacroStabilityInwardsDrainageProperties(input, handler); + + var random = new Random(); + bool constructionPresent = random.NextBoolean(); + double xCoordinateDrainageConstruction = random.Next(); + double zCoordinateDrainageConstruction = random.Next(); + + // When + properties.DrainageConstructionPresent = constructionPresent; + properties.XCoordinateDrainageConstruction = (RoundedDouble) xCoordinateDrainageConstruction; + properties.ZCoordinateDrainageConstruction = (RoundedDouble) zCoordinateDrainageConstruction; + + // Then + Assert.AreEqual(constructionPresent, input.DrainageConstructionPresent); + Assert.AreEqual(xCoordinateDrainageConstruction, input.XCoordinateDrainageConstruction.Value); + Assert.AreEqual(zCoordinateDrainageConstruction, input.ZCoordinateDrainageConstruction.Value); + } + + [Test] + public void DrainageConstructionPresent_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsForCalculation(properties => properties.DrainageConstructionPresent = true, calculation); + } + + [Test] + public void XCoordinateDrainageConstruction_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsForCalculation(properties => properties.XCoordinateDrainageConstruction = (RoundedDouble) 1, calculation); + } + + [Test] + public void ZCoordinateDrainageConstruction_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsForCalculation(properties => properties.ZCoordinateDrainageConstruction = (RoundedDouble) 1, calculation); + } + + [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 MacroStabilityInwardsWaterStressesProperties(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 MacroStabilityInwardsDrainageProperties(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/MacroStabilityInwardsInputContextPropertiesTest.cs =================================================================== diff -u -r79b21a40895beb5fd233c3e3cb20d82e6ab5be56 -r626da40a6865fc35d4a579b74e3f5cff3372b890 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision 79b21a40895beb5fd233c3e3cb20d82e6ab5be56) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) @@ -357,6 +357,8 @@ Assert.AreEqual(inputParameters.UseAssessmentLevelManualInput, properties.UseAssessmentLevelManualInput); Assert.AreEqual(inputParameters.DikeSoilScenario, properties.DikeSoilScenario); + Assert.AreSame(inputParameters, properties.WaterStressesProperties.Data); + mocks.VerifyAll(); } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsWaterStressesPropertiesTest.cs =================================================================== diff -u -r79b21a40895beb5fd233c3e3cb20d82e6ab5be56 -r626da40a6865fc35d4a579b74e3f5cff3372b890 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsWaterStressesPropertiesTest.cs (.../MacroStabilityInwardsWaterStressesPropertiesTest.cs) (revision 79b21a40895beb5fd233c3e3cb20d82e6ab5be56) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsWaterStressesPropertiesTest.cs (.../MacroStabilityInwardsWaterStressesPropertiesTest.cs) (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) @@ -39,6 +39,8 @@ public class MacroStabilityInwardsWaterStressesPropertiesTest { private const int expectedWaterLevelRiverAveragePropertyIndex = 0; + private const int expectedwaterLevelPolderPropertyIndex = 1; + private const int expectedDrainagePropertyIndex = 2; [Test] public void Constructor_ExpectedValues() @@ -104,7 +106,7 @@ // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(1, dynamicProperties.Count); + Assert.AreEqual(3, dynamicProperties.Count); const string waterStressesCategory = "Waterspanningen"; @@ -115,6 +117,22 @@ "Gemiddeld hoog water (GHW) [m+NAP]", "Gemiddeld hoog water."); + PropertyDescriptor waterLevelPolderProperty = dynamicProperties[expectedwaterLevelPolderPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + waterLevelPolderProperty, + waterStressesCategory, + "Polderpeil [m+NAP]", + "Het niveau van het oppervlaktewater binnen een beheersgebied."); + + PropertyDescriptor drainageProperty = dynamicProperties[expectedDrainagePropertyIndex]; + Assert.AreEqual(typeof(ExpandableObjectConverter), drainageProperty.Converter.GetType()); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + drainageProperty, + waterStressesCategory, + "Drainage", + "Drainage constructie eigenschappen.", + true); + mocks.VerifyAll(); } @@ -133,7 +151,8 @@ // Assert Assert.AreEqual(input.WaterLevelRiverAverage, properties.WaterLevelRiverAverage); - + Assert.AreEqual(input.WaterLevelPolder, properties.WaterLevelPolder); + Assert.AreSame(input, properties.Drainage.Data); mocks.VerifyAll(); } @@ -147,13 +166,17 @@ var handler = new ObservablePropertyChangeHandler(calculationItem, input); var properties = new MacroStabilityInwardsWaterStressesProperties(input, handler); - const double waterLevelRiverAverage = 12; + var random = new Random(); + double waterLevelRiverAverage = random.Next(); + double waterLevelPolder = random.Next(); // When properties.WaterLevelRiverAverage = (RoundedDouble) waterLevelRiverAverage; + properties.WaterLevelPolder = (RoundedDouble) waterLevelPolder; // Then Assert.AreEqual(waterLevelRiverAverage, input.WaterLevelRiverAverage.Value); + Assert.AreEqual(waterLevelPolder, input.WaterLevelPolder.Value); } [Test] @@ -167,6 +190,16 @@ } [Test] + public void WaterLevelPolder_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var calculation = new MacroStabilityInwardsCalculationScenario(new GeneralMacroStabilityInwardsInput()); + + // Call & Assert + SetPropertyAndVerifyNotifcationsForCalculation(properties => properties.WaterLevelPolder = (RoundedDouble) 1, calculation); + } + + [Test] public void ToString_Always_ReturnEmptyString() { // Setup @@ -184,8 +217,8 @@ Assert.AreEqual(string.Empty, toString); } - private void SetPropertyAndVerifyNotifcationsForCalculation(Action setProperty, - MacroStabilityInwardsCalculation calculation) + private static void SetPropertyAndVerifyNotifcationsForCalculation(Action setProperty, + MacroStabilityInwardsCalculation calculation) { // Setup var mocks = new MockRepository(); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj =================================================================== diff -u -r79b21a40895beb5fd233c3e3cb20d82e6ab5be56 -r626da40a6865fc35d4a579b74e3f5cff3372b890 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision 79b21a40895beb5fd233c3e3cb20d82e6ab5be56) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision 626da40a6865fc35d4a579b74e3f5cff3372b890) @@ -68,6 +68,7 @@ +