Exemple #1
0
        public async Task CallZomatoApi_ByDefault_ReturnsNearby()
        {
            var zomatoApiClient = new ZomatoClient(_httpClient, _zomatoOptions);
            var result          = await zomatoApiClient.CallZomatoApi(It.IsAny <double>(), It.IsAny <double>());

            Assert.IsType <Nearby>(result);
        }
Exemple #2
0
        public async Task CallZomatoApi_WhenRequestNotSuccessful_ThrowsApiCallException()
        {
            _response.StatusCode = HttpStatusCode.BadRequest;

            var zomatoApiClient = new ZomatoClient(_httpClient, _zomatoOptions);

            await Assert.ThrowsAsync <ApiCallException>
                (() => zomatoApiClient.CallZomatoApi(It.IsAny <double>(), It.IsAny <double>()));
        }
Exemple #3
0
        public async Task CallZomatoApi_ByDefault_HttpClientGet()
        {
            var zomatoApiClient = new ZomatoClient(_httpClient, _zomatoOptions);
            var result          = await zomatoApiClient.CallZomatoApi(It.IsAny <double>(), It.IsAny <double>());

            _handlerMock.Protected().Verify("SendAsync", Times.Once(),
                                            ItExpr.Is <HttpRequestMessage>
                                                (req => req.Method == HttpMethod.Get),
                                            ItExpr.IsAny <CancellationToken>());
        }
Exemple #4
0
        public async Task CallZomatoApi_ByDefault_CallsRightUri()
        {
            var zomatoApiClient = new ZomatoClient
                                      (_httpClient, _zomatoOptions);
            var result = await zomatoApiClient.CallZomatoApi(It.IsAny <double>(), It.IsAny <double>());

            var expectedUri = new Uri(BaseUrl + "geocode?lat=0.0000&lon=0.0000");

            _handlerMock.Protected().Verify("SendAsync", Times.Once(),
                                            ItExpr.Is <HttpRequestMessage>
                                                (req => req.RequestUri == expectedUri),
                                            ItExpr.IsAny <CancellationToken>());
        }