Index: Core/Common/test/Core.Common.TestUtil.Test/TestHelperTest.cs =================================================================== diff -u -r133ab46a14ee9508c8dd5e4f82381da606076ae0 -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Core/Common/test/Core.Common.TestUtil.Test/TestHelperTest.cs (.../TestHelperTest.cs) (revision 133ab46a14ee9508c8dd5e4f82381da606076ae0) +++ Core/Common/test/Core.Common.TestUtil.Test/TestHelperTest.cs (.../TestHelperTest.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -608,7 +608,7 @@ public void AssertExceptionCustomMessage_NoException_ThrowsAssertionException() { // Setup - TestDelegate t = () => { }; + TestDelegate t = () => {}; // Call TestDelegate call = () => TestHelper.AssertThrowsArgumentExceptionAndTestMessage(t, string.Empty); @@ -676,7 +676,7 @@ } [Test] - public void AssertTypeConverter_PropertyWithoutTypeConverterAttribute_ThrowsAssertionException() + public void AssertTypeConverterWithExpression_PropertyWithoutTypeConverterAttribute_ThrowsAssertionException() { // Call TestDelegate test = () => TestHelper.AssertTypeConverter(nameof(TestClass.PropertyWithoutTypeConverter)); @@ -686,7 +686,7 @@ } [Test] - public void AssertTypeConverter_PropertyWithDifferentTypeConverterAttribute_ThrowsAssertionException() + public void AssertTypeConverterWithExpression_PropertyWithDifferentTypeConverterAttribute_ThrowsAssertionException() { // Call TestDelegate test = () => TestHelper.AssertTypeConverter(nameof(TestClass.PropertyWithTypeConverter)); @@ -696,7 +696,7 @@ } [Test] - public void AssertTypeConverter_PropertyWithMatchingTypeConverterAttribute_DoesNotThrowException() + public void AssertTypeConverterWithExpression_PropertyWithMatchingTypeConverterAttribute_DoesNotThrowException() { // Call TestDelegate test = () => TestHelper.AssertTypeConverter(nameof(TestClass.PropertyWithTypeConverter)); @@ -706,7 +706,7 @@ } [Test] - public void AssertTypeConverter_TypeConverterAttributeInherited_ReturnTrue() + public void AssertTypeConverterWithExpression_TypeConverterAttributeInherited_ReturnTrue() { // Call TestDelegate test = () => TestHelper.AssertTypeConverter(nameof(DerivedTestClass.PropertyWithTypeConverter)); @@ -716,6 +716,46 @@ } [Test] + public void AssertTypeConverterWithoutExpression_ClassWithoutTypeConverterAttribute_ThrowsAssertionException() + { + // Call + TestDelegate test = TestHelper.AssertTypeConverter; + + // Assert + Assert.Throws(test); + } + + [Test] + public void AssertTypeConverterWithoutExpression_ClassWithDifferentTypeConverterAttribute_ThrowsAssertionException() + { + // Call + TestDelegate test = TestHelper.AssertTypeConverter; + + // Assert + Assert.Throws(test); + } + + [Test] + public void AssertTypeConverterWithoutExpression_ClassWithMatchingTypeConverterAttribute_DoesNotThrowException() + { + // Call + TestDelegate test = TestHelper.AssertTypeConverter; + + // Assert + Assert.DoesNotThrow(test); + } + + [Test] + public void AssertTypeConverterWithoutExpression_TypeConverterAttributeInherited_ReturnTrue() + { + // Call + TestDelegate test = TestHelper.AssertTypeConverter; + + // Assert + Assert.DoesNotThrow(test); + } + + [Test] [TestCaseSource(nameof(AssertAreEqualButNotSameSource))] public void AssertAreEqualButNotSame_DifferentObjects_ReturnExpectedValues(object objectA, object objectB, bool shouldSucceed) { @@ -1163,6 +1203,9 @@ private class TestToolStripDropDownItem : ToolStripDropDownItem {} + private class TestClassWithoutConverter {} + + [TypeConverter(typeof(DoubleConverter))] private class TestClass { public double PropertyWithoutTypeConverter { get; private set; } Index: Core/Common/test/Core.Common.TestUtil/TestHelper.cs =================================================================== diff -u -r094cd1436a3bca306b1df6d6b09586bf1a032f0e -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision 094cd1436a3bca306b1df6d6b09586bf1a032f0e) +++ Core/Common/test/Core.Common.TestUtil/TestHelper.cs (.../TestHelper.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -394,22 +394,39 @@ /// Thrown when is null. /// Thrown when /// is not an expression with a property, such as an expression calling multiple methods. - /// Thrown when more than one property is found with + /// Thrown when more than one property is found with the /// name specified in . /// Thrown when a custom attribute type cannot be loaded. /// Thrown when the property in /// belongs to a type that is loaded into the reflection-only context. See How to: /// Load Assemblies into the Reflection-Only Context on MSDN for more information. public static void AssertTypeConverter(string expression) where TTypeConverter : TypeConverter { - var typeConverterAttribute = (TypeConverterAttribute) Attribute.GetCustomAttribute(typeof(TTarget).GetProperty(expression), - typeof(TypeConverterAttribute), - true); - Assert.NotNull(typeConverterAttribute); - Assert.IsTrue(typeConverterAttribute.ConverterTypeName == typeof(TTypeConverter).AssemblyQualifiedName); + AssertTypeConverter(typeof(TTarget).GetProperty(expression)); } /// + /// Determines whether a class is decorated with a + /// of a given type. + /// + /// The type of the target. + /// The type of to check + /// for on the type of . + /// Thrown when the class wasn't decorated with + /// a or with a different + /// than . + /// Thrown when more than one class is found with + /// the type specified in . + /// Thrown when a custom attribute type cannot be loaded. + /// Thrown when the class belongs to a type + /// that is loaded into the reflection-only context. See How to: + /// Load Assemblies into the Reflection-Only Context on MSDN for more information. + public static void AssertTypeConverter() where TTypeConverter : TypeConverter + { + AssertTypeConverter(typeof(TTarget)); + } + + /// /// Determines whether objects are copies of each other by verifying that they are /// equal, but not the same. /// @@ -520,6 +537,31 @@ } } + /// + /// Determines whether a class is decorated with a + /// of a given type. + /// + /// The type of to check + /// for on the . + /// Thrown when the class wasn't decorated with + /// a or with a different + /// than . + /// Thrown when more than one class is found with + /// the property specified in . + /// Thrown when a custom attribute type cannot be loaded. + /// Thrown when the class belongs to a type + /// that is loaded into the reflection-only context. See How to: + /// Load Assemblies into the Reflection-Only Context on MSDN for more information. + private static void AssertTypeConverter(MemberInfo expression) where TTypeConverter : TypeConverter + { + var typeConverterAttribute = (TypeConverterAttribute) Attribute.GetCustomAttribute(expression, + typeof(TypeConverterAttribute), + true); + + Assert.NotNull(typeConverterAttribute); + Assert.IsTrue(typeConverterAttribute.ConverterTypeName == typeof(TTypeConverter).AssemblyQualifiedName); + } + private static void AssertIsFasterThan(float maxMilliseconds, string message, Action action, bool rankHddAccess) { var stopwatch = new Stopwatch(); Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs =================================================================== diff -u -r686c5eeaad900a6bb627733de8c21bd607f130aa -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs (.../MacroStabilityInwardsSoilProfile2DLayersHelper.cs) (revision 686c5eeaad900a6bb627733de8c21bd607f130aa) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Data/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelper.cs (.../MacroStabilityInwardsSoilProfile2DLayersHelper.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -19,7 +19,6 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; using System.Linq; using Ringtoets.MacroStabilityInwards.Primitives; @@ -35,16 +34,10 @@ /// Method for obtaining all in recursively. /// /// The collection of layers to recursively get the layers from. - /// An enumerable with . - /// Thrown when is null. + /// An enumerable with , if there are any. public static IEnumerable GetLayersRecursively(IEnumerable layers) { - if (layers == null) - { - throw new ArgumentNullException(nameof(layers)); - } - - return layers.SelectMany(GetLayersRecursively); + return layers?.SelectMany(GetLayersRecursively) ?? Enumerable.Empty(); } private static IEnumerable GetLayersRecursively(MacroStabilityInwardsSoilLayer2D layer) Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DBaseProperties.cs =================================================================== diff -u -r686c5eeaad900a6bb627733de8c21bd607f130aa -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DBaseProperties.cs (.../MacroStabilityInwardsSoilLayer2DBaseProperties.cs) (revision 686c5eeaad900a6bb627733de8c21bd607f130aa) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsSoilLayer2DBaseProperties.cs (.../MacroStabilityInwardsSoilLayer2DBaseProperties.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -68,7 +68,6 @@ } [PropertyOrder(2)] - [ReadOnly(true)] [ResourcesCategory(typeof(RingtoetsCommonFormsResources), nameof(RingtoetsCommonFormsResources.Categories_General))] [TypeConverter(typeof(ExpandableArrayConverter))] [ResourcesDisplayName(typeof(Resources), nameof(Resources.SoilLayer_Geometry_DisplayName))] Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsStochasticSoilProfileProperties.cs =================================================================== diff -u -r686c5eeaad900a6bb627733de8c21bd607f130aa -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsStochasticSoilProfileProperties.cs (.../MacroStabilityInwardsStochasticSoilProfileProperties.cs) (revision 686c5eeaad900a6bb627733de8c21bd607f130aa) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/PropertyClasses/MacroStabilityInwardsStochasticSoilProfileProperties.cs (.../MacroStabilityInwardsStochasticSoilProfileProperties.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -108,11 +108,8 @@ get { 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]; + IEnumerable macroStabilityInwardsSoilLayers2D = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers); + return macroStabilityInwardsSoilLayers2D.Select(layer => new MacroStabilityInwardsSoilLayer2DTopLevelProperties(layer)).ToArray(); } } Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs =================================================================== diff -u -rf1a0220eaafcd55ec39eb0b0c93d5fbd1c65d8c9 -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision f1a0220eaafcd55ec39eb0b0c93d5fbd1c65d8c9) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsInputView.cs (.../MacroStabilityInwardsInputView.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -319,10 +319,7 @@ private IEnumerable GetSoilLayers() { - IEnumerable layers = data?.InputParameters.SoilProfileUnderSurfaceLine?.Layers; - return layers != null - ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers) - : new List(); + return MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(data?.InputParameters.SoilProfileUnderSurfaceLine?.Layers); } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputChartControl.cs =================================================================== diff -u -rf1a0220eaafcd55ec39eb0b0c93d5fbd1c65d8c9 -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputChartControl.cs (.../MacroStabilityInwardsOutputChartControl.cs) (revision f1a0220eaafcd55ec39eb0b0c93d5fbd1c65d8c9) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputChartControl.cs (.../MacroStabilityInwardsOutputChartControl.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -265,10 +265,7 @@ private IEnumerable GetSoilLayers() { - IEnumerable layers = data?.InputParameters.SoilProfileUnderSurfaceLine?.Layers; - return layers != null - ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(layers) - : new List(); + return MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(data.InputParameters.SoilProfileUnderSurfaceLine?.Layers); } private void SetWaternetDatas(MacroStabilityInwardsSurfaceLine surfaceLine) Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelperTest.cs =================================================================== diff -u -r686c5eeaad900a6bb627733de8c21bd607f130aa -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelperTest.cs (.../MacroStabilityInwardsSoilProfile2DLayersHelperTest.cs) (revision 686c5eeaad900a6bb627733de8c21bd607f130aa) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Data.Test/SoilProfile/MacroStabilityInwardsSoilProfile2DLayersHelperTest.cs (.../MacroStabilityInwardsSoilProfile2DLayersHelperTest.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -19,8 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Collections.Generic; +using System.Linq; using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.MacroStabilityInwards.Data.SoilProfile; @@ -32,66 +32,74 @@ public class MacroStabilityInwardsSoilProfile2DLayersHelperTest { [Test] - public void GetLayersRecursively_LayersNull_ThrowsArgumentNullException() + public void GetLayersRecursively_LayersNull_ReturnsEmptyCollection() { // Call - TestDelegate call = () => MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(null); + IEnumerable layers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(null); // Assert - string paramName = Assert.Throws(call).ParamName; - Assert.AreEqual("layers", paramName); + CollectionAssert.IsEmpty(layers); } [Test] - public void GetLayersRecursively_WithLayers_ReturnsAllTopLevelAndNestedLayers() + public void GetLayersRecursively_WithNestedLayers_ReturnsAllTopLevelAndNestedLayers() { // Setup - var nestedLayer1 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List - { - new Point2D(4.0, 2.0), - new Point2D(0.0, 2.5) - }), new List()); + var nestedLayer1 = new MacroStabilityInwardsSoilLayer2D( + new Ring(new List + { + new Point2D(4.0, 2.0), + new Point2D(0.0, 2.5) + }), + Enumerable.Empty()); - var topLevelLayer1 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List - { - new Point2D(0.0, 1.0), - new Point2D(2.0, 4.0) - }), - new List(), - new MacroStabilityInwardsSoilLayerData(), - new[] - { - nestedLayer1 - }); + var topLevelLayer1 = new MacroStabilityInwardsSoilLayer2D( + new Ring(new List + { + new Point2D(0.0, 1.0), + new Point2D(2.0, 4.0) + }), + Enumerable.Empty(), + new MacroStabilityInwardsSoilLayerData(), + new[] + { + nestedLayer1 + }); - var doubleNestedLayer = new MacroStabilityInwardsSoilLayer2D(new Ring(new List - { - new Point2D(4.0, 2.0), - new Point2D(0.0, 2.5) - }), new List()); + var doubleNestedLayer = new MacroStabilityInwardsSoilLayer2D( + new Ring(new List + { + new Point2D(4.0, 2.0), + new Point2D(0.0, 2.5) + }), + Enumerable.Empty()); - var nestedLayer2 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List - { - new Point2D(4.0, 2.0), - new Point2D(0.0, 2.5) - }), - new List(), - new MacroStabilityInwardsSoilLayerData(), - new[] - { - doubleNestedLayer - }); + var nestedLayer2 = new MacroStabilityInwardsSoilLayer2D( + new Ring(new List + { + new Point2D(4.0, 2.0), + new Point2D(0.0, 2.5) + }), + Enumerable.Empty(), + new MacroStabilityInwardsSoilLayerData(), + new[] + { + doubleNestedLayer + }); - var topLevelLayer2 = new MacroStabilityInwardsSoilLayer2D(new Ring(new List - { - new Point2D(3.0, 1.0), - new Point2D(8.0, 3.0) - }), new List(), - new MacroStabilityInwardsSoilLayerData(), - new[] - { - nestedLayer2 - }); + var topLevelLayer2 = new MacroStabilityInwardsSoilLayer2D( + new Ring(new List + { + new Point2D(3.0, 1.0), + new Point2D(8.0, 3.0) + }), + Enumerable.Empty(), + new MacroStabilityInwardsSoilLayerData(), + new[] + { + nestedLayer2 + }); + var layers = new[] { topLevelLayer1, Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DBasePropertiesTest.cs =================================================================== diff -u -r686c5eeaad900a6bb627733de8c21bd607f130aa -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DBasePropertiesTest.cs (.../MacroStabilityInwardsSoilLayer2DBasePropertiesTest.cs) (revision 686c5eeaad900a6bb627733de8c21bd607f130aa) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DBasePropertiesTest.cs (.../MacroStabilityInwardsSoilLayer2DBasePropertiesTest.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -21,11 +21,13 @@ using System; using System.ComponentModel; +using System.Linq; 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.TestUtil.SoilProfile; using Ringtoets.MacroStabilityInwards.Forms.PropertyClasses; using Ringtoets.MacroStabilityInwards.Primitives; @@ -48,13 +50,14 @@ public void Constructor_ValidMacroStabilityInwardsSoilLayer2D_ExpectedValues() { // Setup - MacroStabilityInwardsSoilLayer2D soilLayer = CreateMacroStabilityInwardsSoilLayer2D(); + MacroStabilityInwardsSoilLayer2D soilLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(); // Call var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(soilLayer); // Assert Assert.IsInstanceOf>(properties); + TestHelper.AssertTypeConverter(); TestHelper.AssertTypeConverter(nameof(MacroStabilityInwardsSoilLayer2DBaseProperties.Geometry)); Assert.AreSame(soilLayer, properties.Data); @@ -64,25 +67,28 @@ 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], - new MacroStabilityInwardsSoilLayerData - { - MaterialName = "Test Name", - IsAquifer = true - }, - new[] - { - new MacroStabilityInwardsSoilLayer2D(new Ring(new[] - { - new Point2D(12.987, 12.821), - new Point2D(4.23, 1.02) - }), new Ring[0]) - }); + var layer = new MacroStabilityInwardsSoilLayer2D( + new Ring(new[] + { + new Point2D(20.210230, 26.00001), + new Point2D(3.830, 1.040506) + }), + Enumerable.Empty(), + new MacroStabilityInwardsSoilLayerData + { + MaterialName = "Test Name", + IsAquifer = true + }, + new[] + { + new MacroStabilityInwardsSoilLayer2D( + new Ring(new[] + { + new Point2D(12.987, 12.821), + new Point2D(4.23, 1.02) + }), + Enumerable.Empty()) + }); // Call var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(layer); @@ -96,7 +102,7 @@ public void ToString_Always_ReturnsMaterialName() { // Setup - MacroStabilityInwardsSoilLayer2D layer = CreateMacroStabilityInwardsSoilLayer2D(); + MacroStabilityInwardsSoilLayer2D layer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(); layer.Data.MaterialName = "Layer A 2D"; var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(layer); @@ -112,7 +118,7 @@ public void Constructor_ValidData_PropertieshaveExpectedAttributeValues() { // Setup - MacroStabilityInwardsSoilLayer2D layer = CreateMacroStabilityInwardsSoilLayer2D(); + MacroStabilityInwardsSoilLayer2D layer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(); // Call var properties = new MacroStabilityInwardsSoilLayer2DBaseProperties(layer); @@ -138,15 +144,5 @@ "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]); - } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DTopLevelPropertiesTest.cs =================================================================== diff -u -r1a3f904157a3f86e702ea8086bee67e780da7856 -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DTopLevelPropertiesTest.cs (.../MacroStabilityInwardsSoilLayer2DTopLevelPropertiesTest.cs) (revision 1a3f904157a3f86e702ea8086bee67e780da7856) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsSoilLayer2DTopLevelPropertiesTest.cs (.../MacroStabilityInwardsSoilLayer2DTopLevelPropertiesTest.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -25,7 +25,7 @@ using Core.Common.Gui.Converters; using Core.Common.TestUtil; using NUnit.Framework; -using Ringtoets.MacroStabilityInwards.Data.SoilProfile; +using Ringtoets.MacroStabilityInwards.Data.TestUtil.SoilProfile; using Ringtoets.MacroStabilityInwards.Forms.PropertyClasses; using Ringtoets.MacroStabilityInwards.Primitives; @@ -37,13 +37,14 @@ public void Constructor_ValidMacroStabilityInwardsSoilLayer2D_ExpectedValues() { // Setup - MacroStabilityInwardsSoilLayer2D soilLayer = CreateMacroStabilityInwardsSoilLayer2D(); + MacroStabilityInwardsSoilLayer2D soilLayer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(); // Call var properties = new MacroStabilityInwardsSoilLayer2DTopLevelProperties(soilLayer); // Assert Assert.IsInstanceOf(properties); + TestHelper.AssertTypeConverter(); TestHelper.AssertTypeConverter(nameof(MacroStabilityInwardsSoilLayer2DTopLevelProperties.NestedLayers)); Assert.AreSame(soilLayer, properties.Data); @@ -85,7 +86,7 @@ public void Constructor_ValidData_PropertieshaveExpectedAttributeValues() { // Setup - MacroStabilityInwardsSoilLayer2D layer = CreateMacroStabilityInwardsSoilLayer2D(); + MacroStabilityInwardsSoilLayer2D layer = MacroStabilityInwardsSoilLayer2DTestFactory.CreateMacroStabilityInwardsSoilLayer2D(); // Call var properties = new MacroStabilityInwardsSoilLayer2DTopLevelProperties(layer); @@ -125,15 +126,5 @@ "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]); - } } } \ No newline at end of file Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs =================================================================== diff -u -r1a3f904157a3f86e702ea8086bee67e780da7856 -r03bb865f66b346c37c91f2cd8a442abbb2952cba --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs (.../MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs) (revision 1a3f904157a3f86e702ea8086bee67e780da7856) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/PropertyClasses/MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs (.../MacroStabilityInwardsStochasticSoilProfilePropertiesTest.cs) (revision 03bb865f66b346c37c91f2cd8a442abbb2952cba) @@ -64,6 +64,7 @@ // Assert Assert.IsInstanceOf>(properties); + TestHelper.AssertTypeConverter(); TestHelper.AssertTypeConverter(nameof(MacroStabilityInwardsStochasticSoilProfileProperties.Layers1D)); TestHelper.AssertTypeConverterThrown when does not correspond /// to , or /// . - public static void AssertSoilProfileChartData(IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurface, string expectedName, bool mapDataShouldContainAreas, ChartData actual) + public static void AssertSoilProfileChartData(IMacroStabilityInwardsSoilProfileUnderSurfaceLine soilProfileUnderSurface, + string expectedName, + bool mapDataShouldContainAreas, + ChartData actual) { Assert.IsInstanceOf(actual); var soilProfileChartData = (ChartDataCollection) actual; - MacroStabilityInwardsSoilLayer2D[] layers = soilProfileUnderSurface?.Layers != null - ? MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfileUnderSurface.Layers).ToArray() - : new MacroStabilityInwardsSoilLayer2D[0]; + MacroStabilityInwardsSoilLayer2D[] layers = MacroStabilityInwardsSoilProfile2DLayersHelper.GetLayersRecursively(soilProfileUnderSurface?.Layers).ToArray(); int expectedLayerCount = layers.Length; Assert.AreEqual(expectedLayerCount, soilProfileChartData.Collection.Count());