diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs index 06a9ba63..e3091e90 100644 --- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs +++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs @@ -143,6 +143,32 @@ public class IssueCommentsClientTests } } + public class TheDeleteMethod + { + [Fact] + public void DeletesCorrectUrl() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + client.Delete("fake", "repo", 42); + + connection.Received().Delete(Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42")); + } + + [Fact] + public async Task EnsuresArgumentsNotNullOrEmpty() + { + var connection = Substitute.For(); + var client = new IssueCommentsClient(connection); + + await AssertEx.Throws(async () => await client.Delete(null, "name", 42)); + await AssertEx.Throws(async () => await client.Delete("", "name", 42)); + await AssertEx.Throws(async () => await client.Delete("owner", null, 42)); + await AssertEx.Throws(async () => await client.Delete("owner", "", 42)); + } + } + public class TheCtor { [Fact] diff --git a/Octokit/Clients/IIssueCommentsClient.cs b/Octokit/Clients/IIssueCommentsClient.cs index 7261018d..dd3c2795 100644 --- a/Octokit/Clients/IIssueCommentsClient.cs +++ b/Octokit/Clients/IIssueCommentsClient.cs @@ -64,5 +64,15 @@ namespace Octokit /// The modified comment /// Task Update(string owner, string name, int number, string commentUpdate); + + /// + /// Deletes the specified Issue Comment + /// + /// http://developer.github.com/v3/issues/comments/#delete-a-comment + /// The owner of the repository + /// The name of the repository + /// The comment number + /// + Task Delete(string owner, string name, int number); } } diff --git a/Octokit/Clients/IssueCommentsClient.cs b/Octokit/Clients/IssueCommentsClient.cs index f705199f..dc0c8846 100644 --- a/Octokit/Clients/IssueCommentsClient.cs +++ b/Octokit/Clients/IssueCommentsClient.cs @@ -102,5 +102,21 @@ namespace Octokit return ApiConnection.Patch(ApiUrls.IssueComment(owner, name, number), new BodyWrapper(commentUpdate)); } + + /// + /// Deletes the specified Issue Comment + /// + /// http://developer.github.com/v3/issues/comments/#delete-a-comment + /// The owner of the repository + /// The name of the repository + /// The comment number + /// + public Task Delete(string owner, string name, int number) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + + return ApiConnection.Delete(ApiUrls.IssueComment(owner, name, number)); + } } }