GetCommentIdsAsync() public method

Return a list of all of the comment IDs.
/// 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 GetCommentIdsAsync ( 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>
コード例 #1
0
        public async Task GetCommentIdsAsync_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret);
            var endpoint = new AccountEndpoint(client);

            var comments = await endpoint.GetCommentIdsAsync("sarah");

            Assert.AreEqual(50, comments.Count());
        }
コード例 #2
0
        public async Task GetCommentIdsAsync_WithUsernameNull_ThrowsArgumentNullException()
        {
            var client = new ImgurClient("123", "1234");
            var endpoint = new AccountEndpoint(client);

            var exception =
                await
                    Record.ExceptionAsync(
                        async () => await endpoint.GetCommentIdsAsync(null).ConfigureAwait(false))
                        .ConfigureAwait(false);
            Assert.NotNull(exception);
            Assert.IsType<ArgumentNullException>(exception);
        }
コード例 #3
0
        public async Task GetCommentIdsAsync_Equal()
        {
            var mockUrl = "https://api.imgur.com/3/account/bob/comments/ids/worst/2";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockAccountEndpointResponses.GetCommentIds)
            };

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

            Assert.Equal(50, comments.Count());
        }
コード例 #4
0
        public async Task GetCommentIdsAsync_WithValidReponse_AreEqual()
        {
            var client = new ImgurClient(ClientId, ClientSecret, await GetOAuth2Token());
            var endpoint = new AccountEndpoint(client);

            var comments = await endpoint.GetCommentIdsAsync();

            Assert.IsTrue(comments.Count() > 1);
        }
コード例 #5
0
 public async Task GetCommentIdsAsync_WithUsernameNull_ThrowsArgumentNullException()
 {
     var client = new ImgurClient("123", "1234");
     var endpoint = new AccountEndpoint(client);
     await endpoint.GetCommentIdsAsync(null);
 }
コード例 #6
0
        public async Task GetCommentIdsAsync_AreEqual()
        {
            var fakeHttpMessageHandler = new FakeHttpMessageHandler();
            var fakeResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(AccountEndpointResponses.GetCommentIdsResponse)
            };

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

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

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