Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs =================================================================== diff -u -r96764c996a0c059b15ccfd968ba165a0ede1b1e3 -r0950c1a469810e87b914ad0bc0cebbca32850a4e --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs (.../MacroStabilityInwardsSoilProfile2DLayersHelper.cs) (revision 96764c996a0c059b15ccfd968ba165a0ede1b1e3) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs (.../MacroStabilityInwardsSoilProfile2DLayersHelper.cs) (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -32,11 +32,11 @@ public static class MacroStabilityInwardsSoilProfile2DLayersHelper { /// - /// Method for obtaining all in recursively. + /// Method for obtaining all in recursively. /// /// The collection of layers to recursively get the layers from. /// An enumerable with . - /// Thrown when is null. + /// Thrown when is null. public static IEnumerable GetLayersRecursively(IEnumerable layers) { if (layers == null) Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r353cb6e4be6475bbbc9ec71d867582bf3e9cee7d -r0950c1a469810e87b914ad0bc0cebbca32850a4e --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 353cb6e4be6475bbbc9ec71d867582bf3e9cee7d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -1263,38 +1263,38 @@ } /// - /// Looks up a localized string similar to De geneste lagen binnen deze grondlaag.. + /// Looks up a localized string similar to De geometrie van de buitenring van deze grondlaag.. /// - public static string SoilLayer_NestedLayers_Description { + public static string SoilLayer_Geometry_Description { get { - return ResourceManager.GetString("SoilLayer_NestedLayers_Description", resourceCulture); + return ResourceManager.GetString("SoilLayer_Geometry_Description", resourceCulture); } } /// - /// Looks up a localized string similar to Geneste lagen. + /// Looks up a localized string similar to Geometrie. /// - public static string SoilLayer_NestedLayers_DisplayName { + public static string SoilLayer_Geometry_DisplayName { get { - return ResourceManager.GetString("SoilLayer_NestedLayers_DisplayName", resourceCulture); + return ResourceManager.GetString("SoilLayer_Geometry_DisplayName", resourceCulture); } } /// - /// Looks up a localized string similar to De geometrie van de buitenring van deze grondlaag.. + /// Looks up a localized string similar to De uitsneden binnen deze grondlaag.. /// - public static string SoilLayer_OuterRing_Description { + public static string SoilLayer_NestedLayers_Description { get { - return ResourceManager.GetString("SoilLayer_OuterRing_Description", resourceCulture); + return ResourceManager.GetString("SoilLayer_NestedLayers_Description", resourceCulture); } } /// - /// Looks up a localized string similar to Buitenring. + /// Looks up a localized string similar to Uitsneden. /// - public static string SoilLayer_OuterRing_DisplayName { + public static string SoilLayer_NestedLayers_DisplayName { get { - return ResourceManager.GetString("SoilLayer_OuterRing_DisplayName", resourceCulture); + return ResourceManager.GetString("SoilLayer_NestedLayers_DisplayName", resourceCulture); } } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx =================================================================== diff -u -r353cb6e4be6475bbbc9ec71d867582bf3e9cee7d -r0950c1a469810e87b914ad0bc0cebbca32850a4e --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 353cb6e4be6475bbbc9ec71d867582bf3e9cee7d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Properties/Resources.resx (.../Resources.resx) (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -524,16 +524,16 @@ Lengtemaat die uitdrukking geeft aan de afstand waarover de stijghoogte verloopt in de tussenzandlaag ter hoogte van het voorland. - De geneste lagen binnen deze grondlaag. + De uitsneden binnen deze grondlaag. - Geneste lagen + Uitsneden - + De geometrie van de buitenring van deze grondlaag. - - Buitenring + + Geometrie Eigenschappen van de zonering van het glijvlak. Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DBaseProperties.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DBaseProperties.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DBaseProperties.cs (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -0,0 +1,89 @@ +// 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 System.Linq; +using Core.Common.Base.Geometry; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Converters; +using Core.Common.Gui.PropertyBag; +using Core.Common.Utils.Attributes; +using Ringtoets.MacroStabilityInwards.Forms.Properties; +using Ringtoets.MacroStabilityInwards.Primitives; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.MacroStabilityInwards.Forms.PropertyClasses +{ + /// + /// Base ViewModel of for properties panel. + /// + [TypeConverter(typeof(ExpandableObjectConverter))] + public class MacroStabilityInwardsSoilLayer2DBaseProperties : ObjectProperties + { + /// + /// Creates a new instance of . + /// + /// The 2D soil layer for which the properties are shown. + /// Thrown when + /// is null. + public MacroStabilityInwardsSoilLayer2DBaseProperties(IMacroStabilityInwardsSoilLayer2D soilLayer) + { + if (soilLayer == null) + { + throw new ArgumentNullException(nameof(soilLayer)); + } + + Data = soilLayer; + } + + [PropertyOrder(1)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.SoilLayer_Name_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.SoilLayer_Name_Description))] + public string Name + { + get + { + return data.Data.MaterialName; + } + } + + [PropertyOrder(2)] + [ReadOnly(true)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [TypeConverter(typeof(ExpandableArrayConverter))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.SoilLayer_Geometry_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.SoilLayer_Geometry_Description))] + public Point2D[] Geometry + { + get + { + return data.OuterRing.Points.ToArray(); + } + } + + public override string ToString() + { + return data.Data.MaterialName; + } + } +} \ No newline at end of file Fisheye: Tag 0950c1a469810e87b914ad0bc0cebbca32850a4e refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DProperties.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DTopLevelProperties.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DTopLevelProperties.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DTopLevelProperties.cs (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -0,0 +1,74 @@ +// 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 System.Linq; +using Core.Common.Gui.Attributes; +using Core.Common.Gui.Converters; +using Core.Common.Utils.Attributes; +using Ringtoets.MacroStabilityInwards.Forms.Properties; +using Ringtoets.MacroStabilityInwards.Primitives; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.MacroStabilityInwards.Forms.PropertyClasses +{ + /// + /// ViewModel of a top level for properties panel. + /// + [TypeConverter(typeof(ExpandableObjectConverter))] + public class MacroStabilityInwardsSoilLayer2DTopLevelProperties : MacroStabilityInwardsSoilLayer2DBaseProperties + { + /// + /// Creates a new instance of for + /// the top level properties of a . + /// + /// The 2D soil layer for which the properties are shown. + /// Thrown when + /// is null. + public MacroStabilityInwardsSoilLayer2DTopLevelProperties(IMacroStabilityInwardsSoilLayer2D soilLayer) : base(soilLayer) {} + + [PropertyOrder(3)] + [TypeConverter(typeof(ExpandableArrayConverter))] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(Resources), nameof(Resources.SoilLayer_NestedLayers_DisplayName))] + [ResourcesDescription(typeof(Resources), nameof(Resources.SoilLayer_NestedLayers_Description))] + public MacroStabilityInwardsSoilLayer2DBaseProperties[] NestedLayers + { + get + { + return data.NestedLayers.Select(nestedLayer => new MacroStabilityInwardsSoilLayer2DBaseProperties(nestedLayer)).ToArray(); + } + } + + [PropertyOrder(4)] + [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] + [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.SoilLayer_IsAquifer_DisplayName))] + [ResourcesDescription(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.SoilLayer_IsAquifer_Description))] + public bool IsAquifer + { + get + { + return data.Data.IsAquifer; + } + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsStochasticSoilProfileProperties.cs =================================================================== diff -u -r59adecfc7f82ab8277440ecae147453f5cbddbbf -r0950c1a469810e87b914ad0bc0cebbca32850a4e --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsStochasticSoilProfileProperties.cs (.../MacroStabilityInwardsStochasticSoilProfileProperties.cs) (revision 59adecfc7f82ab8277440ecae147453f5cbddbbf) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsStochasticSoilProfileProperties.cs (.../MacroStabilityInwardsStochasticSoilProfileProperties.cs) (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -31,6 +31,7 @@ using Core.Common.Utils.Attributes; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; using Ringtoets.MacroStabilityInwards.Forms.Properties; +using Ringtoets.MacroStabilityInwards.Primitives; using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.MacroStabilityInwards.Forms.PropertyClasses @@ -102,13 +103,16 @@ [TypeConverter(typeof(ExpandableArrayConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.StochasticSoilProfile_Layers_DisplayName))] - public MacroStabilityInwardsSoilLayer2DProperties[] Layers2D + public MacroStabilityInwardsSoilLayer2DTopLevelProperties[] Layers2D { get { - IEnumerable macroStabilityInwardsSoilLayers2D = (data.SoilProfile as MacroStabilityInwardsSoilProfile2D)?.Layers; - return macroStabilityInwardsSoilLayers2D?.Select(layer => new MacroStabilityInwardsSoilLayer2DProperties(layer)).ToArray() ?? - new MacroStabilityInwardsSoilLayer2DProperties[0]; + IEnumerable layers = (data.SoilProfile as MacroStabilityInwardsSoilProfile2D)?.Layers; + IEnumerable macroStabilityInwardsSoilLayers2D = layers != null + ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers) + : new List(); + return macroStabilityInwardsSoilLayers2D?.Select(layer => new MacroStabilityInwardsSoilLayer2DTopLevelProperties(layer)).ToArray() ?? + new MacroStabilityInwardsSoilLayer2DTopLevelProperties[0]; } } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj =================================================================== diff -u -r353cb6e4be6475bbbc9ec71d867582bf3e9cee7d -r0950c1a469810e87b914ad0bc0cebbca32850a4e --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 353cb6e4be6475bbbc9ec71d867582bf3e9cee7d) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Ringtoets.MacroStabilityInwards.Forms.csproj (.../Ringtoets.MacroStabilityInwards.Forms.csproj) (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -50,6 +50,7 @@ + @@ -82,7 +83,7 @@ - + Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DBasePropertiesTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DBasePropertiesTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DBasePropertiesTest.cs (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -0,0 +1,158 @@ +// 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.Geometry; +using Core.Common.Gui.Converters; +using Core.Common.Gui.PropertyBag; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.Data.SoilProfile; +using Ringtoets.MacroStabilityInwards.Forms.PropertyClasses; +using Ringtoets.MacroStabilityInwards.Primitives; + +namespace Ringtoets.MacroStabilityInwards.Forms.Test.PropertyClasses +{ + public class MacroStabilityInwardsSoilLayer2DBasePropertiesTest + { + [Test] + public void Constructor_MacroStabilityInwardsSoilLayer2DNull_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new MacroStabilityInwardsSoilLayer2DBaseProperties(null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilLayer", exception.ParamName); + } + + [Test] + public void Constructor_ValidMacroStabilityInwardsSoilLayer2D_ExpectedValues() + { + // Setup + MacroStabilityInwardsSoilLayer2D soilLayer = CreateMacroStabilityInwardsSoilLayer2D(); + + // Call + var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(soilLayer); + + // Assert + Assert.IsInstanceOf>(properties); + TestHelper.AssertTypeConverter(nameof(MacroStabilityInwardsSoilLayer2DBaseProperties.Geometry)); + Assert.AreSame(soilLayer, properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var layer = new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(20.210230, 26.00001), + new Point2D(3.830, 1.040506) + }), + new Ring[0]) + { + Data = new MacroStabilityInwardsSoilLayerData + { + MaterialName = "Test Name", + IsAquifer = true + }, + NestedLayers = new[] + { + new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(12.987, 12.821), + new Point2D(4.23, 1.02) + }), new Ring[0]) + } + }; + + // Call + var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(layer); + + // Assert + Assert.AreEqual(layer.Data.MaterialName, properties.Name); + CollectionAssert.AreEqual(layer.OuterRing.Points, properties.Geometry); + } + + [Test] + public void ToString_Always_ReturnsMaterialName() + { + // Setup + MacroStabilityInwardsSoilLayer2D layer = CreateMacroStabilityInwardsSoilLayer2D(); + layer.Data.MaterialName = "Layer A 2D"; + + var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(layer); + + // Call + string name = properties.ToString(); + + // Assert + Assert.AreEqual(layer.Data.MaterialName, name); + } + + [Test] + public void Constructor_ValidData_PropertieshaveExpectedAttributeValues() + { + // Setup + MacroStabilityInwardsSoilLayer2D layer = CreateMacroStabilityInwardsSoilLayer2D(); + + // Call + var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(layer); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + + Assert.AreEqual(2, dynamicProperties.Count); + + const string generalCategoryName = "Algemeen"; + + PropertyDescriptor nameProperty = dynamicProperties[0]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategoryName, + "Naam", + "De naam van de grondlaag.", + true); + + PropertyDescriptor outerRingProperty = dynamicProperties[1]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(outerRingProperty, + generalCategoryName, + "Geometrie", + "De geometrie van de buitenring van deze grondlaag.", + true); + } + + private static MacroStabilityInwardsSoilLayer2D CreateMacroStabilityInwardsSoilLayer2D() + { + return new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(20.210230, 26.00001), + new Point2D(3.830, 1.040506) + }), + new Ring[0]) + { + Data = new MacroStabilityInwardsSoilLayerData() + }; + } + } +} \ No newline at end of file Fisheye: Tag 0950c1a469810e87b914ad0bc0cebbca32850a4e refers to a dead (removed) revision in file `Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DPropertiesTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DTopLevelPropertiesTest.cs =================================================================== diff -u --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DTopLevelPropertiesTest.cs (revision 0) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DTopLevelPropertiesTest.cs (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -0,0 +1,144 @@ +// 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.ComponentModel; +using System.Linq; +using Core.Common.Base.Geometry; +using Core.Common.Gui.Converters; +using Core.Common.TestUtil; +using NUnit.Framework; +using Ringtoets.MacroStabilityInwards.Data.SoilProfile; +using Ringtoets.MacroStabilityInwards.Forms.PropertyClasses; +using Ringtoets.MacroStabilityInwards.Primitives; + +namespace Ringtoets.MacroStabilityInwards.Forms.Test.PropertyClasses +{ + public class MacroStabilityInwardsSoilLayer2DTopLevelPropertiesTest + { + [Test] + public void Constructor_ValidMacroStabilityInwardsSoilLayer2D_ExpectedValues() + { + // Setup + MacroStabilityInwardsSoilLayer2D soilLayer = CreateMacroStabilityInwardsSoilLayer2D(); + + // Call + var properties = new MacroStabilityInwardsSoilLayer2DTopLevelProperties(soilLayer); + + // Assert + Assert.IsInstanceOf(properties); + TestHelper.AssertTypeConverter(nameof(MacroStabilityInwardsSoilLayer2DTopLevelProperties.NestedLayers)); + Assert.AreSame(soilLayer, properties.Data); + } + + [Test] + public void GetProperties_WithData_ReturnExpectedValues() + { + // Setup + var layer = new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(20.210230, 26.00001), + new Point2D(3.830, 1.040506) + }), + new Ring[0]) + { + Data = new MacroStabilityInwardsSoilLayerData + { + IsAquifer = true + }, + NestedLayers = new[] + { + new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(12.987, 12.821), + new Point2D(4.23, 1.02) + }), new Ring[0]) + } + }; + + // Call + var properties = new MacroStabilityInwardsSoilLayer2DTopLevelProperties(layer); + + // Assert + Assert.AreEqual(layer.Data.IsAquifer, properties.IsAquifer); + Assert.AreEqual(1, properties.NestedLayers.Length); + Assert.AreSame(layer.NestedLayers.Single(), properties.NestedLayers.Single().Data); + } + + [Test] + public void Constructor_ValidData_PropertieshaveExpectedAttributeValues() + { + // Setup + MacroStabilityInwardsSoilLayer2D layer = CreateMacroStabilityInwardsSoilLayer2D(); + + // Call + var properties = new MacroStabilityInwardsSoilLayer2DTopLevelProperties(layer); + + // Assert + PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); + + Assert.AreEqual(4, dynamicProperties.Count); + + const string generalCategoryName = "Algemeen"; + + PropertyDescriptor nameProperty = dynamicProperties[0]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nameProperty, + generalCategoryName, + "Naam", + "De naam van de grondlaag.", + true); + + PropertyDescriptor outerRingProperty = dynamicProperties[1]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(outerRingProperty, + generalCategoryName, + "Geometrie", + "De geometrie van de buitenring van deze grondlaag.", + true); + + PropertyDescriptor nestedLayersProperty = dynamicProperties[2]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(nestedLayersProperty, + generalCategoryName, + "Uitsneden", + "De uitsneden binnen deze grondlaag.", + true); + + PropertyDescriptor isAquiferProperty = dynamicProperties[3]; + PropertiesTestHelper.AssertRequiredPropertyDescriptorProperties(isAquiferProperty, + generalCategoryName, + "Is aquifer", + "Geeft aan of deze grondlaag een watervoerende laag betreft.", + true); + } + + private static MacroStabilityInwardsSoilLayer2D CreateMacroStabilityInwardsSoilLayer2D() + { + return new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(20.210230, 26.00001), + new Point2D(3.830, 1.040506) + }), + new Ring[0]) + { + Data = new MacroStabilityInwardsSoilLayerData() + }; + } + } +} \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs =================================================================== diff -u -r7585d2fd78627d94d55ffa16423af90a91e4efd4 -r0950c1a469810e87b914ad0bc0cebbca32850a4e --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs (.../MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs) (revision 7585d2fd78627d94d55ffa16423af90a91e4efd4) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs (.../MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs) (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -388,7 +388,10 @@ new Point2D(20.210230, 26.00001), new Point2D(3.830, 1.040506) }), - new Ring[0]); + new Ring[0]) + { + NestedLayers = new MacroStabilityInwardsSoilLayer2D[0] + }; } private class UnsupportedSoilProfile : IMacroStabilityInwardsSoilProfile Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj =================================================================== diff -u -r353cb6e4be6475bbbc9ec71d867582bf3e9cee7d -r0950c1a469810e87b914ad0bc0cebbca32850a4e --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision 353cb6e4be6475bbbc9ec71d867582bf3e9cee7d) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Ringtoets.MacroStabilityInwards.Forms.Test.csproj (.../Ringtoets.MacroStabilityInwards.Forms.Test.csproj) (revision 0950c1a469810e87b914ad0bc0cebbca32850a4e) @@ -76,13 +76,14 @@ + - +