Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer1DProperties.cs =================================================================== diff -u -ra1eaf8e666afb92642d3efc6877c8e5ac0bdf455 -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer1DProperties.cs (.../MacroStabilityInwardsSoilLayer1DProperties.cs) (revision a1eaf8e666afb92642d3efc6877c8e5ac0bdf455) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer1DProperties.cs (.../MacroStabilityInwardsSoilLayer1DProperties.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.ComponentModel; using System.Globalization; using Core.Common.Base.Data; @@ -36,6 +37,22 @@ [TypeConverter(typeof(ExpandableObjectConverter))] public class MacroStabilityInwardsSoilLayer1DProperties : ObjectProperties { + /// + /// Creates a new instance of . + /// + /// The 1D soil layer for which the properties are shown. + /// Thrown when + /// is null. + public MacroStabilityInwardsSoilLayer1DProperties(MacroStabilityInwardsSoilLayer1D 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))] Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DProperties.cs =================================================================== diff -u -ra1eaf8e666afb92642d3efc6877c8e5ac0bdf455 -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DProperties.cs (.../MacroStabilityInwardsSoilLayer2DProperties.cs) (revision a1eaf8e666afb92642d3efc6877c8e5ac0bdf455) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DProperties.cs (.../MacroStabilityInwardsSoilLayer2DProperties.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // 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; @@ -38,6 +39,22 @@ [TypeConverter(typeof(ExpandableObjectConverter))] public class MacroStabilityInwardsSoilLayer2DProperties : ObjectProperties { + /// + /// Creates a new instance of . + /// + /// The 2D soil layer for which the properties are shown. + /// Thrown when + /// is null. + public MacroStabilityInwardsSoilLayer2DProperties(MacroStabilityInwardsSoilLayer2D 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))] @@ -74,10 +91,7 @@ { get { - return data.Holes.Select(ring => new RingProperties - { - Data = ring - }).ToArray(); + return data.Holes.Select(ring => new RingProperties(ring)).ToArray(); } } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/RingProperties.cs =================================================================== diff -u -ra1eaf8e666afb92642d3efc6877c8e5ac0bdf455 -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/RingProperties.cs (.../RingProperties.cs) (revision a1eaf8e666afb92642d3efc6877c8e5ac0bdf455) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/RingProperties.cs (.../RingProperties.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // 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; @@ -36,6 +37,22 @@ [TypeConverter(typeof(ExpandableObjectConverter))] public class RingProperties : ObjectProperties { + /// + /// Creates a new instance of . + /// + /// The ring for which the properties are shown. + /// Thrown when + /// is null. + public RingProperties(Ring ring) + { + if (ring == null) + { + throw new ArgumentNullException(nameof(ring)); + } + + Data = ring; + } + [TypeConverter(typeof(ExpandableArrayConverter))] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Geometry_DisplayName))] Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/StochasticSoilModelProperties.cs =================================================================== diff -u -ra1eaf8e666afb92642d3efc6877c8e5ac0bdf455 -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/StochasticSoilModelProperties.cs (.../StochasticSoilModelProperties.cs) (revision a1eaf8e666afb92642d3efc6877c8e5ac0bdf455) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/StochasticSoilModelProperties.cs (.../StochasticSoilModelProperties.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // 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; @@ -36,6 +37,22 @@ /// public class StochasticSoilModelProperties : ObjectProperties { + /// + /// Creates a new instance of . + /// + /// The stochastic soil model for which the properties are shown. + /// Thrown when + /// is null. + public StochasticSoilModelProperties(MacroStabilityInwardsStochasticSoilModel stochasticSoilModel) + { + if (stochasticSoilModel == null) + { + throw new ArgumentNullException(nameof(stochasticSoilModel)); + } + + Data = stochasticSoilModel; + } + [PropertyOrder(1)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.StochasticSoilModel_Name_DisplayName))] @@ -71,10 +88,7 @@ get { return data.StochasticSoilProfiles.Count > 0 - ? data.StochasticSoilProfiles.Select(ssp => new StochasticSoilProfileProperties - { - Data = ssp - }).ToArray() + ? data.StochasticSoilProfiles.Select(ssp => new StochasticSoilProfileProperties(ssp)).ToArray() : new StochasticSoilProfileProperties[0]; } } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/StochasticSoilProfileProperties.cs =================================================================== diff -u -ra1eaf8e666afb92642d3efc6877c8e5ac0bdf455 -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/StochasticSoilProfileProperties.cs (.../StochasticSoilProfileProperties.cs) (revision a1eaf8e666afb92642d3efc6877c8e5ac0bdf455) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/StochasticSoilProfileProperties.cs (.../StochasticSoilProfileProperties.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -42,6 +42,22 @@ [TypeConverter(typeof(ExpandableObjectConverter))] public class StochasticSoilProfileProperties : ObjectProperties { + /// + /// Creates a new instance of . + /// + /// The stochastic soil profile for which the properties are shown. + /// Thrown when + /// is null. + public StochasticSoilProfileProperties(MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile) + { + if (stochasticSoilProfile == null) + { + throw new ArgumentNullException(nameof(stochasticSoilProfile)); + } + + Data = stochasticSoilProfile; + } + [PropertyOrder(1)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [ResourcesDisplayName(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.StochasticSoilProfile_Name_DisplayName))] @@ -76,14 +92,7 @@ get { IEnumerable macroStabilityInwardsSoilLayers1D = (data.SoilProfile as MacroStabilityInwardsSoilProfile1D)?.Layers; - if (macroStabilityInwardsSoilLayers1D != null) - { - return macroStabilityInwardsSoilLayers1D.Select(layer => new MacroStabilityInwardsSoilLayer1DProperties - { - Data = layer - }).ToArray(); - } - return new MacroStabilityInwardsSoilLayer1DProperties[0]; + return macroStabilityInwardsSoilLayers1D?.Select(layer => new MacroStabilityInwardsSoilLayer1DProperties(layer)).ToArray() ?? new MacroStabilityInwardsSoilLayer1DProperties[0]; } } @@ -97,14 +106,7 @@ get { IEnumerable macroStabilityInwardsSoilLayers2D = (data.SoilProfile as MacroStabilityInwardsSoilProfile2D)?.Layers; - if (macroStabilityInwardsSoilLayers2D != null) - { - return macroStabilityInwardsSoilLayers2D.Select(layer => new MacroStabilityInwardsSoilLayer2DProperties - { - Data = layer - }).ToArray(); - } - return new MacroStabilityInwardsSoilLayer2DProperties[0]; + return macroStabilityInwardsSoilLayers2D?.Select(layer => new MacroStabilityInwardsSoilLayer2DProperties(layer)).ToArray() ?? new MacroStabilityInwardsSoilLayer2DProperties[0]; } } Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer1DPropertiesTest.cs =================================================================== diff -u -r1670a1ee74bd23ba9315ed1a49c0662dae4f072f -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer1DPropertiesTest.cs (.../MacroStabilityInwardsSoilLayer1DPropertiesTest.cs) (revision 1670a1ee74bd23ba9315ed1a49c0662dae4f072f) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer1DPropertiesTest.cs (.../MacroStabilityInwardsSoilLayer1DPropertiesTest.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.ComponentModel; using System.Globalization; using Core.Common.Gui.PropertyBag; @@ -32,14 +33,28 @@ public class MacroStabilityInwardsSoilLayer1DPropertiesTest { [Test] - public void DefaultConstructor_ExpectedValues() + public void Constructor_MacroStabilityInwardsSoilLayer1DNull_ThrowsArgumentNullException() { // Call - var properties = new MacroStabilityInwardsSoilLayer1DProperties(); + TestDelegate test = () => new MacroStabilityInwardsSoilLayer1DProperties(null); // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilLayer", exception.ParamName); + } + + [Test] + public void Constructor_ValidMacroStabilityInwardsSoilLayer1D_ExpectedValues() + { + // Setup + var soilLayer = new MacroStabilityInwardsSoilLayer1D(2.0); + + // Call + var properties = new MacroStabilityInwardsSoilLayer1DProperties(soilLayer); + + // Assert Assert.IsInstanceOf>(properties); - Assert.IsNull(properties.Data); + Assert.AreSame(soilLayer, properties.Data); } [Test] @@ -56,10 +71,7 @@ }; // Call - var properties = new MacroStabilityInwardsSoilLayer1DProperties - { - Data = layer - }; + var properties = new MacroStabilityInwardsSoilLayer1DProperties(layer); // Assert Assert.AreEqual("Test Name", properties.Name); @@ -79,10 +91,8 @@ } }; - var properties = new MacroStabilityInwardsSoilLayer1DProperties - { - Data = layer - }; + var properties = new MacroStabilityInwardsSoilLayer1DProperties(layer); + // Call string name = properties.ToString(); @@ -104,10 +114,7 @@ }; // Call - var properties = new MacroStabilityInwardsSoilLayer1DProperties - { - Data = layer - }; + var properties = new MacroStabilityInwardsSoilLayer1DProperties(layer); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DPropertiesTest.cs =================================================================== diff -u -r1670a1ee74bd23ba9315ed1a49c0662dae4f072f -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DPropertiesTest.cs (.../MacroStabilityInwardsSoilLayer2DPropertiesTest.cs) (revision 1670a1ee74bd23ba9315ed1a49c0662dae4f072f) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DPropertiesTest.cs (.../MacroStabilityInwardsSoilLayer2DPropertiesTest.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // 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; @@ -34,14 +35,33 @@ public class MacroStabilityInwardsSoilLayer2DPropertiesTest { [Test] - public void DefaultConstructor_ExpectedValues() + public void Constructor_MacroStabilityInwardsSoilLayer2DNull_ThrowsArgumentNullException() { // Call - var properties = new MacroStabilityInwardsSoilLayer2DProperties(); + TestDelegate test = () => new MacroStabilityInwardsSoilLayer2DProperties(null); // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilLayer", exception.ParamName); + } + + [Test] + public void Constructor_ValidMacroStabilityInwardsSoilLayer2D_ExpectedValues() + { + // Setup + var soilLayer = new MacroStabilityInwardsSoilLayer2D(new Ring(new[] + { + new Point2D(20.210230, 26.00001), + new Point2D(3.830, 1.040506) + }), + new Ring[0]); + + // Call + var properties = new MacroStabilityInwardsSoilLayer2DProperties(soilLayer); + + // Assert Assert.IsInstanceOf>(properties); - Assert.IsNull(properties.Data); + Assert.AreSame(soilLayer, properties.Data); } [Test] @@ -70,10 +90,7 @@ }; // Call - var properties = new MacroStabilityInwardsSoilLayer2DProperties - { - Data = layer - }; + var properties = new MacroStabilityInwardsSoilLayer2DProperties(layer); // Assert Assert.AreEqual("Test Name", properties.Name); @@ -103,10 +120,8 @@ } }; - var properties = new MacroStabilityInwardsSoilLayer2DProperties - { - Data = layer - }; + var properties = new MacroStabilityInwardsSoilLayer2DProperties(layer); + // Call string name = properties.ToString(); @@ -132,10 +147,7 @@ }; // Call - var properties = new MacroStabilityInwardsSoilLayer2DProperties - { - Data = layer - }; + var properties = new MacroStabilityInwardsSoilLayer2DProperties(layer); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/RingPropertiesTest.cs =================================================================== diff -u -r5d00e46dbca617ca3c297bff76dc7cc63211b9de -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/RingPropertiesTest.cs (.../RingPropertiesTest.cs) (revision 5d00e46dbca617ca3c297bff76dc7cc63211b9de) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/RingPropertiesTest.cs (.../RingPropertiesTest.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // 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; @@ -33,14 +34,32 @@ public class RingPropertiesTest { [Test] - public void DefaultConstructor_ExpectedValues() + public void Constructor_RingNull_ThrowsArgumentNullException() { // Call - var properties = new RingProperties(); + TestDelegate test = () => new RingProperties(null); // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("ring", exception.ParamName); + } + + [Test] + public void Constructor_ValidRing_ExpectedValues() + { + // Setup + var ring = new Ring(new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + }); + + // Call + var properties = new RingProperties(ring); + + // Assert Assert.IsInstanceOf>(properties); - Assert.IsNull(properties.Data); + Assert.AreSame(ring, properties.Data); } [Test] @@ -54,10 +73,7 @@ }); // Call - var properties = new RingProperties - { - Data = ring - }; + var properties = new RingProperties(ring); // Assert TestHelper.AssertTypeConverter(nameof(RingProperties.Geometry)); @@ -75,10 +91,8 @@ new Point2D(1, 1) }); - var properties = new RingProperties - { - Data = ring - }; + var properties = new RingProperties(ring); + // Call string name = properties.ToString(); @@ -97,10 +111,7 @@ }); // Call - var properties = new RingProperties - { - Data = ring - }; + var properties = new RingProperties(ring); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/StochasticSoilModelPropertiesTest.cs =================================================================== diff -u -r78382ec129ddc7537096860680cef36f3796700d -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/StochasticSoilModelPropertiesTest.cs (.../StochasticSoilModelPropertiesTest.cs) (revision 78382ec129ddc7537096860680cef36f3796700d) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/StochasticSoilModelPropertiesTest.cs (.../StochasticSoilModelPropertiesTest.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.ComponentModel; using Core.Common.Base.Geometry; @@ -39,14 +40,28 @@ private const int stochasticSoilModelStochasticSoilProfilesPropertyIndex = 2; [Test] - public void DefaultConstructor_ExpectedValues() + public void Constructor_StochasticSoilModelNull_ThrowsArgumentNullException() { // Call - var properties = new StochasticSoilModelProperties(); + TestDelegate test = () => new StochasticSoilModelProperties(null); // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochasticSoilModel", exception.ParamName); + } + + [Test] + public void Constructor_ValidStochasticSoilModel_ExpectedValues() + { + // Setup + var stochasticSoilModel = new MacroStabilityInwardsStochasticSoilModel("model"); + + // Call + var properties = new StochasticSoilModelProperties(stochasticSoilModel); + + // Assert Assert.IsInstanceOf>(properties); - Assert.IsNull(properties.Data); + Assert.AreSame(stochasticSoilModel, properties.Data); } [Test] @@ -66,10 +81,7 @@ stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); // Call - var properties = new StochasticSoilModelProperties - { - Data = stochasticSoilModel - }; + var properties = new StochasticSoilModelProperties(stochasticSoilModel); // Assert Assert.AreEqual(stochasticSoilModel.Name, properties.Name); @@ -96,10 +108,7 @@ stochasticSoilModel.StochasticSoilProfiles.Add(stochasticSoilProfile); // Call - var properties = new StochasticSoilModelProperties - { - Data = stochasticSoilModel - }; + var properties = new StochasticSoilModelProperties(stochasticSoilModel); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/StochasticSoilProfilePropertiesTest.cs =================================================================== diff -u -r1670a1ee74bd23ba9315ed1a49c0662dae4f072f -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/StochasticSoilProfilePropertiesTest.cs (.../StochasticSoilProfilePropertiesTest.cs) (revision 1670a1ee74bd23ba9315ed1a49c0662dae4f072f) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/StochasticSoilProfilePropertiesTest.cs (.../StochasticSoilProfilePropertiesTest.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.Collections.Generic; using System.ComponentModel; using System.Globalization; @@ -39,14 +40,28 @@ private const string generalCategoryName = "Algemeen"; [Test] - public void DefaultConstructor_ExpectedValues() + public void Constructor_StochasticSoilProfileNull_ThrowsArgumentNullException() { // Call - var properties = new StochasticSoilProfileProperties(); + TestDelegate test = () => new StochasticSoilProfileProperties(null); // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("stochasticSoilProfile", exception.ParamName); + } + + [Test] + public void Constructor_ValidStochasticSoilProfile_ExpectedValues() + { + // Setup + var stochasticSoilProfile = new MacroStabilityInwardsStochasticSoilProfile(1.0, SoilProfileType.SoilProfile2D, 1234L); + + // Call + var properties = new StochasticSoilProfileProperties(stochasticSoilProfile); + + // Assert Assert.IsInstanceOf>(properties); - Assert.IsNull(properties.Data); + Assert.AreSame(stochasticSoilProfile, properties.Data); } [Test] @@ -103,10 +118,7 @@ { SoilProfile = soilProfile }; - var properties = new StochasticSoilProfileProperties - { - Data = stochasticSoilProfile - }; + var properties = new StochasticSoilProfileProperties(stochasticSoilProfile); // Call bool bottomVisible = properties.DynamicVisibleValidationMethod("Bottom"); @@ -137,10 +149,7 @@ { SoilProfile = soilProfile }; - var properties = new StochasticSoilProfileProperties - { - Data = stochasticSoilProfile - }; + var properties = new StochasticSoilProfileProperties(stochasticSoilProfile); // Call bool bottomVisible = properties.DynamicVisibleValidationMethod("Bottom"); @@ -167,10 +176,7 @@ }; // Call - var properties = new StochasticSoilProfileProperties - { - Data = stochasticSoilProfile - }; + var properties = new StochasticSoilProfileProperties(stochasticSoilProfile); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -231,10 +237,7 @@ }; // Call - var properties = new StochasticSoilProfileProperties - { - Data = stochasticSoilProfile - }; + var properties = new StochasticSoilProfileProperties(stochasticSoilProfile); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties); @@ -302,10 +305,7 @@ }; // Call - var properties = new StochasticSoilProfileProperties - { - Data = stochasticSoilProfile - }; + var properties = new StochasticSoilProfileProperties(stochasticSoilProfile); // Assert Assert.AreEqual(expectedName, properties.Name); @@ -364,10 +364,7 @@ }; // Call - var properties = new StochasticSoilProfileProperties - { - Data = stochasticSoilProfile - }; + var properties = new StochasticSoilProfileProperties(stochasticSoilProfile); // Assert Assert.AreEqual(expectedName, properties.Name); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingSoilLayerProperties.cs =================================================================== diff -u -ra1eaf8e666afb92642d3efc6877c8e5ac0bdf455 -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingSoilLayerProperties.cs (.../PipingSoilLayerProperties.cs) (revision a1eaf8e666afb92642d3efc6877c8e5ac0bdf455) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingSoilLayerProperties.cs (.../PipingSoilLayerProperties.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.ComponentModel; using System.Globalization; using Core.Common.Base.Data; @@ -36,6 +37,22 @@ [TypeConverter(typeof(ExpandableObjectConverter))] public class PipingSoilLayerProperties : ObjectProperties { + /// + /// Creates a new instance of . + /// + /// The soil layer for which the properties are shown. + /// Thrown when + /// is null. + public PipingSoilLayerProperties(PipingSoilLayer 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))] Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilProfileProperties.cs =================================================================== diff -u -ra1eaf8e666afb92642d3efc6877c8e5ac0bdf455 -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilProfileProperties.cs (.../PipingStochasticSoilProfileProperties.cs) (revision a1eaf8e666afb92642d3efc6877c8e5ac0bdf455) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/PropertyClasses/PipingStochasticSoilProfileProperties.cs (.../PipingStochasticSoilProfileProperties.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -91,10 +91,7 @@ get { IEnumerable pipingSoilLayers = data.SoilProfile.Layers; - return pipingSoilLayers.Select(layer => new PipingSoilLayerProperties - { - Data = layer - }).ToArray(); + return pipingSoilLayers.Select(layer => new PipingSoilLayerProperties(layer)).ToArray(); } } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingSoilLayerPropertiesTest.cs =================================================================== diff -u -ra1eaf8e666afb92642d3efc6877c8e5ac0bdf455 -r8d95e188fa8b69e29e776e86411988f4d97ea172 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingSoilLayerPropertiesTest.cs (.../PipingSoilLayerPropertiesTest.cs) (revision a1eaf8e666afb92642d3efc6877c8e5ac0bdf455) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/PropertyClasses/PipingSoilLayerPropertiesTest.cs (.../PipingSoilLayerPropertiesTest.cs) (revision 8d95e188fa8b69e29e776e86411988f4d97ea172) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using System.ComponentModel; using System.Globalization; using Core.Common.Gui.PropertyBag; @@ -33,14 +34,28 @@ public class PipingSoilLayerPropertiesTest { [Test] - public void DefaultConstructor_ExpectedValues() + public void Constructor_PipingSoilLayerNull_ThrowsArgumentNullException() { // Call - var properties = new PipingSoilLayerProperties(); + TestDelegate test = () => new PipingSoilLayerProperties(null); // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("soilLayer", exception.ParamName); + } + + [Test] + public void Constructor_ValidPipingSoilLayer_ExpectedValues() + { + // Setup + var soilLayer = new PipingSoilLayer(2.0); + + // Call + var properties = new PipingSoilLayerProperties(soilLayer); + + // Assert Assert.IsInstanceOf>(properties); - Assert.IsNull(properties.Data); + Assert.AreSame(soilLayer, properties.Data); } [Test] @@ -54,10 +69,7 @@ }; // Call - var properties = new PipingSoilLayerProperties - { - Data = layer - }; + var properties = new PipingSoilLayerProperties(layer); // Assert Assert.AreEqual("Test Name", properties.Name); @@ -74,10 +86,7 @@ MaterialName = "Layer A" }; - var properties = new PipingSoilLayerProperties - { - Data = layer - }; + var properties = new PipingSoilLayerProperties(layer); // Call string name = properties.ToString(); @@ -96,10 +105,7 @@ }; // Call - var properties = new PipingSoilLayerProperties - { - Data = layer - }; + var properties = new PipingSoilLayerProperties(layer); // Assert PropertyDescriptorCollection dynamicProperties = PropertiesTestHelper.GetAllVisiblePropertyDescriptors(properties);