using System; using NetTopologySuite.Geometries; using NUnit.Framework; namespace Deltares.Maps.Tests.Domain { [TestFixture] public class FeatureTest { private Feature feature; #region Setup [TestFixtureSetUp] public void FixtureSetup() { } [TestFixtureTearDown] public void FixtureTearDown() { } [SetUp] public void TestSetup() { } [TearDown] public void TestTearDown() { } #endregion [Test] public void FeatureCreation_NormalScenario_CreatesFeatureInstance() { const string geometryWkt = "POINT (0.1 0.2)"; feature = Feature.Create(geometryWkt); Assert.IsNotNull(feature); Assert.AreEqual(geometryWkt, feature.WktFormat); feature = Feature.Create(geometryWkt); Assert.IsNotNull(feature); Assert.AreEqual(geometryWkt, feature.WktFormat); Assert.IsInstanceOf(typeof(Point), feature.Geometry); } [Test] //[ExpectedException(typeof(ArgumentException), ExpectedMessage = "There was an error parsing the WKT geometry string, maybe due to an incorrect culture format conversion")] [ExpectedException(typeof(ArgumentException))] public void FeatueCreation_DutchCultureWktStringFormat_Throws() { Action test = () => { string geometryWkt = string.Format("MULTIPOINT ({0} {1},{2} {3})", 0.1, 0.2, 0.3, 0.4); feature = Feature.Create(geometryWkt); }; CultureHelper.InvokeWithDutchCulture(test); } [Test] public void FeatureCreation_DutchCulture_FeatureIsCreatedWithoutExceptions() { Action test = () => { const string geometryWkt = "MULTIPOINT (0.0 0.1,0.2 0.3)"; feature = Feature.Create(geometryWkt); Assert.IsNotNull(feature); Assert.AreEqual(geometryWkt, feature.WktFormat); Assert.IsInstanceOf(typeof(MultiPoint), feature.Geometry); }; CultureHelper.InvokeWithDutchCulture(test); } } }