mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 11:40:42 +00:00
Added ApiUrls, updated gist- and comment id to be strings, added failing tests
This commit is contained in:
@@ -22,13 +22,24 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new GistCommentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get(null, "1337"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Get("24", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Get("", "1337"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Get("24", ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.Get(24, 1337);
|
||||
await client.Get("24", "1337");
|
||||
|
||||
connection.Received().Get<GistComment>(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments/1337"), null);
|
||||
}
|
||||
@@ -36,13 +47,22 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
public class TheGetForGistMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new GistCommentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.GetForGist(null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.GetForGist(""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.GetForGist(24);
|
||||
await client.GetForGist("24");
|
||||
|
||||
connection.Received().GetAll<GistComment>(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments"), null);
|
||||
}
|
||||
@@ -55,8 +75,10 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var client = new GistCommentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(24, null));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(24, ""));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create(null, "Comment"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Create("24", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Create("", "Comment"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Create("24", ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -66,7 +88,7 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.Create(24, comment);
|
||||
await client.Create("24", comment);
|
||||
|
||||
connection.Received().Post<GistComment>(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments"), comment);
|
||||
}
|
||||
@@ -79,8 +101,12 @@ namespace Octokit.Tests.Clients
|
||||
{
|
||||
var client = new GistCommentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update(24, 1337, null));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update(24, 1337, ""));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update(null, "1337", "Comment"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update("24", null, "Comment"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Update("24", "1337", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Update("", "1337", "Comment"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Update("24", "", "Comment"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Update("24", "1337", ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -90,7 +116,7 @@ namespace Octokit.Tests.Clients
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.Update(24, 1337, comment);
|
||||
await client.Update("24", "1337", comment);
|
||||
|
||||
connection.Received().Patch<GistComment>(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments/1337"), comment);
|
||||
}
|
||||
@@ -98,13 +124,24 @@ namespace Octokit.Tests.Clients
|
||||
|
||||
public class TheDeleteMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new GistCommentsClient(Substitute.For<IApiConnection>());
|
||||
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete(null, "1337"));
|
||||
await AssertEx.Throws<ArgumentNullException>(async () => await client.Delete("24", null));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("", "1337"));
|
||||
await AssertEx.Throws<ArgumentException>(async () => await client.Delete("24", ""));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostsToCorrectUrl()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new GistCommentsClient(connection);
|
||||
|
||||
await client.Delete(24, 1337);
|
||||
await client.Delete("24", "1337");
|
||||
|
||||
connection.Received().Delete(Arg.Is<Uri>(u => u.ToString() == "gists/24/comments/1337"));
|
||||
}
|
||||
|
||||
@@ -9,32 +9,43 @@ namespace Octokit
|
||||
{
|
||||
}
|
||||
|
||||
public Task<GistComment> Get(int gistId, int commentId)
|
||||
public Task<GistComment> Get(string gistId, string commentId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId");
|
||||
Ensure.ArgumentNotNullOrEmptyString(commentId, "commentId");
|
||||
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<IReadOnlyList<GistComment>> GetForGist(int gistId)
|
||||
public Task<IReadOnlyList<GistComment>> GetForGist(string gistId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId");
|
||||
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<GistComment> Create(int gistId, string comment)
|
||||
public Task<GistComment> Create(string gistId, string comment)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId");
|
||||
Ensure.ArgumentNotNullOrEmptyString(comment, "comment");
|
||||
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public Task<GistComment> Update(int gistId, int commentId, string comment)
|
||||
public Task<GistComment> Update(string gistId, string commentId, string comment)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId");
|
||||
Ensure.ArgumentNotNullOrEmptyString(commentId, "commentId");
|
||||
Ensure.ArgumentNotNullOrEmptyString(comment, "comment");
|
||||
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
|
||||
public Task Delete(int gistId, int commentId)
|
||||
public Task Delete(string gistId, string commentId)
|
||||
{
|
||||
Ensure.ArgumentNotNullOrEmptyString(gistId, "gistId");
|
||||
Ensure.ArgumentNotNullOrEmptyString(commentId, "commentId");
|
||||
|
||||
throw new System.NotImplementedException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,10 +8,10 @@ namespace Octokit
|
||||
{
|
||||
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
|
||||
Justification = "Method makes a network request")]
|
||||
Task<GistComment> Get(int gistId, int commentId);
|
||||
Task<IReadOnlyList<GistComment>> GetForGist(int gistId);
|
||||
Task<GistComment> Create(int gistId, string comment);
|
||||
Task<GistComment> Update(int gistId, int commentId, string comment);
|
||||
Task Delete(int gistId, int commentId);
|
||||
Task<GistComment> Get(string gistId, string commentId);
|
||||
Task<IReadOnlyList<GistComment>> GetForGist(string gistId);
|
||||
Task<GistComment> Create(string gistId, string comment);
|
||||
Task<GistComment> Update(string gistId, string commentId, string comment);
|
||||
Task Delete(string gistId, string commentId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -457,6 +457,25 @@ namespace Octokit
|
||||
return "gists/{0}".FormatUri(id);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for the comments for the specified gist.
|
||||
/// </summary>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
public static Uri GistComments(string gistId)
|
||||
{
|
||||
return "gists/{0}/comments".FormatUri(gistId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for a spesific comment for the specified commit.
|
||||
/// </summary>
|
||||
/// <param name="gistId">The id of the gist</param>
|
||||
/// <param name="commentId">The id of the comment</param>
|
||||
public static Uri GistComment(string gistId, string commentId)
|
||||
{
|
||||
return "gists/{0}/comments/{1}".FormatUri(gistId, commentId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Returns the <see cref="Uri"/> for the specified commit.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user