diff --git a/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs new file mode 100644 index 00000000..669b3a94 --- /dev/null +++ b/Octokit.Tests/Clients/PullRequestReviewCommentReactionsClientTests.cs @@ -0,0 +1,62 @@ +using NSubstitute; +using System; +using System.Threading.Tasks; +using Xunit; + +namespace Octokit.Tests.Clients +{ + public class PullRequestReviewCommentReactionsClientTests + { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new PullRequestReviewCommentReactionsClient(null)); + } + } + + public class TheGetAllMethod + { + [Fact] + public async Task RequestsCorrectUrl() + { + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.PullRequestReviewComment.GetAll("fake", "repo", 42); + + connection.Received().GetAll(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/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.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)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + NewReaction newReaction = new NewReaction(ReactionType.Heart); + + var connection = Substitute.For(); + var client = new ReactionsClient(connection); + + client.PullRequestReviewComment.Create("fake", "repo", 1, newReaction); + + connection.Received().Post(Arg.Is(u => u.ToString() == "repos/fake/repo/pulls/comments/1/reactions"), Arg.Any(), "application/vnd.github.squirrel-girl-preview"); + } + } + } +} diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 05562f78..058d15a0 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -96,6 +96,7 @@ + @@ -212,6 +213,7 @@ + diff --git a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs index cd23ef15..794dae4e 100644 --- a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs +++ b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs @@ -31,11 +31,11 @@ namespace Octokit.Tests.Reactive public void EnsuresArgumentsNotNull() { - Assert.Throws(() => _client.CommitComment.CreateReaction(null, "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComment.CreateReaction("", "name", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComment.CreateReaction("owner", null, 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComment.CreateReaction("owner", "", 1, new NewReaction(ReactionType.Heart))); - Assert.Throws(() => _client.CommitComment.CreateReaction("owner", "name", 1, null)); + Assert.Throws(() => _client.CommitComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.CommitComment.Create("owner", "name", 1, null)); } } @@ -48,8 +48,8 @@ namespace Octokit.Tests.Reactive var client = new ObservableReactionsClient(githubClient); var newReaction = new NewReaction(ReactionType.Confused); - client.CommitComment.CreateReaction("fake", "repo", 1, newReaction); - githubClient.Received().Reaction.CommitComment.CreateReaction("fake", "repo", 1, newReaction); + client.CommitComment.Create("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.CommitComment.Create("fake", "repo", 1, newReaction); } } } diff --git a/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs new file mode 100644 index 00000000..cd85f612 --- /dev/null +++ b/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs @@ -0,0 +1,56 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservablePullRequestReviewCommentReactionsClientTests + { + public class TheGetAllMethod + { + private readonly IGitHubClient _githubClient; + private readonly IObservableReactionsClient _client; + private const string owner = "owner"; + private const string name = "name"; + + public TheGetAllMethod() + { + _githubClient = Substitute.For(); + _client = new ObservableReactionsClient(_githubClient); + } + + [Fact] + public void RequestsCorrectUrl() + { + _client.PullRequestReviewComment.GetAll("fake", "repo", 42); + _githubClient.Received().Reaction.PullRequestReviewComment.GetAll("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + + Assert.Throws(() => _client.PullRequestReviewComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.PullRequestReviewComment.Create("", "name", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); + Assert.Throws(() => _client.PullRequestReviewComment.Create("owner", "name", 1, null)); + } + } + + public class TheCreateMethod + { + [Fact] + public void RequestsCorrectUrl() + { + var githubClient = Substitute.For(); + var client = new ObservableReactionsClient(githubClient); + var newReaction = new NewReaction(ReactionType.Confused); + + client.PullRequestReviewComment.Create("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.PullRequestReviewComment.Create("fake", "repo", 1, newReaction); + } + } + } +}