Implemented Delete for IssueCommentsClient

This commit is contained in:
Peter MacNaughton
2014-01-21 10:52:46 -07:00
parent 97cf290e94
commit 889b4484f3
3 changed files with 52 additions and 0 deletions
@@ -143,6 +143,32 @@ public class IssueCommentsClientTests
}
}
public class TheDeleteMethod
{
[Fact]
public void DeletesCorrectUrl()
{
var connection = Substitute.For<IApiConnection>();
var client = new IssueCommentsClient(connection);
client.Delete("fake", "repo", 42);
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/issues/comments/42"));
}
[Fact]
public async Task EnsuresArgumentsNotNullOrEmpty()
{
var connection = Substitute.For<IApiConnection>();
var client = new IssueCommentsClient(connection);
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete(null, "name", 42));
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("", "name", 42));
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete("owner", null, 42));
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("owner", "", 42));
}
}
public class TheCtor
{
[Fact]
+10
View File
@@ -64,5 +64,15 @@ namespace Octokit
/// <param name="commentUpdate">The modified comment</param>
/// <returns></returns>
Task<IssueComment> Update(string owner, string name, int number, string commentUpdate);
/// <summary>
/// Deletes the specified Issue Comment
/// </summary>
/// <remarks>http://developer.github.com/v3/issues/comments/#delete-a-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment number</param>
/// <returns></returns>
Task Delete(string owner, string name, int number);
}
}
+16
View File
@@ -102,5 +102,21 @@ namespace Octokit
return ApiConnection.Patch<IssueComment>(ApiUrls.IssueComment(owner, name, number), new BodyWrapper(commentUpdate));
}
/// <summary>
/// Deletes the specified Issue Comment
/// </summary>
/// <remarks>http://developer.github.com/v3/issues/comments/#delete-a-comment</remarks>
/// <param name="owner">The owner of the repository</param>
/// <param name="name">The name of the repository</param>
/// <param name="number">The comment number</param>
/// <returns></returns>
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));
}
}
}