diff --git a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs index 0883509d..24f01ff7 100644 --- a/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/IObservableRepositoryCommentsClient.cs @@ -88,17 +88,6 @@ namespace Octokit.Reactive /// The name of the repository /// The comment id /// - IObservable Delete(string owner, string name, int number); - - /// - /// Creates a reaction for specified Commit Comment - /// - /// https://developer.github.com/v3/reactions/#create-reaction-for-a-commit-comment - /// The owner of the repository - /// The name of the repository - /// The comment id - /// The reaction to create - /// - IObservable CreateReaction(string owner, string name, int number, NewReaction reaction); + IObservable Delete(string owner, string name, int number); } } diff --git a/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs b/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs index 91f59d92..6b632fce 100644 --- a/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs +++ b/Octokit.Reactive/Clients/ObservableCommitCommentReactionClient.cs @@ -41,8 +41,7 @@ namespace Octokit.Reactive /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository - /// The comment id - /// The reaction for + /// The comment id /// public IObservable GetAll(string owner, string name, int number) { diff --git a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs index 44069915..3826850f 100644 --- a/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs +++ b/Octokit.Reactive/Clients/ObservableRepositoryCommentsClient.cs @@ -154,22 +154,5 @@ namespace Octokit.Reactive return _client.Delete(owner, name, number).ToObservable(); } - - /// - /// Creates a reaction for specified Commit Comment - /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment - /// The owner of the repository - /// The name of the repository - /// The comment id - /// The reaction for - /// - public IObservable CreateReaction(string owner, string name, int number, NewReaction reaction) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - - return _client.CreateReaction(owner, name, number, reaction).ToObservable(); - } } } diff --git a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs index f00b8d1c..c6a81129 100644 --- a/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests.Integration/Clients/RepositoryCommentsClientTests.cs @@ -377,68 +377,68 @@ public class RepositoryCommentsClientTests } } - public class TheCreateReactionMethod : IDisposable - { - private readonly IGitHubClient _github; - private readonly RepositoryContext _context; + //public class TheCreateReactionMethod : IDisposable + //{ + // private readonly IGitHubClient _github; + // private readonly RepositoryContext _context; - public TheCreateReactionMethod() - { - _github = Helper.GetAuthenticatedClient(); + // public TheCreateReactionMethod() + // { + // _github = Helper.GetAuthenticatedClient(); - _context = _github.CreateRepositoryContext("public-repo").Result; - } + // _context = _github.CreateRepositoryContext("public-repo").Result; + // } - private async Task SetupCommitForRepository(IGitHubClient client) - { - var blob = new NewBlob - { - Content = "Hello World!", - Encoding = EncodingType.Utf8 - }; - var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); + // private async Task SetupCommitForRepository(IGitHubClient client) + // { + // var blob = new NewBlob + // { + // Content = "Hello World!", + // Encoding = EncodingType.Utf8 + // }; + // var blobResult = await client.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob); - var newTree = new NewTree(); - newTree.Tree.Add(new NewTreeItem - { - Type = TreeType.Blob, - Mode = FileMode.File, - Path = "README.md", - Sha = blobResult.Sha - }); + // var newTree = new NewTree(); + // newTree.Tree.Add(new NewTreeItem + // { + // Type = TreeType.Blob, + // Mode = FileMode.File, + // Path = "README.md", + // Sha = blobResult.Sha + // }); - var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); + // var treeResult = await client.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree); - var newCommit = new NewCommit("test-commit", treeResult.Sha); + // var newCommit = new NewCommit("test-commit", treeResult.Sha); - return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); - } + // return await client.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit); + // } - [IntegrationTest] - public async Task CanCreateReaction() - { - var commit = await SetupCommitForRepository(_github); + // [IntegrationTest] + // public async Task CanCreateReaction() + // { + // var commit = await SetupCommitForRepository(_github); - var comment = new NewCommitComment("test"); + // var comment = new NewCommitComment("test"); - var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, - commit.Sha, comment); + // var result = await _github.Repository.Comment.Create(_context.RepositoryOwner, _context.RepositoryName, + // commit.Sha, comment); - Assert.NotNull(result); + // Assert.NotNull(result); - var newReaction = new NewReaction(ReactionType.Confused); - var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); + // var newReaction = new NewReaction(ReactionType.Confused); + // var reaction = await _github.Repository.Comment.CreateReaction(_context.RepositoryOwner, _context.RepositoryName, result.Id, newReaction); - Assert.IsType(reaction); + // Assert.IsType(reaction); - Assert.Equal(ReactionType.Confused, reaction.Content); + // Assert.Equal(ReactionType.Confused, reaction.Content); - Assert.Equal(result.User.Id, reaction.UserId); - } + // Assert.Equal(result.User.Id, reaction.UserId); + // } - public void Dispose() - { - _context.Dispose(); - } - } + // public void Dispose() + // { + // _context.Dispose(); + // } + //} } diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/ReactionsClientTests.cs new file mode 100644 index 00000000..bfe37b3b --- /dev/null +++ b/Octokit.Tests/Clients/ReactionsClientTests.cs @@ -0,0 +1,55 @@ +using NSubstitute; +using Octokit; +using Octokit.Tests; +using System; +using System.Threading.Tasks; +using Xunit; + +public class ReactionsClientTests +{ + public class CommitComments + { + public class TheGetAllMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.CommitComments.GetAll("fake", "repo", 42); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), "application/vnd.github.squirrel-girl-preview"); + } + + [Fact] + public async Task EnsuresArgumentsNotNull() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + await Assert.ThrowsAsync(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + NewReaction newReaction = new NewReaction(ReactionType.Heart); + + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); + } + } + } +} + diff --git a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs index 7e67269c..2628f060 100644 --- a/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryCommentsClientTests.cs @@ -240,34 +240,6 @@ public class RepositoryCommentsClientTests } } - public class TheReactionMethod - { - [Fact] - public void RequestsCorrectUrl() - { - NewReaction newReaction = new NewReaction(ReactionType.Heart); - - var connection = Substitute.For(); - var client = new RepositoryCommentsClient(connection); - - client.CreateReaction("fake", "repo", 1, newReaction); - - connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); - } - - [Fact] - public async Task EnsuresArgumentsNotNull() - { - var connection = Substitute.For(); - var client = new RepositoryCommentsClient(connection); - - await Assert.ThrowsAsync(() => client.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - await Assert.ThrowsAsync(() => client.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - } - } - public class TheCtor { [Fact] diff --git a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj index c6f5566f..206f9b23 100644 --- a/Octokit.Tests/OctoKit.Tests-NetCore45.csproj +++ b/Octokit.Tests/OctoKit.Tests-NetCore45.csproj @@ -180,6 +180,10 @@ + + {49EF16A2-5ED1-480F-80A1-D1D05D6C1BE4} + Octokit-Mono + {c8bc13b6-3fa3-4716-827d-e7706f976fe1} Octokit-NetCore45 diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 87cd858a..72afce19 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -93,6 +93,7 @@ + @@ -208,6 +209,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs new file mode 100644 index 00000000..ebaf6b2f --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs @@ -0,0 +1,65 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableReactionsClientTests + { + public class CommitComments + { + public class TheGetMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + + client.CommitComments.GetAll("fake", "repo", 42); + githubClient.Received().Reaction.CommitComments.GetAll("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + + Assert.Throws(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + var newReaction = new NewReaction(ReactionType.Confused); + + client.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + + Assert.Throws(() => client.CommitComments.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => client.CommitComments.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); + } + } + } + } +} + diff --git a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs index 61ed989e..20f8161d 100644 --- a/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableRepositoryCommentsClientTests.cs @@ -133,30 +133,5 @@ namespace Octokit.Tests.Reactive Assert.Throws(() => client.GetAllForCommit("", "name", "sha1", Args.ApiOptions)); } } - public class TheReactionMethod - { - [Fact] - public void RequestsCorrectUrl() - { - var githubClient = Substitute.For(); - var client = new ObservableRepositoryCommentsClient(githubClient); - var newReaction = new NewReaction(ReactionType.Confused); - - client.CreateReaction("fake", "repo", 1, newReaction); - githubClient.Received().Repository.Comment.CreateReaction("fake", "repo", 1, newReaction); - } - - [Fact] - public void EnsuresArgumentsNotNull() - { - var githubClient = Substitute.For(); - var client = new ObservableRepositoryCommentsClient(githubClient); - - Assert.Throws(() => client.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => client.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - } - } } } diff --git a/Octokit/Clients/CommitCommentReactionClient.cs b/Octokit/Clients/CommitCommentReactionClient.cs index 11d79263..23511324 100644 --- a/Octokit/Clients/CommitCommentReactionClient.cs +++ b/Octokit/Clients/CommitCommentReactionClient.cs @@ -34,8 +34,7 @@ namespace Octokit /// http://developer.github.com/v3/repos/comments/#list-reactions-for-a-commit-comment /// The owner of the repository /// The name of the repository - /// The comment id - /// The reaction for + /// The comment id /// public Task> GetAll(string owner, string name, int number) { diff --git a/Octokit/Clients/IRepositoryCommentsClient.cs b/Octokit/Clients/IRepositoryCommentsClient.cs index a32e5c61..840d36c2 100644 --- a/Octokit/Clients/IRepositoryCommentsClient.cs +++ b/Octokit/Clients/IRepositoryCommentsClient.cs @@ -94,17 +94,6 @@ namespace Octokit /// The name of the repository /// The comment id /// - Task Delete(string owner, string name, int number); - - /// - /// Creates a reaction for specified Commit Comment - /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment - /// The owner of the repository - /// The name of the repository - /// The comment id - /// The reaction for - /// - Task CreateReaction(string owner, string name, int number, NewReaction reaction); + Task Delete(string owner, string name, int number); } } diff --git a/Octokit/Clients/RepositoryCommentsClient.cs b/Octokit/Clients/RepositoryCommentsClient.cs index f6a07b7e..2935c267 100644 --- a/Octokit/Clients/RepositoryCommentsClient.cs +++ b/Octokit/Clients/RepositoryCommentsClient.cs @@ -156,23 +156,5 @@ namespace Octokit return ApiConnection.Delete(ApiUrls.CommitComment(owner, name, number)); } - - /// - /// Creates a reaction for specified Commit Comment - /// - /// http://developer.github.com/v3/repos/comments/#create-reaction-for-a-commit-comment - /// The owner of the repository - /// The name of the repository - /// The comment id - /// The reaction for - /// - public Task CreateReaction(string owner, string name, int number, NewReaction reaction) - { - Ensure.ArgumentNotNullOrEmptyString(owner, "owner"); - Ensure.ArgumentNotNullOrEmptyString(name, "name"); - Ensure.ArgumentNotNull(reaction, "reaction"); - - return ApiConnection.Post(ApiUrls.CommitCommentReaction(owner, name, number), reaction, AcceptHeaders.ReactionsPreview); - } } }