Index: Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7aa6b8425147795b1a87b552fe9d82ae5e9c7565 --- Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs (.../MapPolygonDataConverter.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/src/Core.Components.DotSpatial/Converter/MapPolygonDataConverter.cs (.../MapPolygonDataConverter.cs) (revision 7aa6b8425147795b1a87b552fe9d82ae5e9c7565) @@ -64,9 +64,7 @@ protected override IFeatureSymbolizer CreateSymbolizer(MapPolygonData mapData) { - return mapData.Style != null - ? new PolygonSymbolizer(mapData.Style.FillColor, mapData.Style.StrokeColor, mapData.Style.Width) - : new PolygonSymbolizer(); + return new PolygonSymbolizer(mapData.Style.FillColor, mapData.Style.StrokeColor, mapData.Style.Width); } private static IBasicGeometry GetGeometry(List geometryList) Index: Core/Components/src/Core.Components.Gis/Data/MapLineData.cs =================================================================== diff -u -r31fd11e38313a3c1ee9bb0aa28ce7cdc49f749b2 -r7aa6b8425147795b1a87b552fe9d82ae5e9c7565 --- Core/Components/src/Core.Components.Gis/Data/MapLineData.cs (.../MapLineData.cs) (revision 31fd11e38313a3c1ee9bb0aa28ce7cdc49f749b2) +++ Core/Components/src/Core.Components.Gis/Data/MapLineData.cs (.../MapLineData.cs) (revision 7aa6b8425147795b1a87b552fe9d82ae5e9c7565) @@ -47,7 +47,7 @@ /// Creates a new instance of with default styling. /// /// The name of the . - /// + /// The style of the data. /// Thrown when is /// null or only whitespace. /// Thrown when Index: Core/Components/src/Core.Components.Gis/Data/MapPointData.cs =================================================================== diff -u -r31fd11e38313a3c1ee9bb0aa28ce7cdc49f749b2 -r7aa6b8425147795b1a87b552fe9d82ae5e9c7565 --- Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 31fd11e38313a3c1ee9bb0aa28ce7cdc49f749b2) +++ Core/Components/src/Core.Components.Gis/Data/MapPointData.cs (.../MapPointData.cs) (revision 7aa6b8425147795b1a87b552fe9d82ae5e9c7565) @@ -46,7 +46,7 @@ /// Creates a new instance of . /// /// The name of the . - /// + /// The style of the data. /// Thrown when is /// null or only whitespace. /// Thrown when Index: Core/Components/src/Core.Components.Gis/Data/MapPolygonData.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7aa6b8425147795b1a87b552fe9d82ae5e9c7565 --- Core/Components/src/Core.Components.Gis/Data/MapPolygonData.cs (.../MapPolygonData.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/src/Core.Components.Gis/Data/MapPolygonData.cs (.../MapPolygonData.cs) (revision 7aa6b8425147795b1a87b552fe9d82ae5e9c7565) @@ -21,6 +21,7 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using Core.Components.Gis.Features; using Core.Components.Gis.Style; @@ -33,17 +34,36 @@ public class MapPolygonData : FeatureBasedMapData { /// + /// Creates a new instance of with default styling. + /// + /// The name of the . + /// Thrown when is + /// null or only whitespace. + public MapPolygonData(string name) + : this(name, new PolygonStyle(Color.DarkGray, Color.Black, 2)) {} + + /// /// Creates a new instance of . /// /// The name of the . + /// The style of the data. /// Thrown when is /// null or only whitespace. - public MapPolygonData(string name) : base(name) {} + /// Thrown when + /// is null. + public MapPolygonData(string name, PolygonStyle style) : base(name) + { + if (style == null) + { + throw new ArgumentNullException(nameof(style)); + } + Style = style; + } /// /// Gets or sets the style of the polygon. /// - public PolygonStyle Style { get; set; } + public PolygonStyle Style { get; } /// /// This method validates newly set features. Index: Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7aa6b8425147795b1a87b552fe9d82ae5e9c7565 --- Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs (.../MapPolygonDataConverterTest.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/test/Core.Components.DotSpatial.Test/Converter/MapPolygonDataConverterTest.cs (.../MapPolygonDataConverterTest.cs) (revision 7aa6b8425147795b1a87b552fe9d82ae5e9c7565) @@ -232,10 +232,7 @@ var mapPolygonLayer = new MapPolygonLayer(); Color expectedFillColor = Color.FromKnownColor(fillColor); Color expectedOutlineFillColor = Color.FromKnownColor(outlineFillColor); - var mapPolygonData = new MapPolygonData("test") - { - Style = new PolygonStyle(expectedFillColor, expectedOutlineFillColor, width) - }; + var mapPolygonData = new MapPolygonData("test", new PolygonStyle(expectedFillColor, expectedOutlineFillColor, width)); // Call converter.ConvertLayerProperties(mapPolygonData, mapPolygonLayer); Index: Core/Components/test/Core.Components.DotSpatial.Test/Layer/MapPolygonDataLayerTest.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7aa6b8425147795b1a87b552fe9d82ae5e9c7565 --- Core/Components/test/Core.Components.DotSpatial.Test/Layer/MapPolygonDataLayerTest.cs (.../MapPolygonDataLayerTest.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/test/Core.Components.DotSpatial.Test/Layer/MapPolygonDataLayerTest.cs (.../MapPolygonDataLayerTest.cs) (revision 7aa6b8425147795b1a87b552fe9d82ae5e9c7565) @@ -54,7 +54,7 @@ public void Constructor_MapPolygonDataWithTestProperties_MapPolygonDataLayerCreatedAccordingly() { // Setup - var mapPolygonData = new MapPolygonData("Test name"); + var mapPolygonData = new MapPolygonData("Test name", new PolygonStyle(Color.AliceBlue, Color.Azure, 2)); SetMapPolygonDataTestProperties(mapPolygonData); @@ -72,7 +72,7 @@ public void Update_MapPolygonDataWithTestProperties_MapPolygonDataLayerUpdatedAccordingly() { // Setup - var mapPolygonData = new MapPolygonData("Test name"); + var mapPolygonData = new MapPolygonData("Test name", new PolygonStyle(Color.AliceBlue, Color.Azure, 2)); var mapPolygonDataLayer = new MapPolygonDataLayer(mapPolygonData); SetMapPolygonDataTestProperties(mapPolygonData); @@ -141,7 +141,6 @@ mapPolygonData.IsVisible = false; mapPolygonData.ShowLabels = true; mapPolygonData.SelectedMetaDataAttribute = "Name"; - mapPolygonData.Style = new PolygonStyle(Color.AliceBlue, Color.Azure, 2); mapPolygonData.Features = new[] { CreateTestMapFeature() @@ -155,7 +154,7 @@ Assert.IsTrue(mapPolygonDataLayer.ShowLabels); Assert.IsNotNull(mapPolygonDataLayer.LabelLayer); - Assert.AreEqual(string.Format("[{0}]", "2"), mapPolygonDataLayer.LabelLayer.Symbology.Categories[0].Expression); + Assert.AreEqual("[2]", mapPolygonDataLayer.LabelLayer.Symbology.Categories[0].Expression); var firstPattern = (SimplePattern) mapPolygonDataLayer.Symbolizer.Patterns[0]; Assert.AreEqual(Color.AliceBlue, firstPattern.FillColor); @@ -175,7 +174,7 @@ Assert.IsNull(mapPolygonDataLayer.LabelLayer.Symbology.Categories[0].Expression); var firstPattern = (SimplePattern) mapPolygonDataLayer.Symbolizer.Patterns[0]; - Assert.AreEqual(1, firstPattern.Outline.GetWidth()); + Assert.AreEqual(2, firstPattern.Outline.GetWidth()); Assert.AreEqual(0, mapPolygonDataLayer.DataSet.Features.Count); } Index: Core/Components/test/Core.Components.Gis.Test/Data/MapPolygonDataTest.cs =================================================================== diff -u -r67284323e2785c651633d9c52049ba12a9c70e6a -r7aa6b8425147795b1a87b552fe9d82ae5e9c7565 --- Core/Components/test/Core.Components.Gis.Test/Data/MapPolygonDataTest.cs (.../MapPolygonDataTest.cs) (revision 67284323e2785c651633d9c52049ba12a9c70e6a) +++ Core/Components/test/Core.Components.Gis.Test/Data/MapPolygonDataTest.cs (.../MapPolygonDataTest.cs) (revision 7aa6b8425147795b1a87b552fe9d82ae5e9c7565) @@ -21,12 +21,14 @@ using System; using System.Collections.Generic; +using System.Drawing; using System.Linq; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using Core.Components.Gis.Data; using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; +using Core.Components.Gis.Style; using NUnit.Framework; namespace Core.Components.Gis.Test.Data @@ -44,6 +46,9 @@ Assert.AreEqual("test data", data.Name); Assert.IsEmpty(data.Features); Assert.IsInstanceOf(data); + Assert.AreEqual(Color.DarkGray, data.Style.FillColor); + Assert.AreEqual(Color.Black, data.Style.StrokeColor); + Assert.AreEqual(2, data.Style.Width); } [Test] @@ -61,6 +66,33 @@ } [Test] + public void Constructor_StyleNull_ThrowArgumentNullException() + { + // Call + TestDelegate test = () => new MapPolygonData("test data", null); + + // Assert + var exception = Assert.Throws(test); + Assert.AreEqual("style", exception.ParamName); + } + + [Test] + public void Constructor_WithStyle_ExpectedValues() + { + // Setup + var style = new PolygonStyle(Color.Aqua, Color.DarkGoldenrod, 3); + + // Call + var data = new MapPolygonData("test data", style); + + // Assert + Assert.AreEqual("test data", data.Name); + Assert.IsEmpty(data.Features); + Assert.IsInstanceOf(data); + Assert.AreSame(style, data.Style); + } + + [Test] public void Features_SetValidNewValue_GetsNewValue() { // Setup