diff --git a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs
index 174863fa..5d837b70 100644
--- a/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs
+++ b/Octokit.Reactive/Clients/IObservableCommitCommentReactionsClient.cs
@@ -2,6 +2,12 @@
namespace Octokit.Reactive
{
+ ///
+ /// A client for GitHub's Reactions API.
+ ///
+ ///
+ /// See the Reactions API documentation for more information.
+ ///
public interface IObservableCommitCommentReactionsClient
{
///
@@ -15,6 +21,16 @@ namespace Octokit.Reactive
///
IObservable Create(string owner, string name, int number, NewReaction reaction);
+ ///
+ /// Creates a reaction for a specified Commit Comment
+ ///
+ /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment
+ /// The ID of the repository
+ /// The comment id
+ /// The reaction to create
+ ///
+ IObservable Create(int repositoryId, int number, NewReaction reaction);
+
///
/// List reactions for a specified Commit Comment
///
@@ -24,5 +40,14 @@ namespace Octokit.Reactive
/// The comment id
///
IObservable GetAll(string owner, string name, int number);
+
+ ///
+ /// List reactions for a specified Commit Comment
+ ///
+ /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment
+ /// The owner of the repository
+ /// The comment id
+ ///
+ IObservable GetAll(int repositoryId, int number);
}
}
diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs
index e3d172ee..7b138355 100644
--- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs
+++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionsClient.cs
@@ -4,6 +4,12 @@ using Octokit.Reactive.Internal;
namespace Octokit.Reactive
{
+ ///
+ /// A client for GitHub's Reactions API.
+ ///
+ ///
+ /// See the Reactions API documentation for more information.
+ ///
public class ObservableCommitCommentReactionsClient : IObservableCommitCommentReactionsClient
{
readonly ICommitCommentReactionsClient _client;
@@ -35,6 +41,21 @@ namespace Octokit.Reactive
return _client.Create(owner, name, number, reaction).ToObservable();
}
+ ///
+ /// Creates a reaction for a specified Commit Comment
+ ///
+ /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment
+ /// The ID of the repository
+ /// The comment id
+ /// The reaction to create
+ ///
+ public IObservable Create(int repositoryId, int number, NewReaction reaction)
+ {
+ Ensure.ArgumentNotNull(reaction, "reaction");
+
+ return _client.Create(repositoryId, number, reaction).ToObservable();
+ }
+
///
/// List reactions for a specified Commit Comment
///
@@ -50,5 +71,17 @@ namespace Octokit.Reactive
return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(owner, name, number), null, AcceptHeaders.ReactionsPreview);
}
+
+ ///
+ /// List reactions for a specified Commit Comment
+ ///
+ /// https://developer.github.com/v3/reactions/#list-reactions-for-a-commit-comment
+ /// The owner of the repository
+ /// The comment id
+ ///
+ public IObservable GetAll(int repositoryId, int number)
+ {
+ return _connection.GetAndFlattenAllPages(ApiUrls.CommitCommentReactions(repositoryId, number), null, AcceptHeaders.ReactionsPreview);
+ }
}
}
diff --git a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs
index 679070a6..6c3e169c 100644
--- a/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.cs
+++ b/Octokit.Tests.Integration/Clients/CommitCommentReactionsClientTests.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 CommitCommentReactionsClientTests
@@ -44,6 +44,54 @@ public class CommitCommentReactionsClientTests
return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit);
}
+ [IntegrationTest]
+ public async Task CanListReactions()
+ {
+ var commit = await SetupCommitForRepository(_github);
+
+ var comment = new NewCommitComment("test");
+
+ var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName,
+ commit.Sha, comment);
+
+ Assert.NotNull(result);
+
+ var newReaction = new NewReaction(ReactionType.Confused);
+ var reaction = await _github.Reaction.CommitComment.Create(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction);
+
+ var reactions = await _github.Reaction.CommitComment.GetAll(_context.RepositoryOwner, _context.RepositoryName, result.Id);
+
+ Assert.NotEmpty(reactions);
+
+ Assert.Equal(reaction.Id, reactions[0].Id);
+
+ Assert.Equal(reaction.Content, reactions[0].Content);
+ }
+
+ [IntegrationTest]
+ public async Task CanListReactionsWithRepositoryId()
+ {
+ var commit = await SetupCommitForRepository(_github);
+
+ var comment = new NewCommitComment("test");
+
+ var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName,
+ commit.Sha, comment);
+
+ Assert.NotNull(result);
+
+ var newReaction = new NewReaction(ReactionType.Confused);
+ var reaction = await _github.Reaction.CommitComment.Create(_context.Repository.Id, result.Id, newReaction);
+
+ var reactions = await _github.Reaction.CommitComment.GetAll(_context.Repository.Id, result.Id);
+
+ Assert.NotEmpty(reactions);
+
+ Assert.Equal(reaction.Id, reactions[0].Id);
+
+ Assert.Equal(reaction.Content, reactions[0].Content);
+ }
+
[IntegrationTest]
public async Task CanCreateReaction()
{
@@ -68,6 +116,28 @@ public class CommitCommentReactionsClientTests
}
}
+ [IntegrationTest]
+ public async Task CanCreateReactionWithRepositoryId()
+ {
+ var commit = await SetupCommitForRepository(_github);
+
+ var comment = new NewCommitComment("test");
+
+ var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName,
+ commit.Sha, comment);
+
+ Assert.NotNull(result);
+
+ var newReaction = new NewReaction(ReactionType.Confused);
+ var reaction = await _github.Reaction.CommitComment.Create(_context.Repository.Id, result.Id, newReaction);
+
+ Assert.IsType(reaction);
+
+ Assert.Equal(ReactionType.Confused, reaction.Content);
+
+ Assert.Equal(result.User.Id, reaction.User.Id);
+ }
+
public void Dispose()
{
_context.Dispose();
diff --git a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs
index aba818ca..0f55c0e8 100644
--- a/Octokit.Tests/Clients/CommitCommentReactionsClientTests.cs
+++ b/Octokit.Tests/Clients/CommitCommentReactionsClientTests.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 CommitCommentReactionsClient(connection);
- client.CommitComment.GetAll("fake", "repo", 42);
+ await client.GetAll("fake", "repo", 42);
connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/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 CommitCommentReactionsClient(connection);
- await Assert.ThrowsAsync(() => client.CommitComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart)));
- await Assert.ThrowsAsync(() => client.CommitComment.Create("", "name", 1, new NewReaction(ReactionType.Heart)));
- await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart)));
- await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart)));
- await Assert.ThrowsAsync(() => client.CommitComment.Create("owner", "name", 1, null));
+ await client.GetAll(1, 42);
+
+ connection.Received().GetAll(Arg.Is(u => u.ToString() == "repositories/1/comments/42/reactions"), "application/vnd.github.squirrel-girl-preview");
+ }
+
+ [Fact]
+ public async Task EnsuresNotNullArguments()
+ {
+ var connection = Substitute.For();
+ var client = new CommitCommentReactionsClient(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 CommitCommentReactionsClient(connection);
- client.CommitComment.Create("fake", "repo", 1, newReaction);
+ client.Create("fake", "repo", 1, newReaction);
- connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any