Example #1
0
        public void ParseMessageForLocation()
        {
            //ASSIGN
            var geoservice = new Locationer(null);

            //ACT
            var geoparts = geoservice.Parse(Message1);

            //ASSERT
            Assert.AreEqual(2, geoparts.Count);
            Assert.That(geoparts[0].Contains("morrissons"), "Expected to find Morrisons in part 1, instead was '{0}'", geoparts[0]);
            Assert.That(geoparts[1].Contains("leeds"), "Expected to find Leeds in part 2, instead was '{0}'", geoparts[1]);
        }
Example #2
0
        public void AnyHitsFor(string message, bool shouldFindSomething)
        {
            var service = new Locationer(null);
            var parsedText = service.Parse(message);
            var query = string.Join(",", parsedText);

            var hits = service.GetForMessage(query);

            if (shouldFindSomething) {
                Assert.That(hits.Locations.Count > 0, "Expected some locations to be returned. Instead there was none.");
            }
            else {
                Assert.That(hits.Locations.Count == 0, "Expected no results. Instead found {0} locations for the phrase '{1}'", hits.Locations.Count, message);
            }
        }
Example #3
0
        public void GeolocateMessageViaMapquest()
        {
            var geoservice = new Locationer(null);

            //1. Parse message
            var parts = geoservice.Parse(Message1);

            //2. Concat
            var query = string.Join(",", parts);

            //3. Geocode query
            var result = new MapquestGeocoder().Geocode(query);

            Assert.NotNull(result);
            Assert.GreaterOrEqual(result.Locations.Count, 1);

            foreach (var location in result.Locations)
            {
                Console.WriteLine(location.Description);
            }
        }