Ejemplo n.º 1
0
        public async Task GivenValidRequest_ThenHasExpectedResponseItems(string postalCode)
        {
            var response = await HttpRequestFactory.GetAnonymous(_clientApiUrl, $"json?address={postalCode}");

            dynamic responseContent = response.ContentAsDynamic();

            Assert.NotNull(responseContent.results);
            Assert.NotNull(responseContent.results[0].place_id);
            Assert.NotNull(responseContent.results[0].formatted_address);
        }
Ejemplo n.º 2
0
        public async Task <GeoLocation> GetDetails(string postalCode)
        {
            var response = await HttpRequestFactory.GetAnonymous(_clientApiUrl, $"json?address={postalCode}");

            var responseContent = response.ContentAsType <GoogleMapsResults>();

            var adminLevel1 = responseContent.results.SelectMany(result => result.address_components.Where(component => component.types.Any(type => type == "administrative_area_level_1")));

            var location = new GeoLocation()
            {
                Province = adminLevel1.First().short_name
            };

            return(location);
        }
Ejemplo n.º 3
0
        public async Task GivenValidRequest_ThenHasExpectedResponseCode()
        {
            var response = await HttpRequestFactory.GetAnonymous(_clientApiUrl, $"json?address=J3Y%209H5");

            Assert.Equal(HttpStatusCode.OK, response.StatusCode);
        }