Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsInput.cs =================================================================== diff -u -reb77464397a17cc0a006933b6d9bfeb5cfba3d66 -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsInput.cs (.../MacroStabilityInwardsInput.cs) (revision eb77464397a17cc0a006933b6d9bfeb5cfba3d66) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsInput.cs (.../MacroStabilityInwardsInput.cs) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -112,6 +112,8 @@ LeftGrid = new MacroStabilityInwardsGrid(); RightGrid = new MacroStabilityInwardsGrid(); + + CreateZones = true; } /// @@ -623,6 +625,22 @@ } } + /// + /// Gets or sets create zones. + /// + public bool CreateZones { get; set; } + + /// + /// Gets the automatic forbidden zones. + /// + public MacroStabilityInwardsZoningBoundariesDetermination AutomaticForbiddenZones + { + get + { + return MacroStabilityInwardsZoningBoundariesDetermination.Automatic; + } + } + #endregion } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsZoningBoundariesDetermination.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsZoningBoundariesDetermination.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/MacroStabilityInwardsZoningBoundariesDetermination.cs (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -0,0 +1,38 @@ +// 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 Core.Common.Utils.Attributes; +using Ringtoets.MacroStabilityInwards.Data.Properties; + +namespace Ringtoets.MacroStabilityInwards.Data +{ + /// + /// The zoning boundaries determination types. + /// + public enum MacroStabilityInwardsZoningBoundariesDetermination + { + [ResourcesDisplayName(typeof(Resources), nameof(Resources.Automatic_DisplayName))] + Automatic = 1, + + [ResourcesDisplayName(typeof(Resources), nameof(Resources.Manual_DisplayName))] + Manual = 2 + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj =================================================================== diff -u -r378756fb27984abc7c2fdf13650b5b1700f94917 -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision 378756fb27984abc7c2fdf13650b5b1700f94917) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/Ringtoets.MacroStabilityInwards.Data.csproj (.../Ringtoets.MacroStabilityInwards.Data.csproj) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -51,6 +51,7 @@ + True Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r82e52ce72856fab42af51e186cb8c48f0a45cc30 -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 82e52ce72856fab42af51e186cb8c48f0a45cc30) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -100,6 +100,24 @@ } /// + /// Looks up a localized string similar to Zoneringsgrenzen automatisch bepalen of handmatig invoeren?. + /// + public static string AutomaticForbiddenZones_Description { + get { + return ResourceManager.GetString("AutomaticForbiddenZones_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Methode. + /// + public static string AutomaticForbiddenZones_DisplayName { + get { + return ResourceManager.GetString("AutomaticForbiddenZones_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Grid. /// public static string Categories_Grid { @@ -127,6 +145,24 @@ } /// + /// Looks up a localized string similar to Gebruik zoneringsgrenzen bij het bepalen van het intredepunt van het glijvlak?. + /// + public static string CreateZones_Description { + get { + return ResourceManager.GetString("CreateZones_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Bepaling. + /// + public static string CreateZones_DisplayName { + get { + return ResourceManager.GetString("CreateZones_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Dijktype van de geschematiseerde dijk.. /// public static string DikeSoilScenario_Description { @@ -963,6 +999,24 @@ } /// + /// Looks up a localized string similar to Eigenschappen van de zonering glijvlak.. + /// + public static string SlipPlaneSettings_Description { + get { + return ResourceManager.GetString("SlipPlaneSettings_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Zonering glijvlak. + /// + public static string SlipPlaneSettings_DisplayName { + get { + return ResourceManager.GetString("SlipPlaneSettings_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to De binnenringen van deze grondlaag.. /// public static string SoilLayer_Holes_Description { Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx =================================================================== diff -u -r82e52ce72856fab42af51e186cb8c48f0a45cc30 -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 82e52ce72856fab42af51e186cb8c48f0a45cc30) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -508,4 +508,22 @@ Buitenring + + Eigenschappen van de zonering glijvlak. + + + Zonering glijvlak + + + Zoneringsgrenzen automatisch bepalen of handmatig invoeren? + + + Methode + + + Gebruik zoneringsgrenzen bij het bepalen van het intredepunt van het glijvlak? + + + Bepaling + \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsInputContextProperties.cs =================================================================== diff -u -r78382ec129ddc7537096860680cef36f3796700d -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsInputContextProperties.cs (.../MacroStabilityInwardsInputContextProperties.cs) (revision 78382ec129ddc7537096860680cef36f3796700d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsInputContextProperties.cs (.../MacroStabilityInwardsInputContextProperties.cs) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -34,7 +34,6 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Forms.PropertyClasses; using Ringtoets.Common.Forms.UITypeEditors; -using Ringtoets.MacroStabilityInwards.Data; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; using Ringtoets.MacroStabilityInwards.Forms.PresentationObjects; using Ringtoets.MacroStabilityInwards.Forms.Properties; @@ -62,7 +61,8 @@ private const int slipPlaneMinimumDepthPropertyIndex = 9; private const int slipPlaneMinimumLengthPropertyIndex = 10; private const int maximumSliceWidthPropertyIndex = 11; - private const int gridSettingsPropertyIndex = 12; + private const int slipPlaneSettingsPropertyIndex = 12; + private const int gridSettingsPropertyIndex = 13; private const int hydraulicCategoryIndex = 1; private const int schematizationCategoryIndex = 2; @@ -365,6 +365,19 @@ } } + [PropertyOrder(slipPlaneSettingsPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Settings), settingsCategoryIndex, totalCategoryCount)] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.SlipPlaneSettings_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.SlipPlaneSettings_Description))] + [TypeConverter(typeof(ExpandableObjectConverter))] + public MacroStabilityInwardsSlipPlaneSettingsProperties SlipPlaneSettings + { + get + { + return new MacroStabilityInwardsSlipPlaneSettingsProperties(data.WrappedData, propertyChangeHandler); + } + } + [PropertyOrder(gridSettingsPropertyIndex)] [ResourcesCategory(typeof(Resources), nameof(Resources.Categories_Settings), settingsCategoryIndex, totalCategoryCount)] [ResourcesDisplayName(typeof(Resources), nameof(Resources.GridSettings_DisplayName))] Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsProperties.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsProperties.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsProperties.cs (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -0,0 +1,101 @@ +// 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.Gui.Attributes; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils; +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 slip plane settings properties in for properties panel. + /// + public class MacroStabilityInwardsSlipPlaneSettingsProperties : ObjectProperties + { + private const int createZonesPropertyIndex = 1; + private const int automaticForbiddenZonesPropertyIndex = 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 MacroStabilityInwardsSlipPlaneSettingsProperties(MacroStabilityInwardsInput data, IObservablePropertyChangeHandler handler) + { + if (data == null) + { + throw new ArgumentNullException(nameof(data)); + } + if (handler == null) + { + throw new ArgumentNullException(nameof(handler)); + } + + Data = data; + propertyChangeHandler = handler; + } + + [PropertyOrder(createZonesPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.SlipPlaneSettings_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.CreateZones_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.CreateZones_Description))] + public bool CreateZones + { + get + { + return data.CreateZones; + } + set + { + PropertyChangeHelper.ChangePropertyAndNotify(() => data.CreateZones = value, propertyChangeHandler); + } + } + + [PropertyOrder(automaticForbiddenZonesPropertyIndex)] + [ResourcesCategory(typeof(Resources), nameof(Resources.SlipPlaneSettings_DisplayName))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.AutomaticForbiddenZones_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.AutomaticForbiddenZones_Description))] + [TypeConverter(typeof(EnumTypeConverter))] + public MacroStabilityInwardsZoningBoundariesDetermination AutomaticForbiddenZones + { + get + { + return data.AutomaticForbiddenZones; + } + } + + public override string ToString() + { + return string.Empty; + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj =================================================================== diff -u -rd04fe66045d6183879fd4e70bab196d127039350 -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision d04fe66045d6183879fd4e70bab196d127039350) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -72,6 +72,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsInputTest.cs =================================================================== diff -u -rf2ba7f68f5de2fc3c8dec8baf7326808120cee52 -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsInputTest.cs (.../MacroStabilityInwardsInputTest.cs) (revision f2ba7f68f5de2fc3c8dec8baf7326808120cee52) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsInputTest.cs (.../MacroStabilityInwardsInputTest.cs) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -137,6 +137,9 @@ Assert.IsNotNull(inputParameters.LeftGrid); Assert.IsNotNull(inputParameters.RightGrid); + + Assert.IsTrue(inputParameters.CreateZones); + Assert.AreEqual(MacroStabilityInwardsZoningBoundariesDetermination.Automatic, inputParameters.AutomaticForbiddenZones); } [Test] Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsZoningBoundariesDeterminationTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsZoningBoundariesDeterminationTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/MacroStabilityInwardsZoningBoundariesDeterminationTest.cs (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -0,0 +1,63 @@ +// 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.Collections.Generic; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Ringtoets.MacroStabilityInwards.Data.Test +{ + [TestFixture] + public class MacroStabilityInwardsZoningBoundariesDeterminationTest : EnumTestFixture + { + protected override IDictionary ExpectedDisplayNameForEnumValues + { + get + { + return new Dictionary + { + { + MacroStabilityInwardsZoningBoundariesDetermination.Automatic, "Automatisch" + }, + { + MacroStabilityInwardsZoningBoundariesDetermination.Manual, "Handmatig" + } + }; + } + } + + protected override IDictionary ExpectedValueForEnumValues + { + get + { + return new Dictionary + { + { + MacroStabilityInwardsZoningBoundariesDetermination.Automatic, 1 + }, + { + MacroStabilityInwardsZoningBoundariesDetermination.Manual, 2 + } + }; + } + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj =================================================================== diff -u -r378756fb27984abc7c2fdf13650b5b1700f94917 -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 378756fb27984abc7c2fdf13650b5b1700f94917) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/Ringtoets.MacroStabilityInwards.Data.Test.csproj (.../Ringtoets.MacroStabilityInwards.Data.Test.csproj) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -70,6 +70,7 @@ + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs =================================================================== diff -u -rf2ba7f68f5de2fc3c8dec8baf7326808120cee52 -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision f2ba7f68f5de2fc3c8dec8baf7326808120cee52) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsInputContextPropertiesTest.cs (.../MacroStabilityInwardsInputContextPropertiesTest.cs) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -62,7 +62,8 @@ private const int expectedSlipPlaneMinimumDepthPropertyIndex = 8; private const int expectedSlipPlaneMinimumLengthPropertyIndex = 9; private const int expectedMaximumSliceWidthPropertyIndex = 10; - private const int expectedGridSettingsPropertyIndex = 11; + private const int expectedSlipPlaneSettingsPropertyIndex = 11; + private const int expectedGridSettingsPropertyIndex = 12; [Test] public void Constructor_DataNull_ThrowArgumentNullException() @@ -165,7 +166,7 @@ // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); - Assert.AreEqual(12, dynamicProperties.Count); + Assert.AreEqual(13, dynamicProperties.Count); const string hydraulicDataCategory = "\t\tHydraulische gegevens"; const string schematizationCategory = "\tSchematisatie"; @@ -254,6 +255,16 @@ "Maximale lamelbreedte [m]", "Maximale breedte van een lamel."); + PropertyDescriptor slipPlaneSettingsProperty = dynamicProperties[expectedSlipPlaneSettingsPropertyIndex]; + TestHelper.AssertTypeConverter( + nameof(MacroStabilityInwardsInputContextProperties.SlipPlaneSettings)); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + slipPlaneSettingsProperty, + settingsCategory, + "Zonering glijvlak", + "Eigenschappen van de zonering glijvlak.", + true); + PropertyDescriptor gridSettingsProperty = dynamicProperties[expectedGridSettingsPropertyIndex]; TestHelper.AssertTypeConverter( nameof(MacroStabilityInwardsInputContextProperties.GridSettings)); @@ -301,7 +312,7 @@ const string hydraulicDataCategory = "\t\tHydraulische gegevens"; if (!useManualAssessmentLevelInput) { - Assert.AreEqual(12, dynamicProperties.Count); + Assert.AreEqual(13, dynamicProperties.Count); PropertyDescriptor hydraulicBoundaryLocationProperty = dynamicProperties[expectedSelectedHydraulicBoundaryLocationPropertyIndex]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( @@ -320,7 +331,7 @@ } else { - Assert.AreEqual(11, dynamicProperties.Count); + Assert.AreEqual(12, dynamicProperties.Count); PropertyDescriptor assessmentLevelProperty = dynamicProperties[0]; PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( @@ -401,6 +412,8 @@ Assert.AreSame(inputParameters, properties.GridSettings.Data); + Assert.AreSame(inputParameters, properties.SlipPlaneSettings.Data); + mocks.VerifyAll(); } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsPropertiesTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsPropertiesTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSlipPlaneSettingsPropertiesTest.cs (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -0,0 +1,214 @@ +// 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.Gui.PropertyBag; +using Core.Common.TestUtil; +using Core.Common.Utils; +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 MacroStabilityInwardsSlipPlaneSettingsPropertiesTest + { + private const int expectedCreateZonesPropertyIndex = 0; + private const int expectedAutomaticForbiddenZonesPropertyIndex = 1; + + [Test] + public void Constructor_ExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(); + + // Call + var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(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 MacroStabilityInwardsSlipPlaneSettingsProperties(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 MacroStabilityInwardsSlipPlaneSettingsProperties(new MacroStabilityInwardsInput(), + 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(); + + // Call + var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + + Assert.AreEqual(2, dynamicProperties.Count); + + const string category = "Zonering glijvlak"; + + PropertyDescriptor createZonesProperty = dynamicProperties[expectedCreateZonesPropertyIndex]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + createZonesProperty, + category, + "Bepaling", + "Gebruik zoneringsgrenzen bij het bepalen van het intredepunt van het glijvlak?"); + + PropertyDescriptor automaticForbiddenZonesProperty = dynamicProperties[expectedAutomaticForbiddenZonesPropertyIndex]; + TestHelper.AssertTypeConverter(nameof(properties.AutomaticForbiddenZones)); + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties( + automaticForbiddenZonesProperty, + category, + "Methode", + "Zoneringsgrenzen automatisch bepalen of handmatig invoeren?", + true); + + mocks.VerifyAll(); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(); + + // Call + var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); + + // Assert + Assert.AreEqual(input.CreateZones, properties.CreateZones); + Assert.AreEqual(input.AutomaticForbiddenZones, properties.AutomaticForbiddenZones); + mocks.VerifyAll(); + } + + [Test] + public void GivenPropertiesWithData_WhenChangingProperties_ThenPropertiesSetOnInput() + { + // Given + var calculationItem = new MacroStabilityInwardsCalculationScenario(); + MacroStabilityInwardsInput input = calculationItem.InputParameters; + + var handler = new ObservablePropertyChangeHandler(calculationItem, input); + var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, handler); + + var random = new Random(); + bool createZones = random.NextBoolean(); + + // When + properties.CreateZones = createZones; + + // Then + Assert.AreEqual(createZones, input.CreateZones); + } + + [Test] + public void CreateZones_SetValidValue_SetsValueAndUpdatesObservers() + { + // Setup + var mocks = new MockRepository(); + var observable = mocks.StrictMock(); + observable.Expect(o => o.NotifyObservers()); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(); + + var handler = new SetPropertyValueAfterConfirmationParameterTester(new[] + { + observable + }); + + var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, handler); + + // Call + properties.CreateZones = false; + + // Assert + Assert.IsTrue(handler.Called); + mocks.VerifyAll(); + } + + [Test] + public void ToString_Always_ReturnEmptyString() + { + // Setup + var mocks = new MockRepository(); + var changeHandler = mocks.Stub(); + mocks.ReplayAll(); + + var input = new MacroStabilityInwardsInput(); + var properties = new MacroStabilityInwardsSlipPlaneSettingsProperties(input, changeHandler); + + // Call + string toString = properties.ToString(); + + // Assert + Assert.AreEqual(string.Empty, toString); + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj =================================================================== diff -u -rf2ba7f68f5de2fc3c8dec8baf7326808120cee52 -r4e00271fd762917c0ce059fe0697e607ed0065fb --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision f2ba7f68f5de2fc3c8dec8baf7326808120cee52) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision 4e00271fd762917c0ce059fe0697e607ed0065fb) @@ -74,6 +74,7 @@ +