diff --git a/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs
index 906a8814..4d387dae 100644
--- a/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableIssueCommentsClient.cs
@@ -4,6 +4,12 @@ using System.Reactive;
namespace Octokit.Reactive
{
+ ///
+ /// A client for GitHub's Issue Comments API.
+ ///
+ ///
+ /// See the Issue Comments API documentation for more information.
+ ///
public interface IObservableIssueCommentsClient
{
///
@@ -13,20 +19,35 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The issue comment id
- /// The s for the specified Issue Comment.
[SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
Justification = "Method makes a network request")]
IObservable Get(string owner, string name, int id);
+ ///
+ /// Gets a single Issue Comment by id.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#get-a-single-comment
+ /// The ID of the repository
+ /// The issue comment id
+ [SuppressMessage("Microsoft.Naming", "CA1716:IdentifiersShouldNotMatchKeywords", MessageId = "Get",
+ Justification = "Method makes a network request")]
+ IObservable Get(int repositoryId, int id);
+
///
/// Gets Issue Comments for a repository.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
/// The owner of the repository
/// The name of the repository
- /// The list of s for the specified Repository.
IObservable GetAllForRepository(string owner, string name);
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The ID of the repository
+ IObservable GetAllForRepository(int repositoryId);
+
///
/// Gets Issue Comments for a repository.
///
@@ -34,9 +55,16 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
- /// The list of s for the specified Repository.
IObservable GetAllForRepository(string owner, string name, ApiOptions options);
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The ID of the repository
+ /// Options for changing the API response
+ IObservable GetAllForRepository(int repositoryId, ApiOptions options);
+
///
/// Gets Issue Comments for a specified Issue.
///
@@ -44,9 +72,16 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The issue number
- /// The list of s for the specified Issue.
IObservable GetAllForIssue(string owner, string name, int number);
+ ///
+ /// Gets Issue Comments for a specified Issue.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
+ /// The ID of the repository
+ /// The issue number
+ IObservable GetAllForIssue(int repositoryId, int number);
+
///
/// Gets Issue Comments for a specified Issue.
///
@@ -55,9 +90,17 @@ namespace Octokit.Reactive
/// The name of the repository
/// The issue number
/// Options for changing the API response
- /// The list of s for the specified Issue.
IObservable GetAllForIssue(string owner, string name, int number, ApiOptions options);
+ ///
+ /// Gets Issue Comments for a specified Issue.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
+ /// The ID of the repository
+ /// The issue number
+ /// Options for changing the API response
+ IObservable GetAllForIssue(int repositoryId, int number, ApiOptions options);
+
///
/// Creates a new Issue Comment for a specified Issue.
///
@@ -66,9 +109,17 @@ namespace Octokit.Reactive
/// The name of the repository
/// The number of the issue
/// The text of the new comment
- /// The that was just created.
IObservable Create(string owner, string name, int number, string newComment);
+ ///
+ /// Creates a new Issue Comment for a specified Issue.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#create-a-comment
+ /// The ID of the repository
+ /// The number of the issue
+ /// The text of the new comment
+ IObservable Create(int repositoryId, int number, string newComment);
+
///
/// Updates a specified Issue Comment.
///
@@ -77,9 +128,17 @@ namespace Octokit.Reactive
/// The name of the repository
/// The comment id
/// The modified comment
- /// The that was just updated.
IObservable Update(string owner, string name, int id, string commentUpdate);
+ ///
+ /// Updates a specified Issue Comment.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#edit-a-comment
+ /// The ID of the repository
+ /// The comment id
+ /// The modified comment
+ IObservable Update(int repositoryId, int id, string commentUpdate);
+
///
/// Deletes the specified Issue Comment
///
@@ -87,7 +146,14 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The comment id
- ///
IObservable Delete(string owner, string name, int id);
+
+ ///
+ /// Deletes the specified Issue Comment
+ ///
+ /// http://developer.github.com/v3/issues/comments/#delete-a-comment
+ /// The ID of the repository
+ /// The comment id
+ IObservable Delete(int repositoryId, int id);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs
index f0011cf2..37b42c67 100644
--- a/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableIssueCommentsClient.cs
@@ -5,6 +5,12 @@ using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
+ ///
+ /// A client for GitHub's Issue Comments API.
+ ///
+ ///
+ /// See the Issue Comments API documentation for more information.
+ ///
public class ObservableIssueCommentsClient : IObservableIssueCommentsClient
{
readonly IIssueCommentsClient _client;
@@ -25,7 +31,6 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The issue comment id
- /// The s for the specified Issue Comment.
public IObservable Get(string owner, string name, int id)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -34,13 +39,23 @@ namespace Octokit.Reactive
return _client.Get(owner, name, id).ToObservable();
}
+ ///
+ /// Gets a single Issue Comment by id.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#get-a-single-comment
+ /// The ID of the repository
+ /// The issue comment id
+ public IObservable Get(int repositoryId, int id)
+ {
+ return _client.Get(repositoryId, id).ToObservable();
+ }
+
///
/// Gets Issue Comments for a repository.
///
/// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
/// The owner of the repository
/// The name of the repository
- /// The list of s for the specified Repository.
public IObservable GetAllForRepository(string owner, string name)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -49,6 +64,16 @@ namespace Octokit.Reactive
return GetAllForRepository(owner, name, ApiOptions.None);
}
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The ID of the repository
+ public IObservable GetAllForRepository(int repositoryId)
+ {
+ return GetAllForRepository(repositoryId, ApiOptions.None);
+ }
+
///
/// Gets Issue Comments for a repository.
///
@@ -56,7 +81,6 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// Options for changing the API response
- /// The list of s for the specified Repository.
public IObservable GetAllForRepository(string owner, string name, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -66,6 +90,19 @@ namespace Octokit.Reactive
return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name), null, AcceptHeaders.ReactionsPreview, options);
}
+ ///
+ /// Gets Issue Comments for a repository.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-in-a-repository
+ /// The ID of the repository
+ /// Options for changing the API response
+ public IObservable GetAllForRepository(int repositoryId, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(repositoryId), options);
+ }
+
///
/// Gets Issue Comments for a specified Issue.
///
@@ -73,7 +110,6 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The issue number
- /// The list of s for the specified Issue.
public IObservable GetAllForIssue(string owner, string name, int number)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -82,6 +118,17 @@ namespace Octokit.Reactive
return GetAllForIssue(owner, name, number, ApiOptions.None);
}
+ ///
+ /// Gets Issue Comments for a specified Issue.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
+ /// The ID of the repository
+ /// The issue number
+ public IObservable GetAllForIssue(int repositoryId, int number)
+ {
+ return GetAllForIssue(repositoryId, number, ApiOptions.None);
+ }
+
///
/// Gets Issue Comments for a specified Issue.
///
@@ -90,7 +137,6 @@ namespace Octokit.Reactive
/// The name of the repository
/// The issue number
/// Options for changing the API response
- /// The list of s for the specified Issue.
public IObservable GetAllForIssue(string owner, string name, int number, ApiOptions options)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -100,6 +146,20 @@ namespace Octokit.Reactive
return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(owner, name, number), null, AcceptHeaders.ReactionsPreview, options);
}
+ ///
+ /// Gets Issue Comments for a specified Issue.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#list-comments-on-an-issue
+ /// The ID of the repository
+ /// The issue number
+ /// Options for changing the API response
+ public IObservable GetAllForIssue(int repositoryId, int number, ApiOptions options)
+ {
+ Ensure.ArgumentNotNull(options, "options");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.IssueComments(repositoryId, number), options);
+ }
+
///
/// Creates a new Issue Comment for a specified Issue.
///
@@ -108,7 +168,6 @@ namespace Octokit.Reactive
/// The name of the repository
/// The number of the issue
/// The text of the new comment
- /// The that was just created.
public IObservable Create(string owner, string name, int number, string newComment)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -118,6 +177,20 @@ namespace Octokit.Reactive
return _client.Create(owner, name, number, newComment).ToObservable();
}
+ ///
+ /// Creates a new Issue Comment for a specified Issue.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#create-a-comment
+ /// The ID of the repository
+ /// The number of the issue
+ /// The text of the new comment
+ public IObservable Create(int repositoryId, int number, string newComment)
+ {
+ Ensure.ArgumentNotNull(newComment, "newComment");
+
+ return _client.Create(repositoryId, number, newComment).ToObservable();
+ }
+
///
/// Updates a specified Issue Comment.
///
@@ -126,7 +199,6 @@ namespace Octokit.Reactive
/// The name of the repository
/// The comment id
/// The modified comment
- /// The that was just updated.
public IObservable Update(string owner, string name, int id, string commentUpdate)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -136,6 +208,20 @@ namespace Octokit.Reactive
return _client.Update(owner, name, id, commentUpdate).ToObservable();
}
+ ///
+ /// Updates a specified Issue Comment.
+ ///
+ /// http://developer.github.com/v3/issues/comments/#edit-a-comment
+ /// The ID of the repository
+ /// The comment id
+ /// The modified comment
+ public IObservable Update(int repositoryId, int id, string commentUpdate)
+ {
+ Ensure.ArgumentNotNull(commentUpdate, "commentUpdate");
+
+ return _client.Update(repositoryId, id, commentUpdate).ToObservable();
+ }
+
///
/// Deletes the specified Issue Comment
///
@@ -143,7 +229,6 @@ namespace Octokit.Reactive
/// The owner of the repository
/// The name of the repository
/// The comment id
- ///
public IObservable Delete(string owner, string name, int id)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -151,5 +236,16 @@ namespace Octokit.Reactive
return _client.Delete(owner, name, id).ToObservable();
}
+
+ ///
+ /// Deletes the specified Issue Comment
+ ///
+ /// http://developer.github.com/v3/issues/comments/#delete-a-comment
+ /// The ID of the repository
+ /// The comment id
+ public IObservable Delete(int repositoryId, int id)
+ {
+ return _client.Delete(repositoryId, id).ToObservable();
+ }
}
-}
+}
\ No newline at end of file
diff --git a/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs
index ceb375a0..071a841e 100644
--- a/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/IssueCommentsClientTests.cs
@@ -1,53 +1,475 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using System.Threading.Tasks;
+using System.Threading.Tasks;
using Octokit;
using Octokit.Tests.Integration;
+using Octokit.Tests.Integration.Helpers;
using Xunit;
public class IssueCommentsClientTests
{
- private readonly IIssueCommentsClient _issueCommentsClient;
-
- public IssueCommentsClientTests()
+ public class TheGetMethod
{
- var github = Helper.GetAuthenticatedClient();
- _issueCommentsClient = github.Issue.Comment;
+ readonly IIssueCommentsClient _issueCommentsClient;
+
+ const string owner = "octokit";
+ const string name = "octokit.net";
+ const int id = 12067722;
+ const int repositoryId = 7528679;
+
+ public TheGetMethod()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ _issueCommentsClient = github.Issue.Comment;
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsIssueComment()
+ {
+ var comment = await _issueCommentsClient.Get(owner, name, id);
+
+ Assert.NotNull(comment);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsIssueCommentWithRepositoryId()
+ {
+ var comment = await _issueCommentsClient.Get(repositoryId, id);
+
+ Assert.NotNull(comment);
+ }
}
- [IntegrationTest]
- public async Task CanDeserializeIssueCommentWhenGettingAllForRepository()
+ public class TheGetAllForRepositoryMethod
{
- var comments = await _issueCommentsClient.GetAllForRepository("alfhenrik-test", "repo-with-issue-comment-reactions");
+ readonly IIssueCommentsClient _issueCommentsClient;
- Assert.NotEmpty(comments);
- var comment = comments[0];
- Assert.NotNull(comment.Reactions);
- Assert.Equal(3, comment.Reactions.TotalCount);
- Assert.Equal(1, comment.Reactions.Plus1);
- Assert.Equal(1, comment.Reactions.Hooray);
- Assert.Equal(1, comment.Reactions.Heart);
- Assert.Equal(0, comment.Reactions.Laugh);
- Assert.Equal(0, comment.Reactions.Confused);
- Assert.Equal(0, comment.Reactions.Minus1);
+ const string owner = "octokit";
+ const string name = "octokit.net";
+ const int repositoryId = 7528679;
+
+ public TheGetAllForRepositoryMethod()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ _issueCommentsClient = github.Issue.Comment;
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsIssueComments()
+ {
+ var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name);
+
+ Assert.NotEmpty(issueComments);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsIssueCommentsWithRepositoryId()
+ {
+ var issueComments = await _issueCommentsClient.GetAllForRepository(repositoryId);
+
+ Assert.NotEmpty(issueComments);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfIssueCommentsWithoutStart()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options);
+
+ Assert.Equal(5, issueComments.Count);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfIssueCommentsWithRepositoryIdWithoutStart()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var issueComments = await _issueCommentsClient.GetAllForRepository(repositoryId, options);
+
+ Assert.Equal(5, issueComments.Count);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfIssueCommentsWithStart()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options);
+
+ Assert.Equal(5, issueComments.Count);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfIssueCommentsWithRepositoryIdWithStart()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var issueComments = await _issueCommentsClient.GetAllForRepository(repositoryId, options);
+
+ Assert.Equal(5, issueComments.Count);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsDistinctResultsBasedOnStartPage()
+ {
+ var startOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var firstPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, startOptions);
+
+ var skipStartOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var secondPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, skipStartOptions);
+
+ Assert.NotEqual(firstPageIssueComments[0].Id, secondPageIssueComments[0].Id);
+ Assert.NotEqual(firstPageIssueComments[1].Id, secondPageIssueComments[1].Id);
+ Assert.NotEqual(firstPageIssueComments[2].Id, secondPageIssueComments[2].Id);
+ Assert.NotEqual(firstPageIssueComments[3].Id, secondPageIssueComments[3].Id);
+ Assert.NotEqual(firstPageIssueComments[4].Id, secondPageIssueComments[4].Id);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsDistinctResultsBasedOnStartPageWithRepositoryId()
+ {
+ var startOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var firstPageIssueComments = await _issueCommentsClient.GetAllForRepository(repositoryId, startOptions);
+
+ var skipStartOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var secondPageIssueComments = await _issueCommentsClient.GetAllForRepository(repositoryId, skipStartOptions);
+
+ Assert.NotEqual(firstPageIssueComments[0].Id, secondPageIssueComments[0].Id);
+ Assert.NotEqual(firstPageIssueComments[1].Id, secondPageIssueComments[1].Id);
+ Assert.NotEqual(firstPageIssueComments[2].Id, secondPageIssueComments[2].Id);
+ Assert.NotEqual(firstPageIssueComments[3].Id, secondPageIssueComments[3].Id);
+ Assert.NotEqual(firstPageIssueComments[4].Id, secondPageIssueComments[4].Id);
+ }
}
- [IntegrationTest]
- public async Task CanDeserializeIssueComment()
+ public class TheGetAllForIssueMethod
{
- var comments = await _issueCommentsClient.GetAllForIssue("alfhenrik-test", "repo-with-issue-comment-reactions", 1);
+ readonly IIssueCommentsClient _issueCommentsClient;
- Assert.NotEmpty(comments);
- var comment = comments[0];
- Assert.NotNull(comment.Reactions);
- Assert.Equal(3, comment.Reactions.TotalCount);
- Assert.Equal(1, comment.Reactions.Plus1);
- Assert.Equal(1, comment.Reactions.Hooray);
- Assert.Equal(1, comment.Reactions.Heart);
- Assert.Equal(0, comment.Reactions.Laugh);
- Assert.Equal(0, comment.Reactions.Confused);
- Assert.Equal(0, comment.Reactions.Minus1);
+ const string owner = "octokit";
+ const string name = "octokit.net";
+ const int number = 1115;
+ const int repositoryId = 7528679;
+
+ public TheGetAllForIssueMethod()
+ {
+ var github = Helper.GetAuthenticatedClient();
+
+ _issueCommentsClient = github.Issue.Comment;
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsIssueComments()
+ {
+ var issueComments = await _issueCommentsClient.GetAllForIssue(owner, name, number);
+
+ Assert.NotEmpty(issueComments);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsIssueCommentsWithRepositoryId()
+ {
+ var issueComments = await _issueCommentsClient.GetAllForIssue(repositoryId, number);
+
+ Assert.NotEmpty(issueComments);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfIssueCommentsWithoutStart()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var issueComments = await _issueCommentsClient.GetAllForIssue(owner, name, number, options);
+
+ Assert.Equal(5, issueComments.Count);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfIssueCommentsWithRepositoryIdWithoutStart()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var issueComments = await _issueCommentsClient.GetAllForIssue(repositoryId, number, options);
+
+ Assert.Equal(5, issueComments.Count);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfIssueCommentsWithStart()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var issueComments = await _issueCommentsClient.GetAllForIssue(owner, name, number, options);
+
+ Assert.Equal(5, issueComments.Count);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsCorrectCountOfIssueCommentsWithRepositoryIdWithStart()
+ {
+ var options = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var issueComments = await _issueCommentsClient.GetAllForIssue(repositoryId, number, options);
+
+ Assert.Equal(5, issueComments.Count);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsDistinctResultsBasedOnStartPage()
+ {
+ var startOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var firstPageIssueComments = await _issueCommentsClient.GetAllForIssue(owner, name, number, startOptions);
+
+ var skipStartOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var secondPageIssueComments = await _issueCommentsClient.GetAllForIssue(owner, name, number, skipStartOptions);
+
+ Assert.NotEqual(firstPageIssueComments[0].Id, secondPageIssueComments[0].Id);
+ Assert.NotEqual(firstPageIssueComments[1].Id, secondPageIssueComments[1].Id);
+ Assert.NotEqual(firstPageIssueComments[2].Id, secondPageIssueComments[2].Id);
+ Assert.NotEqual(firstPageIssueComments[3].Id, secondPageIssueComments[3].Id);
+ Assert.NotEqual(firstPageIssueComments[4].Id, secondPageIssueComments[4].Id);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsDistinctResultsBasedOnStartPageWithRepositoryId()
+ {
+ var startOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1
+ };
+
+ var firstPageIssueComments = await _issueCommentsClient.GetAllForIssue(repositoryId, number, startOptions);
+
+ var skipStartOptions = new ApiOptions
+ {
+ PageSize = 5,
+ PageCount = 1,
+ StartPage = 2
+ };
+
+ var secondPageIssueComments = await _issueCommentsClient.GetAllForIssue(repositoryId, number, skipStartOptions);
+
+ Assert.NotEqual(firstPageIssueComments[0].Id, secondPageIssueComments[0].Id);
+ Assert.NotEqual(firstPageIssueComments[1].Id, secondPageIssueComments[1].Id);
+ Assert.NotEqual(firstPageIssueComments[2].Id, secondPageIssueComments[2].Id);
+ Assert.NotEqual(firstPageIssueComments[3].Id, secondPageIssueComments[3].Id);
+ Assert.NotEqual(firstPageIssueComments[4].Id, secondPageIssueComments[4].Id);
+ }
+ }
+
+ public class TheCreateMethod
+ {
+ readonly IIssueCommentsClient _issueCommentsClient;
+ readonly RepositoryContext _context;
+ readonly IIssuesClient _issuesClient;
+
+ public TheCreateMethod()
+ {
+ var gitHubClient = Helper.GetAuthenticatedClient();
+
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ _context = gitHubClient.CreateRepositoryContext(new NewRepository(repoName)).Result;
+
+ _issuesClient = gitHubClient.Issue;
+ _issueCommentsClient = gitHubClient.Issue.Comment;
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsIssueComment()
+ {
+ var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("Super Issue 1"));
+
+ var comment = await _issueCommentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, "test comment 1");
+
+ var loadedComment = await _issueCommentsClient.Get(_context.RepositoryOwner, _context.RepositoryName, comment.Id);
+
+ Assert.Equal(comment.Id, loadedComment.Id);
+ Assert.Equal(comment.Body, loadedComment.Body);
+ }
+
+ [IntegrationTest]
+ public async Task ReturnsIssueCommentWithRepositoryId()
+ {
+ var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("Super Issue 2"));
+
+ var comment = await _issueCommentsClient.Create(_context.Repository.Id, issue.Number, "test comment 2");
+
+ var loadedComment = await _issueCommentsClient.Get(_context.Repository.Id, comment.Id);
+
+ Assert.Equal(comment.Id, loadedComment.Id);
+ Assert.Equal(comment.Body, loadedComment.Body);
+ }
+ }
+
+ public class TheUpdateMethod
+ {
+ readonly IIssueCommentsClient _issueCommentsClient;
+ readonly RepositoryContext _context;
+ readonly IIssuesClient _issuesClient;
+
+ public TheUpdateMethod()
+ {
+ var gitHubClient = Helper.GetAuthenticatedClient();
+
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ _context = gitHubClient.CreateRepositoryContext(new NewRepository(repoName)).Result;
+
+ _issuesClient = gitHubClient.Issue;
+ _issueCommentsClient = gitHubClient.Issue.Comment;
+ }
+
+ [IntegrationTest]
+ public async Task UpdateIssueComment()
+ {
+ var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("Super Issue 1"));
+
+ var comment = await _issueCommentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, "test comment 1");
+ var commentId = comment.Id;
+
+ var beforeComment = await _issueCommentsClient.Get(_context.RepositoryOwner, _context.RepositoryName, commentId);
+
+ await _issueCommentsClient.Update(_context.RepositoryOwner, _context.RepositoryName, commentId, "test comment 2");
+
+ var afterComment = await _issueCommentsClient.Get(_context.RepositoryOwner, _context.RepositoryName, commentId);
+
+ Assert.Equal(beforeComment.Id, afterComment.Id);
+ Assert.NotEqual(beforeComment.Body, afterComment.Body);
+ Assert.Equal("test comment 2", afterComment.Body);
+ }
+
+ [IntegrationTest]
+ public async Task UpdateIssueWithRepositoryId()
+ {
+ var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("Super Issue 1"));
+
+ var comment = await _issueCommentsClient.Create(_context.Repository.Id, issue.Number, "test comment 1");
+ var commentId = comment.Id;
+
+ var beforeComment = await _issueCommentsClient.Get(_context.Repository.Id, commentId);
+
+ await _issueCommentsClient.Update(_context.Repository.Id, commentId, "test comment 2");
+
+ var afterComment = await _issueCommentsClient.Get(_context.Repository.Id, commentId);
+
+ Assert.Equal(beforeComment.Id, afterComment.Id);
+ Assert.NotEqual(beforeComment.Body, afterComment.Body);
+ Assert.Equal("test comment 2", afterComment.Body);
+ }
+ }
+
+ public class TheDeleteMethod
+ {
+ readonly IIssueCommentsClient _issueCommentsClient;
+ readonly RepositoryContext _context;
+ readonly IIssuesClient _issuesClient;
+
+ public TheDeleteMethod()
+ {
+ var gitHubClient = Helper.GetAuthenticatedClient();
+
+ var repoName = Helper.MakeNameWithTimestamp("public-repo");
+
+ _context = gitHubClient.CreateRepositoryContext(new NewRepository(repoName)).Result;
+
+ _issuesClient = gitHubClient.Issue;
+ _issueCommentsClient = gitHubClient.Issue.Comment;
+ }
+
+ [IntegrationTest]
+ public async Task DeleteIssueComment()
+ {
+ var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("Super Issue 1"));
+
+ var comment = await _issueCommentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, issue.Number, "test comment 1");
+
+ await _issueCommentsClient.Delete(_context.RepositoryOwner, _context.RepositoryName, comment.Id);
+
+ await Assert.ThrowsAsync(() => _issueCommentsClient.Get(_context.RepositoryOwner, _context.RepositoryName, comment.Id));
+ }
+
+ [IntegrationTest]
+ public async Task DeleteIssueWithRepositoryId()
+ {
+ var issue = await _issuesClient.Create(_context.RepositoryOwner, _context.RepositoryName, new NewIssue("Super Issue 1"));
+
+ var comment = await _issueCommentsClient.Create(_context.Repository.Id, issue.Number, "test comment 1");
+
+ await _issueCommentsClient.Delete(_context.Repository.Id, comment.Id);
+
+ await Assert.ThrowsAsync(() => _issueCommentsClient.Get(_context.Repository.Id, comment.Id));
+ }
}
}
diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
index aa34483d..3b51a013 100644
--- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
+++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj
@@ -151,7 +151,6 @@
-
diff --git a/Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs b/Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs
deleted file mode 100644
index 11c8b845..00000000
--- a/Octokit.Tests.Integration/Reactive/ObservableIssueCommentsClientTests.cs
+++ /dev/null
@@ -1,126 +0,0 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Reactive.Linq;
-using System.Text;
-using System.Threading.Tasks;
-using Octokit.Reactive;
-using Xunit;
-
-namespace Octokit.Tests.Integration.Reactive
-{
- public class ObservableIssueCommentsClientTests
- {
- public class TheGetAllForRepositoryMethod
- {
- readonly ObservableIssueCommentsClient _issueCommentsClient;
- const string owner = "octokit";
- const string name = "octokit.net";
-
- public TheGetAllForRepositoryMethod()
- {
- var github = Helper.GetAuthenticatedClient();
-
- _issueCommentsClient = new ObservableIssueCommentsClient(github);
- }
-
- [IntegrationTest]
- public async Task ReturnsIssueComments()
- {
- var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name).ToList();
-
- Assert.NotEmpty(issueComments);
- }
-
- [IntegrationTest]
- public async Task ReturnsCorrectCountOfIssueCommentsWithoutStart()
- {
- var options = new ApiOptions
- {
- PageSize = 5,
- PageCount = 1
- };
-
- var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options).ToList();
-
- Assert.Equal(5, issueComments.Count);
- }
-
- [IntegrationTest]
- public async Task ReturnsCorrectCountOfIssueCommentsWithStart()
- {
- var options = new ApiOptions
- {
- PageSize = 5,
- PageCount = 1,
- StartPage = 2
- };
-
- var issueComments = await _issueCommentsClient.GetAllForRepository(owner, name, options).ToList();
-
- Assert.Equal(5, issueComments.Count);
- }
-
- [IntegrationTest]
- public async Task ReturnsDistinctResultsBasedOnStartPage()
- {
- var startOptions = new ApiOptions
- {
- PageSize = 5,
- PageCount = 1
- };
-
- var firstPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, startOptions).ToList();
-
- var skipStartOptions = new ApiOptions
- {
- PageSize = 5,
- PageCount = 1,
- StartPage = 2
- };
-
- var secondPageIssueComments = await _issueCommentsClient.GetAllForRepository(owner, name, skipStartOptions).ToList();
-
- Assert.NotEqual(firstPageIssueComments[0].Id, secondPageIssueComments[0].Id);
- Assert.NotEqual(firstPageIssueComments[1].Id, secondPageIssueComments[1].Id);
- Assert.NotEqual(firstPageIssueComments[2].Id, secondPageIssueComments[2].Id);
- Assert.NotEqual(firstPageIssueComments[3].Id, secondPageIssueComments[3].Id);
- Assert.NotEqual(firstPageIssueComments[4].Id, secondPageIssueComments[4].Id);
- }
-
- [IntegrationTest]
- public async Task ReturnsAllIssueCommentsWithReactions()
- {
- var comments = await _issueCommentsClient.GetAllForRepository("alfhenrik-test", "repo-with-issue-comment-reactions").ToList();
-
- Assert.NotEmpty(comments);
- var comment = comments[0];
- Assert.NotNull(comment.Reactions);
- Assert.Equal(3, comment.Reactions.TotalCount);
- Assert.Equal(1, comment.Reactions.Plus1);
- Assert.Equal(1, comment.Reactions.Hooray);
- Assert.Equal(1, comment.Reactions.Heart);
- Assert.Equal(0, comment.Reactions.Laugh);
- Assert.Equal(0, comment.Reactions.Confused);
- Assert.Equal(0, comment.Reactions.Minus1);
- }
-
- [IntegrationTest]
- public async Task ReturnsIssueCommentWithReactions()
- {
- var comments = await _issueCommentsClient.GetAllForIssue("alfhenrik-test", "repo-with-issue-comment-reactions", 1).ToList();
-
- Assert.NotEmpty(comments);
- var comment = comments[0];
- Assert.NotNull(comment.Reactions);
- Assert.Equal(3, comment.Reactions.TotalCount);
- Assert.Equal(1, comment.Reactions.Plus1);
- Assert.Equal(1, comment.Reactions.Hooray);
- Assert.Equal(1, comment.Reactions.Heart);
- Assert.Equal(0, comment.Reactions.Laugh);
- Assert.Equal(0, comment.Reactions.Confused);
- Assert.Equal(0, comment.Reactions.Minus1);
- }
- }
- }
-}
diff --git a/Octokit.Tests/Clients/IssueCommentsClientTests.cs b/Octokit.Tests/Clients/IssueCommentsClientTests.cs
index 629cf80f..2354e780 100644
--- a/Octokit.Tests/Clients/IssueCommentsClientTests.cs
+++ b/Octokit.Tests/Clients/IssueCommentsClientTests.cs
@@ -13,12 +13,12 @@ namespace Octokit.Tests.Clients
public class TheGetMethod
{
[Fact]
- public void RequestsCorrectUrl()
+ public async Task RequestsCorrectUrl()
{
var connection = Substitute.For();
var client = new IssueCommentsClient(connection);
- client.Get("fake", "repo", 42);
+ await client.Get("fake", "repo", 42);
connection.Received().Get(
Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments/42"),
@@ -26,14 +26,26 @@ namespace Octokit.Tests.Clients
Arg.Is(s => s == "application/vnd.github.squirrel-girl-preview"));
}
+ [Fact]
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentsClient(connection);
+
+ await client.Get(1, 42);
+
+ connection.Received().Get(Arg.Is(u => u.ToString() == "repositories/1/issues/comments/42"));
+ }
+
[Fact]
public async Task EnsuresNonNullArguments()
{
var client = new IssueCommentsClient(Substitute.For());
await Assert.ThrowsAsync(() => client.Get(null, "name", 1));
- await Assert.ThrowsAsync(() => client.Get("", "name", 1));
await Assert.ThrowsAsync(() => client.Get("owner", null, 1));
+
+ await Assert.ThrowsAsync(() => client.Get("", "name", 1));
await Assert.ThrowsAsync(() => client.Get("owner", "", 1));
}
}
@@ -41,12 +53,12 @@ namespace Octokit.Tests.Clients
public class TheGetForRepositoryMethod
{
[Fact]
- public void RequestsCorrectUrl()
+ public async Task RequestsCorrectUrl()
{
var connection = Substitute.For();
var client = new IssueCommentsClient(connection);
- client.GetAllForRepository("fake", "repo");
+ await client.GetAllForRepository("fake", "repo");
connection.Received().GetAll(
Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments"),
@@ -56,7 +68,18 @@ namespace Octokit.Tests.Clients
}
[Fact]
- public void RequestsCorrectUrlWithApiOptions()
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentsClient(connection);
+
+ await client.GetAllForRepository(1);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/comments"), Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithApiOptions()
{
var connection = Substitute.For();
var client = new IssueCommentsClient(connection);
@@ -67,7 +90,8 @@ namespace Octokit.Tests.Clients
PageSize = 1,
StartPage = 1
};
- client.GetAllForRepository("fake", "repo", options);
+
+ await client.GetAllForRepository("fake", "repo", options);
connection.Received().GetAll(
Arg.Is(u => u.ToString() == "repos/fake/repo/issues/comments"),
@@ -77,16 +101,39 @@ namespace Octokit.Tests.Clients
}
[Fact]
- public async Task EnsuresArgumentsNotNull()
+ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentsClient(connection);
+
+ var options = new ApiOptions
+ {
+ PageCount = 1,
+ PageSize = 1,
+ StartPage = 1
+ };
+
+ await client.GetAllForRepository(1, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/comments"), options);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For();
var client = new IssueCommentsClient(connection);
await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name"));
- await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name"));
await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null));
- await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", ""));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository(null, "name", ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForRepository(1, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name"));
+ await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", ""));
await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", ApiOptions.None));
}
@@ -95,12 +142,12 @@ namespace Octokit.Tests.Clients
public class TheGetForIssueMethod
{
[Fact]
- public void RequestsCorrectUrl()
+ public async Task RequestsCorrectUrl()
{
var connection = Substitute.For();
var client = new IssueCommentsClient(connection);
- client.GetAllForIssue("fake", "repo", 3);
+ await client.GetAllForIssue("fake", "repo", 3);
connection.Received().GetAll(
Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
@@ -110,7 +157,18 @@ namespace Octokit.Tests.Clients
}
[Fact]
- public void RequestsCorrectUrlWithApiOptions()
+ public async Task RequestsCorrectUrlWithRepositoryId()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentsClient(connection);
+
+ await client.GetAllForIssue(1, 3);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/3/comments"), Args.ApiOptions);
+ }
+
+ [Fact]
+ public async Task RequestsCorrectUrlWithApiOptions()
{
var connection = Substitute.For();
var client = new IssueCommentsClient(connection);
@@ -121,7 +179,8 @@ namespace Octokit.Tests.Clients
PageSize = 1,
PageCount = 1
};
- client.GetAllForIssue("fake", "repo", 3, options);
+
+ await client.GetAllForIssue("fake", "repo", 3, options);
connection.Received().GetAll(
Arg.Is(u => u.ToString() == "repos/fake/repo/issues/3/comments"),
@@ -131,16 +190,39 @@ namespace Octokit.Tests.Clients
}
[Fact]
- public async Task EnsuresArgumentsNotNull()
+ public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
+ {
+ var connection = Substitute.For();
+ var client = new IssueCommentsClient(connection);
+
+ var options = new ApiOptions
+ {
+ StartPage = 1,
+ PageSize = 1,
+ PageCount = 1
+ };
+
+ await client.GetAllForIssue(1, 3, options);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/issues/3/comments"), options);
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
{
var connection = Substitute.For();
var client = new IssueCommentsClient(connection);
await Assert.ThrowsAsync(() => client.GetAllForIssue(null, "name", 1));
- await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1));
await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1));
- await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1));
+ await Assert.ThrowsAsync(() => client.GetAllForIssue(null, "name", 1, ApiOptions.None));
+ await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", null, 1, ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "name", 1, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForIssue(1, 1, null));
+
+ await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1));
+ await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1));
await Assert.ThrowsAsync(() => client.GetAllForIssue("", "name", 1, ApiOptions.None));
await Assert.ThrowsAsync(() => client.GetAllForIssue("owner", "", 1, ApiOptions.None));
}
@@ -161,16 +243,31 @@ namespace Octokit.Tests.Clients
}
[Fact]
- public async Task EnsuresArgumentsNotNull()
+ public void PostsToCorrectUrlWithRepositoryId()
+ {
+ const string newComment = "some title";
+ var connection = Substitute.For();
+ var client = new IssueCommentsClient(connection);
+
+ client.Create(1, 1, newComment);
+
+ connection.Received().Post(Arg.Is(u => u.ToString() == "repositories/1/issues/1/comments"), Arg.Any