예제 #1
0
        public async Task WhenGetCountryIso3CodeByCoordinateAsync_ThenReturnsIso3CountryCode()
        {
            var mockResponseData = "{\"results\" : [{" +
                                   "\"access_points\" : []," +
                                   "\"address_components\" : [{" +
                                   "\"long_name\" : \"Netherlands\"," +
                                   $" \"short_name\" : \"{CountryIso2Code}\"," +
                                   " \"types\" : [ \"country\", \"political\"]" +
                                   "}]}]}";
            var mockCoordinate = double.MinValue;

            _geocodingRestService.Setup(arg => arg.GetCountryDataByCoordinateAsync(It.IsAny <double>(), It.IsAny <double>()))
            .ReturnsAsync(mockResponseData);

            var result = await _geocodingReader.GetCountryIso3CodeByCoordinateAsync(mockCoordinate, mockCoordinate);

            Assert.Equal(result, CountryIso3Code);
        }
예제 #2
0
 private async Task SetCountryIso3Code(Location location)
 {
     location.CountryIso3Code = IsCoordinatesDetermined(location)
         ? await _geocodingReader.GetCountryIso3CodeByCoordinateAsync(location.Latitude.Value, location.Longitude.Value)
         : null;
 }