Imgur.API.Endpoints.Impl.CommentEndpoint.GetRepliesAsync C# (CSharp) Method

GetRepliesAsync() public method

Get the comment with all of the replies for the comment.
/// 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 GetRepliesAsync ( int commentId ) : Task
commentId int The comment id.
return Task
        public async Task<IComment> GetRepliesAsync(int commentId)
        {
            var url = $"comment/{commentId}/replies";

            using (var request = RequestBuilder.CreateRequest(HttpMethod.Get, url))
            {
                var comment = await SendRequestAsync<Comment>(request).ConfigureAwait(false);
                return comment;
            }
        }

Usage Example

コード例 #1
0
        public async Task GetRepliesAsync_True()
        {
            var mockUrl = "https://api.imgur.com/3/comment/539556821/replies";
            var mockResponse = new HttpResponseMessage(HttpStatusCode.OK)
            {
                Content = new StringContent(MockCommentEndpointResponses.GetCommentReplies)
            };

            var client = new ImgurClient("123", "1234");
            var endpoint = new CommentEndpoint(client, new HttpClient(new MockHttpMessageHandler(mockUrl, mockResponse)));
            var comments = await endpoint.GetRepliesAsync(539556821).ConfigureAwait(false);

            Assert.True(comments.Children.Count() == 7);
        }