Ejemplo n.º 1
0
        public void ProcessEndpointBaseResponse_WithResponseNull_ThrowsImgurException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new MockEndpoint(client);

            var exception = Record.Exception(() => endpoint.ProcessEndpointResponse <bool>(null));

            Assert.NotNull(exception);
            Assert.IsType <ImgurException>(exception);
        }
Ejemplo n.º 2
0
        public void ProcessEndpointResponse_WithSuccessfulResponse_Equal()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new MockEndpoint(client);

            var response = new HttpResponseMessage {
                Content = new StringContent(MockGenericEndpointResponses.SuccessfulResponse)
            };

            var result = endpoint.ProcessEndpointResponse <bool>(response);

            Assert.True(result);
        }
Ejemplo n.º 3
0
        public void ProcessMashapeEndpointResponse_WithoutAuthorization_ThrowMashapeException()
        {
            var client   = new MashapeClient("123", "567567", "1234");
            var endpoint = new MockEndpoint(client);

            var response = new HttpResponseMessage {
                Content = new StringContent(MockErrors.MashapeError)
            };

            var exception = Record.Exception(() => endpoint.ProcessEndpointResponse <RateLimit>(response));

            Assert.NotNull(exception);
            Assert.IsType <MashapeException>(exception);
        }
Ejemplo n.º 4
0
        public void ProcessImgurEndpointResponse_WithImgurCacheErrorResponse_ThrowsImgurException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new MockEndpoint(client);

            var response = new HttpResponseMessage {
                Content = new StringContent("<html>")
            };

            var exception = Record.Exception(() => endpoint.ProcessEndpointResponse <RateLimit>(response));

            Assert.NotNull(exception);
            Assert.IsType <ImgurException>(exception);
        }
Ejemplo n.º 5
0
        public void ProcessEndpointBaseResponse_WithStringResponseNull_ThrowsImgurException()
        {
            var client   = new ImgurClient("123", "1234");
            var endpoint = new MockEndpoint(client);

            var response = new HttpResponseMessage {
                Content = new StringContent("")
            };

            var exception = Record.Exception(() => endpoint.ProcessEndpointResponse <bool>(response));

            Assert.NotNull(exception);
            Assert.IsType <ImgurException>(exception);
        }
Ejemplo n.º 6
0
        private IOAuth2Token GetToken()
        {
            if (_token != null)
            {
                return(_token);
            }

            var endpoint = new MockEndpoint(new ImgurClient("a", "b"));
            var response = new HttpResponseMessage
            {
                Content = new StringContent(MockOAuth2EndpointResponses.GetTokenByCode)
            };

            _token = endpoint.ProcessEndpointResponse <OAuth2Token>(response);
            return(_token);
        }