using System; using System.Collections.ObjectModel; using Core.Common.TestUtil; using Core.Components.Gis.Data; using NUnit.Framework; namespace Core.Components.DotSpatial.Test.Data { [TestFixture] public class MapPolygonDataTest { [Test] public void Constructor_NullPoints_ThrowsArgumentNullException() { // Call TestDelegate test = () => new MapPolygonData(null); // Assert TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, string.Format("A point collection is required when creating a subclass of {0}.", typeof(PointBasedMapData))); } [Test] public void Constructor_WithEmptyPoints_CreatesNewMapPolygonData() { // Setup var points = new Collection>(); // Call var data = new MapPolygonData(points); // Assert Assert.IsInstanceOf(data); Assert.AreNotSame(points, data.Points); } [Test] public void Constructor_WithPoints_CreatesNewMapPolygonData() { // Setup var points = CreateTestPoints(); // Call var data = new MapPolygonData(points); // Assert Assert.IsInstanceOf(data); Assert.AreNotSame(points, data.Points); CollectionAssert.AreEqual(points, data.Points); } private static Collection> CreateTestPoints() { return new Collection> { new Tuple(0.0, 1.1), new Tuple(1.0, 2.1), new Tuple(1.6, 1.6) }; } } }