ImgurNet.ApiEndpoints.CommentEndpoint.DeleteCommentAsync C# (CSharp) Method

DeleteCommentAsync() public method

Delete a comment by the given id
public DeleteCommentAsync ( System.Int64 commentId ) : Task>
commentId System.Int64 The Id of the comment
return Task>
		public async Task<ImgurResponse<Boolean>> DeleteCommentAsync(Int64 commentId)
		{
			if (ImgurClient.Authentication == null)
				throw new InvalidAuthenticationException("Authentication can not be null. Set it in the main Imgur class.");

			if (!(ImgurClient.Authentication is OAuth2Authentication))
				throw new InvalidAuthenticationException("You need to use OAuth2Authentication to call this Endpoint.");

			return
				await
					Request.SubmitImgurRequestAsync<Boolean>(Request.HttpMethod.Delete, String.Format(CommentDeleteUrl, commentId),
						ImgurClient.Authentication);
		}

Usage Example

		public async Task TestDeleteComment()
		{
			var imgurClient = await AuthenticationHelpers.CreateOAuth2AuthenticatedImgurClient();
			var commentEndpoint = new CommentEndpoint(imgurClient);
			var comment = await commentEndpoint.CreateCommentAsync("test reply", "161n8BB", 193421419);
			var deleteComment = await commentEndpoint.DeleteCommentAsync(comment.Data.Id);

			// Assert the Reponse
			Assert.IsNotNull(comment.Data);
			Assert.AreEqual(comment.Success, true);
			Assert.AreEqual(comment.Status, HttpStatusCode.OK);

			// Assert the Data
			Assert.AreEqual(deleteComment.Data, true);
		}