public async Task TestGeocodeAddressWithPartialMatchViaGeocodeRequest() { const string address = "21 Henr St, Bristol, UK"; var client = new GeocodeClient(settings.GeocodeAPIKey); var result = await client.GeocodeRequest(new GeocodeRequest { address = address }); Assert.AreEqual(GeocodeStatus.Ok, result.Status); Assert.AreEqual(true, result.Results.All(r => r.PartialMatch)); Assert.AreEqual(true, result.Results.Length > 0); }
public async Task TestGeocodeAddressWithRegionViaGeocodeRequest() { var client = new GeocodeClient(settings.GeocodeAPIKey); var result = await client.GeocodeRequest(new GeocodeRequest { address = "London", region = "ca" }); Assert.AreEqual(GeocodeStatus.Ok, result.Status); Assert.AreEqual("London, ON, Canada", result.Results.First().FormattedAddress); result = await client.GeocodeRequest(new GeocodeRequest { address = "London", region = "uk" }); Assert.AreEqual(GeocodeStatus.Ok, result.Status); Assert.AreEqual("London, UK", result.Results.First().FormattedAddress); }
public async Task TestGeocodeAddressWithRegionBoundsComponentsAndLanguageViaGeocodeRequest() { var client = new GeocodeClient(settings.GeocodeAPIKey); var result = await client.GeocodeRequest(new GeocodeRequest { address = "London", region = "ca", bounds = new GeoViewport{ Northeast = new GeoCoordinate{Latitude = -51.5073509m, Longitude = -0.1277583m }, Southwest = new GeoCoordinate{Latitude = 51.5073509m, Longitude = 0.1277583m } }, components = GeocodeComponent.locality, language = "en-GB" }); Assert.AreEqual(GeocodeStatus.Ok, result.Status); Assert.AreEqual("London, ON, Canada", result.Results.First().FormattedAddress); }
public async Task TestReverseGeocodeWithLocationResultTypeLanguageResultViaGeocodeReverseRequest() { if (string.IsNullOrEmpty(settings.GeocodeAPIKey)) { Assert.Inconclusive("APIKey was not provided"); return; } var client = new GeocodeClient(settings.GeocodeAPIKey); var result = await client.GeocodeRequest( new GeocodeReverseRequest { latlng = new GeoCoordinate { Latitude = 51.5073509m, Longitude = -0.1277583m }, language = "en-GB", location_type = LocationType.Approximate, result_type = GeocodeComponent.locality }); Assert.AreEqual(GeocodeStatus.Ok, result.Status); Assert.IsTrue(result.Results.Any(i => i.FormattedAddress == "London, UK")); }
public async Task TestReverseGeocodeWithLanguageResultViaGeocodeReverseRequest() { var client = new GeocodeClient(settings.GeocodeAPIKey); var result = await client.GeocodeRequest( new GeocodeReverseRequest { latlng = new GeoCoordinate { Latitude = 51.5073509m, Longitude = -0.1277583m }, language = "en-GB", }); Assert.AreEqual(GeocodeStatus.Ok, result.Status); Assert.IsTrue(result.Results.Any(i => i.FormattedAddress == "3 Whitehall, London SW1A 2DD, UK")); }
public async Task TestReversePlaceIdViaGeocodeReverseRequest() { if (string.IsNullOrEmpty(settings.GeocodeAPIKey)) { Assert.Inconclusive("APIKey was not provided"); return; } var client = new GeocodeClient(settings.GeocodeAPIKey); var result = await client.GeocodeRequest(new GeocodeReverseRequest { placeid = "ChIJb9KHxsgEdkgRe82UfSxQIv0" }); Assert.AreEqual(GeocodeStatus.Ok, result.Status); Assert.IsTrue(result.Results.Any(i => i.FormattedAddress == "London WC2N, UK")); }