Index: Core/Components/src/Core.Components.Gis.IO/Writers/PointShapeFileWriter.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/src/Core.Components.Gis.IO/Writers/PointShapeFileWriter.cs (.../PointShapeFileWriter.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Core/Components/src/Core.Components.Gis.IO/Writers/PointShapeFileWriter.cs (.../PointShapeFileWriter.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -49,11 +49,6 @@ protected override IFeature AddFeature(MapFeature mapFeature) { - if (mapFeature == null) - { - throw new ArgumentNullException("mapFeature"); - } - Point point = CreatePointFromMapFeature(mapFeature); return ShapeFile.AddFeature(point); Index: Core/Components/src/Core.Components.Gis.IO/Writers/PolylineShapeFileWriter.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/src/Core.Components.Gis.IO/Writers/PolylineShapeFileWriter.cs (.../PolylineShapeFileWriter.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Core/Components/src/Core.Components.Gis.IO/Writers/PolylineShapeFileWriter.cs (.../PolylineShapeFileWriter.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -49,11 +49,6 @@ protected override IFeature AddFeature(MapFeature mapFeature) { - if (mapFeature == null) - { - throw new ArgumentNullException("mapFeature"); - } - LineString lineString = CreateLineStringFromMapFeature(mapFeature); return ShapeFile.AddFeature(lineString); Index: Core/Components/src/Core.Components.Gis.IO/Writers/ShapeFileWriterBase.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/src/Core.Components.Gis.IO/Writers/ShapeFileWriterBase.cs (.../ShapeFileWriterBase.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Core/Components/src/Core.Components.Gis.IO/Writers/ShapeFileWriterBase.cs (.../ShapeFileWriterBase.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -65,9 +65,9 @@ throw new ArgumentException(Resources.ShapeFileWriterBase_CopyToFeature_Mapdata_can_only_contain_one_feature); } - var mapFeature = mapData.Features.First(); + MapFeature mapFeature = mapData.Features.First(); EnsureAttributeTableExists(mapFeature); - var feature = AddFeature(mapFeature); + IFeature feature = AddFeature(mapFeature); CopyMetaDataFromMapFeatureToAttributeTable(mapFeature, feature); } @@ -102,9 +102,9 @@ /// /// Create a new feature from a . /// - /// The from which to create a feature. + /// The from which to create a feature. + /// This cannot be null. /// The created feature. - /// Thrown when is null. protected abstract IFeature AddFeature(MapFeature mapFeature); private void EnsureAttributeTableExists(MapFeature mapFeature) @@ -126,12 +126,12 @@ private static void CopyMetaDataFromMapFeatureToAttributeTable(MapFeature mapFeature, IFeature feature) { IDictionary metaData = mapFeature.MetaData; - var sortedKeys = metaData.Keys.ToList(); + List sortedKeys = metaData.Keys.ToList(); sortedKeys.Sort(); - foreach (var key in sortedKeys) + foreach (string key in sortedKeys) { - var value = metaData[key]; + object value = metaData[key]; feature.DataRow.BeginEdit(); feature.DataRow[key] = value; feature.DataRow.EndEdit(); @@ -141,13 +141,13 @@ private void CreateAttributeTable(MapFeature mapFeature) { IDictionary metaData = mapFeature.MetaData; - var sortedKeys = metaData.Keys.ToList(); + List sortedKeys = metaData.Keys.ToList(); sortedKeys.Sort(); - var columns = ShapeFile.DataTable.Columns; - foreach (var key in sortedKeys) + DataColumnCollection columns = ShapeFile.DataTable.Columns; + foreach (string key in sortedKeys) { - var value = metaData[key]; + object value = metaData[key]; columns.Add(new DataColumn { DataType = value.GetType(), Index: Core/Components/src/Core.Components.Gis/Data/FeatureBasedMapData.cs =================================================================== diff -u -r38ee40c1f98ff4b1921d4de64fd032c8fbcadf92 -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/src/Core.Components.Gis/Data/FeatureBasedMapData.cs (.../FeatureBasedMapData.cs) (revision 38ee40c1f98ff4b1921d4de64fd032c8fbcadf92) +++ Core/Components/src/Core.Components.Gis/Data/FeatureBasedMapData.cs (.../FeatureBasedMapData.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Linq; using Core.Components.Gis.Features; namespace Core.Components.Gis.Data @@ -45,7 +46,8 @@ /// /// Gets or sets an array of features. /// - /// Calls and so can throw all corresponding exceptions. + /// Calls and so can throw all corresponding exceptions. + /// This collection will not contain null elements. public MapFeature[] Features { get @@ -64,13 +66,14 @@ /// This method validates newly set features. /// /// The new features to validate. - /// Thrown when is null. + /// Thrown when + /// is null or contains null. /// protected virtual void ValidateFeatures(MapFeature[] featuresToValidate) { - if (featuresToValidate == null) + if (featuresToValidate == null || featuresToValidate.Any(e => e == null)) { - throw new ArgumentNullException("featuresToValidate", @"The array of features cannot be null."); + throw new ArgumentNullException("featuresToValidate", @"The array of features cannot be null or contain null."); } } } Index: Core/Components/src/Core.Components.Gis/Data/MapPointData.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -23,7 +23,6 @@ using System.Collections.Generic; using System.Linq; using Core.Components.Gis.Features; -using Core.Components.Gis.Geometries; using Core.Components.Gis.Style; namespace Core.Components.Gis.Data Index: Core/Components/test/Core.Components.Gis.IO.Test/Writers/PointShapeFileWriterTest.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/test/Core.Components.Gis.IO.Test/Writers/PointShapeFileWriterTest.cs (.../PointShapeFileWriterTest.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Core/Components/test/Core.Components.Gis.IO.Test/Writers/PointShapeFileWriterTest.cs (.../PointShapeFileWriterTest.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -86,7 +86,7 @@ new MapGeometry(new[] { Enumerable.Empty() - }), + }) }); MapPointData mapData = new MapPointData("test") Index: Core/Components/test/Core.Components.Gis.IO.Test/Writers/PolylineShapeFileWriterTest.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/test/Core.Components.Gis.IO.Test/Writers/PolylineShapeFileWriterTest.cs (.../PolylineShapeFileWriterTest.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Core/Components/test/Core.Components.Gis.IO.Test/Writers/PolylineShapeFileWriterTest.cs (.../PolylineShapeFileWriterTest.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -85,7 +85,7 @@ new MapGeometry(new[] { Enumerable.Empty() - }), + }) }); MapLineData mapData = new MapLineData("test") Index: Core/Components/test/Core.Components.Gis.IO.Test/Writers/ShapeFileWriterBaseTest.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/test/Core.Components.Gis.IO.Test/Writers/ShapeFileWriterBaseTest.cs (.../ShapeFileWriterBaseTest.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Core/Components/test/Core.Components.Gis.IO.Test/Writers/ShapeFileWriterBaseTest.cs (.../ShapeFileWriterBaseTest.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -57,8 +57,8 @@ TestDelegate test = () => writer.CopyToFeature(null); // Assert - var excpetion = Assert.Throws(test); - Assert.AreEqual("mapData", excpetion.ParamName); + var exception = Assert.Throws(test); + Assert.AreEqual("mapData", exception.ParamName); } } @@ -78,29 +78,6 @@ } [Test] - public void CopyToFeature_MapFeatureNull_ThrowsArgumentNullException() - { - // Setup - MapPointData mapData = new MapPointData("test") - { - Features = new MapFeature[] - { - null - } - }; - - using (var writer = new TestShapeFileWriterBase()) - { - // Call - TestDelegate call = () => writer.CopyToFeature(mapData); - - // Assert - var exception = Assert.Throws(call); - Assert.AreEqual("mapFeature", exception.ParamName); - } - } - - [Test] [TestCase("")] [TestCase(" ")] [TestCase(null)] Index: Core/Components/test/Core.Components.Gis.Test/Data/FeatureBasedMapDataTest.cs =================================================================== diff -u -rce31448a066c084f755439f3e7d453bfb042b291 -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/test/Core.Components.Gis.Test/Data/FeatureBasedMapDataTest.cs (.../FeatureBasedMapDataTest.cs) (revision ce31448a066c084f755439f3e7d453bfb042b291) +++ Core/Components/test/Core.Components.Gis.Test/Data/FeatureBasedMapDataTest.cs (.../FeatureBasedMapDataTest.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -85,10 +85,24 @@ TestDelegate test = () => data.Features = null; // Assert - const string expectedMessage = "The array of features cannot be null."; + const string expectedMessage = "The array of features cannot be null or contain null."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } + [Test] + public void Features_SetCollectionWithNullElement_ThrowsArgumentNullException() + { + // Setup + var data = new TestFeatureBasedMapData("test data"); + + // Call + TestDelegate test = () => data.Features = new MapFeature[]{ null }; + + // Assert + const string expectedMessage = "The array of features cannot be null or contain null."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + private class TestFeatureBasedMapData : FeatureBasedMapData { public TestFeatureBasedMapData(string name) : base(name) { } Index: Core/Components/test/Core.Components.Gis.Test/Data/MapLineDataTest.cs =================================================================== diff -u -rce31448a066c084f755439f3e7d453bfb042b291 -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/test/Core.Components.Gis.Test/Data/MapLineDataTest.cs (.../MapLineDataTest.cs) (revision ce31448a066c084f755439f3e7d453bfb042b291) +++ Core/Components/test/Core.Components.Gis.Test/Data/MapLineDataTest.cs (.../MapLineDataTest.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -98,11 +98,25 @@ TestDelegate test = () => data.Features = null; // Assert - const string expectedMessage = "The array of features cannot be null."; + const string expectedMessage = "The array of features cannot be null or contain null."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } [Test] + public void Features_SetCollectionWithNullValue_ThrowsArgumentNullException() + { + // Setup + var data = new MapLineData("test data"); + + // Call + TestDelegate test = () => data.Features = new MapFeature[]{ null }; + + // Assert + const string expectedMessage = "The array of features cannot be null or contain null."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] [TestCase(0)] [TestCase(2)] [TestCase(7)] Index: Core/Components/test/Core.Components.Gis.Test/Data/MapPointDataTest.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/test/Core.Components.Gis.Test/Data/MapPointDataTest.cs (.../MapPointDataTest.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Core/Components/test/Core.Components.Gis.Test/Data/MapPointDataTest.cs (.../MapPointDataTest.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -98,11 +98,25 @@ TestDelegate test = () => data.Features = null; // Assert - const string expectedMessage = "The array of features cannot be null."; + const string expectedMessage = "The array of features cannot be null or contain null."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } [Test] + public void Features_SetCollectionWithNullValue_ThrowsArgumentNullException() + { + // Setup + var data = new MapPointData("test data"); + + // Call + TestDelegate test = () => data.Features = new MapFeature[]{ null }; + + // Assert + const string expectedMessage = "The array of features cannot be null or contain null."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] [TestCase(0)] [TestCase(2)] [TestCase(7)] Index: Core/Components/test/Core.Components.Gis.Test/Data/MapPolygonDataTest.cs =================================================================== diff -u -rce31448a066c084f755439f3e7d453bfb042b291 -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Core/Components/test/Core.Components.Gis.Test/Data/MapPolygonDataTest.cs (.../MapPolygonDataTest.cs) (revision ce31448a066c084f755439f3e7d453bfb042b291) +++ Core/Components/test/Core.Components.Gis.Test/Data/MapPolygonDataTest.cs (.../MapPolygonDataTest.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -99,11 +99,25 @@ TestDelegate test = () => data.Features = null; // Assert - const string expectedMessage = "The array of features cannot be null."; + const string expectedMessage = "The array of features cannot be null or contain null."; TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); } [Test] + public void Features_SetCollectionWithNullValue_ThrowsArgumentNullException() + { + // Setup + var data = new MapPolygonData("test data"); + + // Call + TestDelegate test = () => data.Features = new MapFeature[]{ null }; + + // Assert + const string expectedMessage = "The array of features cannot be null or contain null."; + TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, expectedMessage); + } + + [Test] public void Features_SetInvalidValue_ThrowsArgumentException() { // Setup Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineImporter.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineImporter.cs (.../ReferenceLineImporter.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineImporter.cs (.../ReferenceLineImporter.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -78,7 +78,7 @@ { get { - return string.Format(RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter, Name); + return RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter; } } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Plugin/FileImporter/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -81,7 +81,7 @@ { get { - return string.Format(RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter, Name); + return RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter; } } Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryLocationsWriter.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryLocationsWriter.cs (.../HydraulicBoundaryLocationsWriter.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryLocationsWriter.cs (.../HydraulicBoundaryLocationsWriter.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -59,7 +59,7 @@ var pointShapeFileWriter = new PointShapeFileWriter(); - foreach (var mapLineData in hydraulicBoundaryLocations.Select(CreateMapPointData)) + foreach (MapPointData mapLineData in hydraulicBoundaryLocations.Select(CreateMapPointData)) { pointShapeFileWriter.CopyToFeature(mapLineData); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs =================================================================== diff -u -rfea3ed82dfb6dfcad535eef16efcbaa9c01564ed -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs (.../FailureMechanismSectionsImporter.cs) (revision fea3ed82dfb6dfcad535eef16efcbaa9c01564ed) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/FailureMechanismSectionsImporter.cs (.../FailureMechanismSectionsImporter.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -89,7 +89,7 @@ { get { - return string.Format(RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter, Name); + return RingtoetsCommonIOResources.DataTypeDisplayName_shape_file_filter; } } Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileExporters/HydraulicBoundaryLocationsExporterTest.cs =================================================================== diff -u -r718348fd1a88ab775f495dad750379e4cbedb25f -r7fcd0c3e627c8a69c3b4618c09782321a5b78c2e --- Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileExporters/HydraulicBoundaryLocationsExporterTest.cs (.../HydraulicBoundaryLocationsExporterTest.cs) (revision 718348fd1a88ab775f495dad750379e4cbedb25f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/FileExporters/HydraulicBoundaryLocationsExporterTest.cs (.../HydraulicBoundaryLocationsExporterTest.cs) (revision 7fcd0c3e627c8a69c3b4618c09782321a5b78c2e) @@ -45,7 +45,7 @@ string filePath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "test.shp"); // Call - HydraulicBoundaryLocationsExporter hydraulicBoundaryLocationsExporter = new HydraulicBoundaryLocationsExporter(new[] { hydraulicBoundaryLocation }, filePath); + var hydraulicBoundaryLocationsExporter = new HydraulicBoundaryLocationsExporter(new[] { hydraulicBoundaryLocation }, filePath); // Assert Assert.IsInstanceOf(hydraulicBoundaryLocationsExporter); @@ -69,7 +69,7 @@ public void ParameteredConstructor_FilePathNull_ThrowArgumentException() { // Setup - HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) { DesignWaterLevel = 111.111, WaveHeight = 222.222 @@ -86,7 +86,7 @@ public void Export_ValidData_ReturnTrue() { // Setup - HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) { DesignWaterLevel = 111.111, WaveHeight = 222.222 @@ -97,7 +97,7 @@ Directory.CreateDirectory(directoryPath); string filePath = Path.Combine(directoryPath, "test.shp"); - HydraulicBoundaryLocationsExporter exporter = new HydraulicBoundaryLocationsExporter(new[] { hydraulicBoundaryLocation }, filePath); + var exporter = new HydraulicBoundaryLocationsExporter(new[] { hydraulicBoundaryLocation }, filePath); bool isExported; try @@ -118,7 +118,7 @@ public void Export_InvalidDirectoryRights_LogErrorAndReturnFalse() { // Setup - HydraulicBoundaryLocation hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(123, "aName", 1.1, 2.2) { DesignWaterLevel = 111.111, WaveHeight = 222.222 @@ -129,7 +129,7 @@ Directory.CreateDirectory(directoryPath); string filePath = Path.Combine(directoryPath, "test.shp"); - HydraulicBoundaryLocationsExporter exporter = new HydraulicBoundaryLocationsExporter(new[] { hydraulicBoundaryLocation }, filePath); + var exporter = new HydraulicBoundaryLocationsExporter(new[] { hydraulicBoundaryLocation }, filePath); try {