diff --git a/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs
index 75cc0a88..8fee248e 100644
--- a/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs
+++ b/Octokit.Reactive/Clients/IObservablePullRequestReviewCommentReactionsClient.cs
@@ -1,10 +1,32 @@
using System;
-using System.Collections.Generic;
namespace Octokit.Reactive
{
+ ///
+ /// A client for GitHub's Reactions API.
+ ///
+ ///
+ /// See the Reactions API documentation for more information.
+ ///
public interface IObservablePullRequestReviewCommentReactionsClient
{
+ ///
+ /// Get all reactions for a specified Pull Request Review Comment.
+ ///
+ /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment
+ /// The owner of the repository
+ /// The name of the repository
+ /// The comment id
+ IObservable GetAll(string owner, string name, int number);
+
+ ///
+ /// Get all reactions for a specified Pull Request Review Comment.
+ ///
+ /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment
+ /// The ID of the repository
+ /// The comment id
+ IObservable GetAll(int repositoryId, int number);
+
///
/// Creates a reaction for a specified Pull Request Review Comment.
///
@@ -13,17 +35,15 @@ namespace Octokit.Reactive
/// The name of the repository
/// The comment id
/// The reaction to create
- ///
IObservable Create(string owner, string name, int number, NewReaction reaction);
///
- /// Get all reactions for a specified Pull Request Review Comment.
+ /// Creates a reaction for a specified Pull Request Review Comment.
///
- /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment
- /// The owner of the repository
- /// The name of the repository
- /// The comment id
- ///
- IObservable GetAll(string owner, string name, int number);
+ /// https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment
+ /// The owner of the repository
+ /// The comment id
+ /// The reaction to create
+ IObservable Create(int repositoryId, int number, NewReaction reaction);
}
}
diff --git a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs
index e917ef5a..abf8132b 100644
--- a/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs
+++ b/Octokit.Reactive/Clients/ObservablePullRequestReviewCommentReactionsClient.cs
@@ -1,10 +1,15 @@
-using Octokit.Reactive.Internal;
-using System;
-using System.Collections.Generic;
+using System;
using System.Reactive.Threading.Tasks;
+using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
+ ///
+ /// A client for GitHub's Reactions API.
+ ///
+ ///
+ /// See the Reactions API documentation for more information.
+ ///
public class ObservablePullRequestReviewCommentReactionsClient : IObservablePullRequestReviewCommentReactionsClient
{
readonly IPullRequestReviewCommentReactionsClient _client;
@@ -18,6 +23,32 @@ namespace Octokit.Reactive
_connection = client.Connection;
}
+ ///
+ /// Get all reactions for a specified Pull Request Review Comment.
+ ///
+ /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment
+ /// The owner of the repository
+ /// The name of the repository
+ /// The comment id
+ public IObservable GetAll(string owner, string name, int number)
+ {
+ Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
+ Ensure.ArgumentNotNullOrEmptyString(name, "name");
+
+ return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), null, AcceptHeaders.ReactionsPreview);
+ }
+
+ ///
+ /// Get all reactions for a specified Pull Request Review Comment.
+ ///
+ /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment
+ /// The ID of the repository
+ /// The comment id
+ public IObservable GetAll(int repositoryId, int number)
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentReaction(repositoryId, number), null, AcceptHeaders.ReactionsPreview);
+ }
+
///
/// Creates a reaction for a specified Pull Request Review Comment.
///
@@ -26,7 +57,6 @@ namespace Octokit.Reactive
/// The name of the repository
/// The comment id
/// The reaction to create
- ///
public IObservable Create(string owner, string name, int number, NewReaction reaction)
{
Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
@@ -37,19 +67,17 @@ namespace Octokit.Reactive
}
///
- /// Get all reactions for a specified Pull Request Review Comment.
+ /// Creates a reaction for a specified Pull Request Review Comment.
///
- /// https://developer.github.com/v3/reactions/#list-reactions-for-a-pull-request-review-comment
- /// The owner of the repository
- /// The name of the repository
- /// The comment id
- ///
- public IObservable GetAll(string owner, string name, int number)
+ /// https://developer.github.com/v3/reactions/#create-reaction-for-a-pull-request-review-comment
+ /// The owner of the repository
+ /// The comment id
+ /// The reaction to create
+ public IObservable Create(int repositoryId, int number, NewReaction reaction)
{
- Ensure.ArgumentNotNullOrEmptyString(owner, "owner");
- Ensure.ArgumentNotNullOrEmptyString(name, "name");
+ Ensure.ArgumentNotNull(reaction, "reaction");
- return _connection.GetAndFlattenAllPages(ApiUrls.PullRequestReviewCommentReaction(owner, name, number), null, AcceptHeaders.ReactionsPreview);
+ return _client.Create(repositoryId, number, reaction).ToObservable();
}
}
}
diff --git a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs
index 84afbcda..e457144c 100644
--- a/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/PullRequestReviewCommentReactionsClientTests.cs
@@ -1,8 +1,8 @@
-using Octokit;
+using System;
+using System.Threading.Tasks;
+using Octokit;
using Octokit.Tests.Integration;
using Octokit.Tests.Integration.Helpers;
-using System;
-using System.Threading.Tasks;
using Xunit;
public class PullRequestReviewCommentReactionsClientTests : IDisposable
@@ -26,6 +26,52 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable
_context = _github.CreateRepositoryContext("test-repo").Result;
}
+ [IntegrationTest]
+ public async Task CanListReactions()
+ {
+ var pullRequest = await CreatePullRequest(_context);
+
+ const string body = "A review comment message";
+ const int position = 1;
+
+ var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number);
+
+ var commentFromGitHub = await _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id);
+
+ AssertComment(commentFromGitHub, body, position);
+
+ var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id, new NewReaction(ReactionType.Heart));
+
+ var reactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, commentFromGitHub.Id);
+
+ Assert.NotEmpty(reactions);
+ Assert.Equal(reaction.Id, reactions[0].Id);
+ Assert.Equal(reaction.Content, reactions[0].Content);
+ }
+
+ [IntegrationTest]
+ public async Task CanListReactionsWithRepositoryId()
+ {
+ var pullRequest = await CreatePullRequest(_context);
+
+ const string body = "A review comment message";
+ const int position = 1;
+
+ var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number);
+
+ var commentFromGitHub = await _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id);
+
+ AssertComment(commentFromGitHub, body, position);
+
+ var reaction = await _github.Reaction.PullRequestReviewComment.Create(_context.Repository.Id, commentFromGitHub.Id, new NewReaction(ReactionType.Heart));
+
+ var reactions = await _github.Reaction.PullRequestReviewComment.GetAll(_context.Repository.Id, commentFromGitHub.Id);
+
+ Assert.NotEmpty(reactions);
+ Assert.Equal(reaction.Id, reactions[0].Id);
+ Assert.Equal(reaction.Content, reactions[0].Content);
+ }
+
[IntegrationTest]
public async Task CanCreateReaction()
{
@@ -52,6 +98,31 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable
}
}
+ [IntegrationTest]
+ public async Task CanCreateReactionWithRepositoryId()
+ {
+ var pullRequest = await CreatePullRequest(_context);
+
+ const string body = "A review comment message";
+ const int position = 1;
+
+ var createdComment = await CreateComment(body, position, pullRequest.Sha, pullRequest.Number);
+
+ var commentFromGitHub = await _client.GetComment(Helper.UserName, _context.RepositoryName, createdComment.Id);
+
+ AssertComment(commentFromGitHub, body, position);
+
+ var pullRequestReviewCommentReaction = await _github.Reaction.PullRequestReviewComment.Create(_context.Repository.Id, commentFromGitHub.Id, new NewReaction(ReactionType.Heart));
+
+ Assert.NotNull(pullRequestReviewCommentReaction);
+
+ Assert.IsType(pullRequestReviewCommentReaction);
+
+ Assert.Equal(ReactionType.Heart, pullRequestReviewCommentReaction.Content);
+
+ Assert.Equal(commentFromGitHub.User.Id, pullRequestReviewCommentReaction.User.Id);
+ }
+
///
/// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request)
///
@@ -155,4 +226,3 @@ public class PullRequestReviewCommentReactionsClientTests : IDisposable
public string Sha { get; set; }
}
}
-
diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs
index 66bec075..054ef7dd 100644
--- a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs
+++ b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs
@@ -1,6 +1,6 @@
-using NSubstitute;
-using System;
+using System;
using System.Threading.Tasks;
+using NSubstitute;
using Xunit;
namespace Octokit.Tests.Clients
@@ -22,24 +22,35 @@ namespace Octokit.Tests.Clients
public async Task RequestsCorrectUrl()
{
var connection = Substitute.For();
- var client = new ReactionsClient(connection);
+ var client = new PullRequestReviewCommentReactionsClient(connection);
- client.PullRequestReviewComment.GetAll("fake", "repo", 42);
+ await client.GetAll("fake", "repo", 42);
connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview");
}
[Fact]
- public async Task EnsuresArgumentsNotNull()
+ public async Task RequestsCorrectUrlWithRepositoryId()
{
var connection = Substitute.For();
- var client = new ReactionsClient(connection);
+ var client = new PullRequestReviewCommentReactionsClient(connection);
- await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart)));
- await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("", "name", 1, new NewReaction(ReactionType.Heart)));
- await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart)));
- await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart)));
- await Assert.ThrowsAsync(() => client.PullRequestReviewComment.Create("owner", "name", 1, null));
+ await client.GetAll(1, 42);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/pulls/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview");
+ }
+
+ [Fact]
+ public async Task EnsuresNonNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new PullRequestReviewCommentReactionsClient(connection);
+
+ await Assert.ThrowsAsync(() => client.GetAll(null, "name", 1));
+ await Assert.ThrowsAsync(() => client.GetAll("owner", null, 1));
+
+ await Assert.ThrowsAsync(() => client.GetAll("", "name", 1));
+ await Assert.ThrowsAsync(() => client.GetAll("owner", "", 1));
}
}
@@ -51,11 +62,40 @@ namespace Octokit.Tests.Clients
NewReaction newReaction = new NewReaction(ReactionType.Heart);
var connection = Substitute.For();
- var client = new ReactionsClient(connection);
+ var client = new PullRequestReviewCommentReactionsClient(connection);
- client.PullRequestReviewComment.Create("fake", "repo", 1, newReaction);
+ client.Create("fake", "repo", 1, newReaction);
- connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/comments/1/reactions"), Arg.Any