Beispiel #1
0
        public void UpdateRateLimit_WithMashapeClientHeaders_Equal()
        {
            var client   = new MashapeClient("123", "1234", "jhjhjhjh");
            var endpoint = new MockEndpoint(client);
            var response = new HttpResponseMessage();

            response.Headers.TryAddWithoutValidation("X-RateLimit-Requests-Limit", "123");
            response.Headers.TryAddWithoutValidation("X-RateLimit-Requests-Remaining", "345");

            endpoint.UpdateRateLimit(response.Headers);

            Assert.Equal(123, endpoint.ApiClient.RateLimit.ClientLimit);
            Assert.Equal(345, endpoint.ApiClient.RateLimit.ClientRemaining);

            response.Headers.Remove("X-RateLimit-Requests-Limit");
            response.Headers.Remove("X-RateLimit-Requests-Remaining");

            response.Headers.TryAddWithoutValidation("X-RateLimit-Requests-Limit", "122");
            response.Headers.TryAddWithoutValidation("X-RateLimit-Requests-Remaining", "344");

            endpoint.UpdateRateLimit(response.Headers);

            Assert.Equal(122, endpoint.ApiClient.RateLimit.ClientLimit);
            Assert.Equal(344, endpoint.ApiClient.RateLimit.ClientRemaining);
        }
Beispiel #2
0
        public void UpdateRateLimit_WithHeadersNull_ThrowArgumentException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new MockEndpoint(client);

            var exception = Record.Exception(() => endpoint.UpdateRateLimit(null));

            Assert.NotNull(exception);
            Assert.IsType <ArgumentNullException>(exception);
        }
Beispiel #3
0
        public void UpdateRateLimit_WithImgurClientHeadersRemoved_Equal()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new MockEndpoint(client);
            var response = new HttpResponseMessage();

            response.Headers.TryAddWithoutValidation("X-RateLimit-ClientLimit", "123");
            response.Headers.TryAddWithoutValidation("X-RateLimit-ClientRemaining", "345");

            endpoint.UpdateRateLimit(response.Headers);

            Assert.Equal(123, endpoint.ApiClient.RateLimit.ClientLimit);
            Assert.Equal(345, endpoint.ApiClient.RateLimit.ClientRemaining);

            response.Headers.Remove("X-RateLimit-ClientLimit");
            response.Headers.Remove("X-RateLimit-ClientRemaining");

            endpoint.UpdateRateLimit(response.Headers);

            Assert.Equal(123, endpoint.ApiClient.RateLimit.ClientLimit);
            Assert.Equal(345, endpoint.ApiClient.RateLimit.ClientRemaining);
        }