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); }
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); }
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); }
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); }
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); }
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); }