PointTests.cs :  » GIS » SharpMap » UnitTests » Geometries » C# / CSharp Open Source

Home
C# / CSharp Open Source
1.2.6.4 mono .net core
2.2.6.4 mono core
3.Aspect Oriented Frameworks
4.Bloggers
5.Build Systems
6.Business Application
7.Charting Reporting Tools
8.Chat Servers
9.Code Coverage Tools
10.Content Management Systems CMS
11.CRM ERP
12.Database
13.Development
14.Email
15.Forum
16.Game
17.GIS
18.GUI
19.IDEs
20.Installers Generators
21.Inversion of Control Dependency Injection
22.Issue Tracking
23.Logging Tools
24.Message
25.Mobile
26.Network Clients
27.Network Servers
28.Office
29.PDF
30.Persistence Frameworks
31.Portals
32.Profilers
33.Project Management
34.RSS RDF
35.Rule Engines
36.Script
37.Search Engines
38.Sound Audio
39.Source Control
40.SQL Clients
41.Template Engines
42.Testing
43.UML
44.Web Frameworks
45.Web Service
46.Web Testing
47.Wiki Engines
48.Windows Presentation Foundation
49.Workflows
50.XML Parsers
C# / C Sharp
C# / C Sharp by API
C# / CSharp Tutorial
C# / CSharp Open Source » GIS » SharpMap 
SharpMap » UnitTests » Geometries » PointTests.cs
using NUnit.Framework;
using SharpMap.Geometries;

namespace UnitTests.Geometries{
    [TestFixture]
    public class PointTests
    {
        [Test]
        public void Point()
        {
            //Do various Point method calls to cover the point class with sufficient testing
            Point p0 = new Point();
            Point p1 = new Point(0, 0);
            Point p2 = new Point(450, 120);
            Assert.IsTrue(p0.IsEmpty());
            Assert.IsFalse(p1.IsEmpty());
            Assert.AreNotEqual(p0, p1);
            Assert.AreEqual(450, p2.X);
            Assert.AreEqual(120, p2.Y);
            Assert.AreNotSame(p2.Clone(), p2);
            p0 = p2.Clone();
            p0.X += 100;
            p0.Y = 150;
            p0[0] += p0[1];
            Assert.AreEqual(new Point(700, 150), p0);
            Assert.AreEqual(p2, p2.GetBoundingBox().Min);
            Assert.AreEqual(p2, p2.GetBoundingBox().Max);
            Assert.IsTrue(p2.IsSimple());
            Assert.IsFalse(p2.IsEmpty());
            Assert.AreEqual(2, p2.NumOrdinates);
            Assert.AreEqual(new Point(400, 100), p2 + new Point(-50, -20));
            Assert.AreEqual(new Point(500, 100), p2 - new Point(-50, 20));
            Assert.AreEqual(new Point(900, 240), p2*2);
            Assert.AreEqual(0, p2.Dimension);
            Assert.AreEqual(450, p2[0]);
            Assert.AreEqual(120, p2[1]);
            Assert.IsNull(p2.Boundary());
            Assert.AreEqual(p2.X.GetHashCode() ^ p2.Y.GetHashCode() ^ p2.IsEmpty().GetHashCode(), p2.GetHashCode());
            Assert.Greater(p2.CompareTo(p1), 0);
            Assert.Less(p1.CompareTo(p2), 0);
            Assert.AreEqual(p2.CompareTo(new Point(450, 120)), 0);
        }

        [Test]
        public void Point3D()
        {
            //Do various Point method calls to cover the point class with sufficient testing
            Point3D p0 = new Point3D();
            Point p = new Point(23, 21);
            Point3D p1 = new Point3D(450, 120, 34);
            Point3D p2 = new Point3D(p, 94);
            Assert.IsTrue(p0.IsEmpty());
            Assert.IsFalse(p1.IsEmpty());
            Assert.IsFalse(p2.IsEmpty());

            Assert.AreNotEqual(p, p2);
            Assert.AreEqual(94, p2.Z);

            Assert.AreNotSame(p1.Clone(), p1);
            p0 = p1.Clone();
            p0.X += 100;
            p0.Y = 150;
            p0.Z += 499;
            p0[2] += p0[2];
            Assert.AreEqual(new Point3D(550, 150, 1066), p0);
            Assert.AreEqual(p2.AsPoint(), p2.GetBoundingBox().Min);
            Assert.AreEqual(p2.AsPoint(), p2.GetBoundingBox().Max);
            Assert.AreEqual(3, p2.NumOrdinates);
            Assert.AreEqual(new Point3D(-27, 1, 123), p2 + new Point3D(-50, -20, 29));
            Assert.AreEqual(new Point(73, 1), p2 - new Point(-50, 20));
            Assert.AreEqual(new Point3D(46, 42, 188), p2*2);
            Assert.AreEqual(0, p2.Dimension);
            Assert.AreEqual(23, p2[0]);
            Assert.AreEqual(21, p2[1]);
            Assert.AreEqual(94, p2[2]);
            Assert.IsNull(p2.Boundary());
            Assert.AreEqual(p2.X.GetHashCode() ^ p2.Y.GetHashCode() ^ p2.Z.GetHashCode() ^ p2.IsEmpty().GetHashCode(),
                            p2.GetHashCode());
            Assert.Less(p2.CompareTo(p1), 0);
            Assert.Greater(p1.CompareTo(p2), 0);
            Assert.AreEqual(0, p2.CompareTo(new Point3D(23, 21, 94)));
            Assert.AreEqual(0, p2.CompareTo(new Point(23, 21)));
        }
    }
}
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.