HamOntFire / HamOntFire.Test / MapGeneratorTests.cs

using HamOntFire.Core;
using NUnit.Framework;
using Raven.Client;
using Raven.Client.Embedded;

namespace HamOntFire.Test
{
    [TestFixture]
    public class MapGeneratorTests
    {
        private MapGenerator _generator;
        IDocumentStore _store;
        private IDocumentSession _session;

        [SetUp]
        public void InitialiseTest()
        {
            _store = new EmbeddableDocumentStore
                {
                    RunInMemory = true
                };
            _store.Initialize();

            _session = _store.OpenSession();
            _generator = new MapGenerator();
        }

        [Test]
        public void LocationInFlamboroughShouldHaveLowXLowY()
        {
            var lat = 43.3315696m;
            var lng = -79.909654m;
            int x = _generator.LongitudeToX(lng);
            int y = _generator.LatitudeToY(lat);

            Assert.AreEqual(498, x);
            Assert.AreEqual(283, y);
        }

        [Test]
        public void LocationInAncasterShouldHaveLowXHighY()
        {
            var lat = 43.1930519m;
            var lng = -80.0232868m;
            int x = _generator.LongitudeToX(lng);
            int y = _generator.LatitudeToY(lat);

            Assert.AreEqual(334, x);
            Assert.AreEqual(559, y);
        }

        [Test]
        public void LocationInGlanbrookShouldHaveHighXHighY()
        {
            var lat = 43.1774448m;
            var lng = -79.808948m;
            int x = _generator.LongitudeToX(lng);
            int y = _generator.LatitudeToY(lat);

            Assert.AreEqual(643, x);
            Assert.AreEqual(590, y);
        }

        [Test]
        public void LocationOnSafariRd()
        {
            var lat = 43.3399592m;
            var lng = -80.1516106m;
            int x = _generator.LongitudeToX(lng);
            int y = _generator.LatitudeToY(lat);

            Assert.AreEqual(148, x);
            Assert.AreEqual(267, y);
        }
    }
}
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.