public void Add(string message) { Messages = Messages == null ? new List<string>() : Messages; Messages.Add(message); //now geocode something and populate the local properties of this convo var locationer = new Locationer(_geocoder); var locationResult = locationer.GetForMessage(message); locationResult.Locations = locationResult.Locations ?? new List<Location>(); //bleh Locations = Locations == null ? new List<Location>() : Locations; Locations = locationResult.Locations; }
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]); }
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); } }
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); } }