GetCommentsAsync() public method

Return the comments the user has created.
/// Thrown when a null reference is passed to a method that does not accept it as a /// valid argument. /// Thrown when an error is found in a response from an Imgur endpoint. Thrown when an error is found in a response from a Mashape endpoint.
public GetCommentsAsync ( string username = "me", CommentSortOrder sort = CommentSortOrder.Newest, int page = null ) : Task>
username string The user account. Default: me
sort CommentSortOrder The order that the comments should be sorted by. Default: Newest
page int Allows you to set the page number so you don't have to retrieve all the data at once. Default: null
return Task>
Ejemplo n.º 1
0
        public async Task GetCommentsAsync_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new AccountEndpoint(client);

            var comments = await endpoint.GetCommentsAsync("sarah", CommentSortOrder.Best);

            Assert.AreEqual(50, comments.Count());
        }
        public async Task GetCommentsAsync_WithUsernameNull_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client);

            var exception =
                await
                    Record.ExceptionAsync(
                        async () => await endpoint.GetCommentsAsync(null).ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
        public async Task GetCommentsAsync_Equal()
        {
            var mockUrl = "https://api.imgur.com/3/account/bob/comments/worst/2";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAccountEndpointResponses.GetComments)
            };

            var client = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var comments = await endpoint.GetCommentsAsync("bob", CommentSortOrder.Worst, 2).ConfigureAwait(false);

            Assert.Equal(50, comments.Count());
        }
        public async Task GetCommentsAsync_WithValidReponse_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret, await GetOAuth2Token());
            var endpoint = new AccountEndpoint(client);

            var comments = await endpoint.GetCommentsAsync();

            Assert.IsTrue(comments.Count() >= 2);
        }
 public async Task GetCommentsAsync_WithUsernameNull_ThrowsArgumentNullException()
 {
     var client = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetCommentsAsync(null);
 }
        public async Task GetCommentsAsync_AreEqual()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetCommentsResponse)
            };

            fakeHttpMessageHandler.AddFakeResponse(new Uri("https://api.imgur.com/3/account/bob/comments/worst/2"),
                fakeResponse);

            var client = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client, new HttpClient(fakeHttpMessageHandler));
            var comments = await endpoint.GetCommentsAsync("bob", CommentSortOrder.Worst, 2);

            Assert.AreEqual(50, comments.Count());
        }