예제 #1
0
        public async void GetContent_when_connection_forbidden_returns_response_with_statuscode()
        {
            var response = new ImgurRatelimitResponse();
            var handler  = StubHttpClient.GetHandler();

            handler.AddResponse(new Uri("https://api.imgur.com/3/credits"), HttpStatusCode.Forbidden, new ApiHelper <ImgurRatelimitResponse> {
                Data = response
            });

            var source = new ImgurRatelimitSource(StubHttpClient.Create(handler));
            var result = await source.GetContent();

            Assert.NotNull(result);
            Assert.Equal(HttpStatusCode.Forbidden, result.StatusCode);
        }
예제 #2
0
        public async void GetContent_success_returns_ratelimit_response()
        {
            var response = new ImgurRatelimitResponse {
                ClientRemaining = 10, ClientLimit = 20, UserLimit = 30, UserRemaining = 40, UserReset = 50
            };
            var handler = StubHttpClient.GetHandler();

            handler.AddResponse(new Uri("https://api.imgur.com/3/credits"), HttpStatusCode.OK, new ApiHelper <ImgurRatelimitResponse> {
                Data = response
            });

            var source = new ImgurRatelimitSource(StubHttpClient.Create(handler));
            var result = await source.GetContent();

            Assert.NotNull(result);
            Assert.Equal(response.ClientRemaining, result.ClientRemaining);
            Assert.Equal(response.ClientLimit, result.ClientLimit);
            Assert.Equal(response.UserLimit, result.UserLimit);
            Assert.Equal(response.UserRemaining, result.UserRemaining);
            Assert.Equal(response.UserReset, result.UserReset);
            Assert.Equal(HttpStatusCode.OK, result.StatusCode);
        }