LinestringTests.cs
上传用户:sex100000
上传日期:2013-11-09
资源大小:1377k
文件大小:1k
源码类别:

GIS编程

开发平台:

C#

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Collections.ObjectModel;
  4. using NUnit.Framework;
  5. using SharpMap.Geometries;
  6. namespace UnitTests.Geometries
  7. {
  8. [TestFixture]
  9. public class LinestringTests
  10. {
  11. [Test]
  12. public void Linestring()
  13. {
  14. LineString l = new LineString();
  15. Assert.IsTrue(l.IsEmpty());
  16. Assert.IsNull(l.GetBoundingBox());
  17. Assert.AreEqual(0, l.Length);
  18. Assert.IsFalse(l.Equals(null));
  19. Assert.IsTrue(l.Equals(new LineString()));
  20. Collection<Point> vertices = new Collection<Point>();
  21. vertices.Add(new Point(54, 23));
  22. vertices.Add(new Point(93, 12));
  23. vertices.Add(new Point(104, 32));
  24. l.Vertices = vertices;
  25. Assert.IsFalse(l.IsEmpty());
  26. Assert.IsFalse(l.IsClosed);
  27. Assert.AreEqual(3, l.NumPoints);
  28. Assert.AreEqual(new Point(54, 23), l.StartPoint);
  29. Assert.AreEqual(new Point(104,32), l.EndPoint);
  30. l.Vertices.Add(new Point(54, 23));
  31. Assert.IsTrue(l.IsClosed);
  32. Assert.AreEqual(114.15056678325843, l.Length);
  33. Assert.AreNotSame(l.Clone(), l);
  34. Assert.AreNotSame(l.Clone().Vertices[0], l.Vertices[0]);
  35. Assert.AreEqual(l.Clone(), l);
  36. LineString l2 = l.Clone();
  37. l2.Vertices[2] = l2.Vertices[2] + new Point(1, 1);
  38. Assert.AreNotEqual(l2, l);
  39. l2 = l.Clone();
  40. l2.Vertices.Add(new Point(34, 23));
  41. Assert.AreNotEqual(l2, l);
  42. }
  43. }
  44. }