public async Task Error_is_returned_for_empty_request()
        {
            var geocodeRequest = new GeocodeRequest();

            var response = await bingGeocoder.GeocodeAddressAsync(geocodeRequest);

            Assert.Equal(GeocodeStatus.Error, response.ResponseStatus);
        }
Exemple #2
0
        public async Task GeocodeAddressAsync_Should_Call_Bing_Locations_API_And_Return_List_Of_SingleAddressResponse(
            string address,
            string city,
            string stateProvince,
            string postalCode,
            string country
            )
        {
            // Arrange
            var mockHttpClientWrapper = new Mock <IHttpClientWrapper>();

            using var mockHttpResponseMessage = new HttpResponseMessage()
                  {
                      Content = new StringContent(GetMockHttpResponseMessage(out int expectedOutputAddresses))
                  };

            mockHttpClientWrapper.Setup(mock => mock.GetAsync(It.IsAny <Uri>())).ReturnsAsync(mockHttpResponseMessage);

            var bingOptions = Options.Create(
                new BingOptions()
            {
                ApiRootUrl = "https://foo.bar",
                GeocodeSingleAddressEndpoint = "baz/qux"
            }
                );

            var bingGeocoder = new BingGeocoder(mockHttpClientWrapper.Object, bingOptions);

            // Act
            var result = await bingGeocoder.GeocodeAddressAsync(address, city, stateProvince, postalCode, country).ConfigureAwait(false);

            // Assert
            Assert.That(result is List <SingleAddressGeocodeResponse>);
            Assert.That(result.Count == expectedOutputAddresses);
        }