diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs index 55c5af2ab1..1a8ed9b9a5 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs @@ -27,6 +27,16 @@ public interface IObservableRepositoryCommentsClient /// IObservable GetAllForRepository(string owner, string name); + /// + /// Gets Commit Comments for a repository. + /// + /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository + /// The owner of the repository + /// The name of the repository + /// Options to change the API response + /// + IObservable GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets Commit Comments for a specified Commit. /// @@ -37,6 +47,17 @@ public interface IObservableRepositoryCommentsClient /// IObservable GetAllForCommit(string owner, string name, string sha); + /// + /// Gets Commit Comments for a specified Commit. + /// + /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit + /// The owner of the repository + /// The name of the repository + /// The sha of the commit + /// Options to change the API response + /// + IObservable GetAllForCommit(string owner, string name, string sha, ApiOptions options); + /// /// Creates a new Commit Comment for a specified Commit. /// diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs index 236939e7ee..3826850fd5 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs @@ -46,7 +46,24 @@ public IObservable GetAllForRepository(string owner, string name) Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return _connection.GetAndFlattenAllPages(ApiUrls.CommitComments(owner, name)); + return GetAllForRepository(owner, name, ApiOptions.None); + } + + /// + /// Gets Commit Comments for a repository. + /// + /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository + /// The owner of the repository + /// The name of the repository + /// Options to change the API response + /// + public IObservable GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.CommitComments(owner, name), options); } /// @@ -63,7 +80,26 @@ public IObservable GetAllForCommit(string owner, string name, str Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(sha, "sha"); - return _connection.GetAndFlattenAllPages(ApiUrls.CommitComments(owner, name, sha)); + return GetAllForCommit(owner, name, sha, ApiOptions.None); + } + + /// + /// Gets Commit Comments for a specified Commit. + /// + /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit + /// The owner of the repository + /// The name of the repository + /// The sha of the commit + /// Options to change the API response + /// + public IObservable GetAllForCommit(string owner, string name, string sha, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(sha, "sha"); + Ensure.ArgumentNotNull(options, "options"); + + return _connection.GetAndFlattenAllPages(ApiUrls.CommitComments(owner, name, sha), options); } /// diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index 09177c9589..bba1fbf1f4 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -35,7 +35,7 @@ public async Task EnsuresNonNullArguments() } } - public class TheGetForRepositoryMethod + public class TheGetAllForRepositoryMethod { [Fact] public void RequestsCorrectUrl() @@ -43,9 +43,9 @@ public void RequestsCorrectUrl() var connection = Substitute.For(); var client = new RepositoryCommentsClient(connection); - client.GetAllForRepository("fake", "repo"); + client.GetAllForRepository("fake", "repo", new ApiOptions()); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments"), Arg.Any()); } [Fact] @@ -54,10 +54,11 @@ public async Task EnsuresArgumentsNotNull() var connection = Substitute.For(); var client = new RepositoryCommentsClient(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", new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForRepository("", "name", new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", null, new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "", new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForRepository("owner", "name", null)); } } @@ -69,9 +70,9 @@ public void RequestsCorrectUrl() var connection = Substitute.For(); var client = new RepositoryCommentsClient(connection); - client.GetAllForCommit("fake", "repo", "sha"); + client.GetAllForCommit("fake", "repo", "sha", new ApiOptions()); - connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/comments")); + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/commits/sha/comments"), Arg.Any()); } [Fact] @@ -80,12 +81,13 @@ public async Task EnsuresArgumentsNotNull() var connection = Substitute.For(); var client = new RepositoryCommentsClient(connection); - await Assert.ThrowsAsync(() => client.GetAllForCommit(null, "name", "sha")); - await Assert.ThrowsAsync(() => client.GetAllForCommit("", "name", "sha")); - await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", null, "sha")); - await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "", "sha")); - await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", null)); - await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "")); + await Assert.ThrowsAsync(() => client.GetAllForCommit(null, "name", "sha", new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForCommit("", "name", "sha", new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", null, "sha", new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "", "sha", new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", null, new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "", new ApiOptions())); + await Assert.ThrowsAsync(() => client.GetAllForCommit("owner", "name", "sha", null)); } } diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 8fd268a0b2..eb4f54149c 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -213,6 +213,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs new file mode 100644 index 0000000000..8ac5cd803b --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs @@ -0,0 +1,67 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableRepositoryCommentsClientTests + { + public class TheGetAllForRepositoryMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommentsClient(githubClient); + var options = new ApiOptions(); + + client.GetAllForRepository("fake", "repo", options); + githubClient.Received().Repository.Comment.GetAllForRepository("fake", "repo", options); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommentsClient(githubClient); + + Assert.Throws(() => client.GetAllForRepository(null, "name", new ApiOptions())); + Assert.Throws(() => client.GetAllForRepository("", "name", new ApiOptions())); + Assert.Throws(() => client.GetAllForRepository("owner", null, new ApiOptions())); + Assert.Throws(() => client.GetAllForRepository("owner", "", new ApiOptions())); + Assert.Throws(() => client.GetAllForRepository("owner", "name", null)); + } + } + + public class TheGetForCommitMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommentsClient(githubClient); + var options = new ApiOptions(); + + client.GetAllForCommit("fake", "repo", "sha", options); + githubClient.Received().Repository.Comment.GetAllForCommit("fake", "repo", "sha", options); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var githubClient = Substitute.For(); + var client = new ObservableRepositoryCommentsClient(githubClient); + + Assert.Throws(() => client.GetAllForCommit(null, "name", "sha", new ApiOptions())); + Assert.Throws(() => client.GetAllForCommit("", "name", "sha", new ApiOptions())); + Assert.Throws(() => client.GetAllForCommit("owner", null, "sha", new ApiOptions())); + Assert.Throws(() => client.GetAllForCommit("owner", "", "sha", new ApiOptions())); + Assert.Throws(() => client.GetAllForCommit("owner", "name", null, new ApiOptions())); + Assert.Throws(() => client.GetAllForCommit("owner", "name", "", new ApiOptions())); + Assert.Throws(() => client.GetAllForCommit("owner", "name", "sha", null)); + } + } + } +} diff --git a/Octokit/Clients/IRepositoryCommentsClient.cs b/Octokit/Clients/IRepositoryCommentsClient.cs index 3156870f24..f378dafe88 100644 --- a/Octokit/Clients/IRepositoryCommentsClient.cs +++ b/Octokit/Clients/IRepositoryCommentsClient.cs @@ -33,6 +33,16 @@ public interface IRepositoryCommentsClient /// Task> GetAllForRepository(string owner, string name); + /// + /// Gets Commit Comments for a repository. + /// + /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository + /// The owner of the repository + /// The name of the repository + /// Options to change the API response + /// + Task> GetAllForRepository(string owner, string name, ApiOptions options); + /// /// Gets Commit Comments for a specified Commit. /// @@ -43,6 +53,17 @@ public interface IRepositoryCommentsClient /// Task> GetAllForCommit(string owner, string name, string sha); + /// + /// Gets Commit Comments for a specified Commit. + /// + /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit + /// The owner of the repository + /// The name of the repository + /// The sha of the commit + /// Options to change the API response + /// + Task> GetAllForCommit(string owner, string name, string sha, ApiOptions options); + /// /// Creates a new Commit Comment for a specified Commit. /// diff --git a/Octokit/Clients/RepositoryCommentsClient.cs b/Octokit/Clients/RepositoryCommentsClient.cs index a196c287f2..5dc99f297e 100644 --- a/Octokit/Clients/RepositoryCommentsClient.cs +++ b/Octokit/Clients/RepositoryCommentsClient.cs @@ -49,7 +49,24 @@ public Task> GetAllForRepository(string owner, stri Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); Ensure.ArgumentNotNullOrEmptyString(name, "name"); - return ApiConnection.GetAll(ApiUrls.CommitComments(owner, name)); + return GetAllForRepository(owner, name, ApiOptions.None); + } + + /// + /// Gets Commit Comments for a repository. + /// + /// http://developer.github.com/v3/repos/comments/#list-commit-comments-for-a-repository + /// The owner of the repository + /// The name of the repository + /// Options to change the API response + /// + public Task> GetAllForRepository(string owner, string name, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.CommitComments(owner, name), options); } /// @@ -66,7 +83,26 @@ public Task> GetAllForCommit(string owner, string n Ensure.ArgumentNotNullOrEmptyString(name, "name"); Ensure.ArgumentNotNullOrEmptyString(sha, "sha"); - return ApiConnection.GetAll(ApiUrls.CommitComments(owner, name, sha)); + return GetAllForCommit(owner, name, sha, ApiOptions.None); + } + + /// + /// Gets Commit Comments for a specified Commit. + /// + /// http://developer.github.com/v3/repos/comments/#list-comments-for-a-single-commit + /// The owner of the repository + /// The name of the repository + /// The sha of the commit + /// Options to change the API response + /// + public Task> GetAllForCommit(string owner, string name, string sha, ApiOptions options) + { + Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); + Ensure.ArgumentNotNullOrEmptyString(name, "name"); + Ensure.ArgumentNotNullOrEmptyString(sha, "sha"); + Ensure.ArgumentNotNull(options, "options"); + + return ApiConnection.GetAll(ApiUrls.CommitComments(owner, name, sha), options); } /// diff --git a/SolutionInfo.cs b/SolutionInfo.cs index 22509412fb..a52961be74 100644 --- a/SolutionInfo.cs +++ b/SolutionInfo.cs @@ -6,10 +6,8 @@ [assembly: AssemblyVersionAttribute("0.19.0")] [assembly: AssemblyFileVersionAttribute("0.19.0")] [assembly: ComVisibleAttribute(false)] -namespace System -{ - internal static class AssemblyVersionInformation - { +namespace System { + internal static class AssemblyVersionInformation { internal const string Version = "0.19.0"; } }