public async Task VoteCommentAsync_WithIdNull_ThrowsArgumentNullException() { var fakeOAuth2Handler = new FakeOAuth2TokenHandler(); var client = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse()); var endpoint = new CommentEndpoint(client); await endpoint.VoteCommentAsync(null, Vote.Down); }
public async Task TestVoteComment() { var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient(); var commentEndpoint = new CommentEndpoint(imgurClient); var comment = await commentEndpoint.GetCommentAsync(193421419); var votedComment = await commentEndpoint.VoteCommentAsync(comment.Data.Id, VoteDirection.Up); // Assert the Reponse Assert.IsNotNull(votedComment.Data); Assert.AreEqual(votedComment.Success, true); Assert.AreEqual(votedComment.Status, HttpStatusCode.OK); }
public async Task VoteCommentAsync_WithOAuth2TokenNull_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234"); var endpoint = new CommentEndpoint(client); var exception = await Record.ExceptionAsync( async() => await endpoint.VoteCommentAsync(539556821, VoteOption.Down).ConfigureAwait(false)) .ConfigureAwait(false); Assert.NotNull(exception); Assert.IsType <ArgumentNullException>(exception); }
public async Task VoteCommentAsync_True() { var mockUrl = "https://api.imgur.com/3/comment/539556821/vote/down"; var mockResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(MockCommentEndpointResponses.VoteComment) }; var client = new ImgurClient("123", "1234", MockOAuth2Token); var endpoint = new CommentEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse))); var reported = await endpoint.VoteCommentAsync(539556821, VoteOption.Down).ConfigureAwait(false); Assert.True(reported); }
public async Task VoteCommentAsync_IsTrue() { var fakeHttpMessageHandler = new FakeHttpMessageHandler(); var fakeResponse = new HttpResponseMessage(HttpStatusCode.OK) { Content = new StringContent(CommentEndpointResponses.VoteCommentResponse) }; fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/comment/539556821/vote/down"), fakeResponse); var fakeOAuth2Handler = new FakeOAuth2TokenHandler(); var client = new ImgurClient("123", "1234", fakeOAuth2Handler.GetOAuth2TokenCodeResponse()); var endpoint = new CommentEndpoint(client, new HttpClient(fakeHttpMessageHandler)); var reported = await endpoint.VoteCommentAsync("539556821", Vote.Down); Assert.IsTrue(reported); }
public async Task VoteCommentAsync_WithOAuth2TokenNull_ThrowsArgumentNullException() { var client = new ImgurClient("123", "1234"); var endpoint = new CommentEndpoint(client); await endpoint.VoteCommentAsync("539556821", Vote.Down); }