public async Task SearchAddressShouldReturnAddressResponse() { var address = await _googleGeocodingApi.SearchAddress(_client, Address1).ConfigureAwait(false); Assert.Equal("OK", address.Status); Assert.NotEmpty(address.Results); Assert.NotEmpty(address.Results.Where(p => p.FormattedAddress == Address1)); }
public async Task <GeocodedAddress> GeocodeAddress(string address) { var httpClient = new HttpClient(); var googleGeocodingApi = new GoogleGeocodingApi(Configuration["GoogleApiKey"]); var loc = await googleGeocodingApi.SearchAddress(httpClient, address); var result = new GeocodedAddress { County = loc.Results.FirstOrDefault()?.CityShortName?.Replace("County", ""), State = loc.Results.FirstOrDefault()?.StateLongName }; return(result); }