From 10fe3cd7c9e1904a6541edfe27127ac0c1d8f35d Mon Sep 17 00:00:00 2001 From: lrz-hal Date: Mon, 30 May 2016 17:01:45 +0200 Subject: [PATCH] create unit tests for CommitCommentReactionClient --- ...cs => CommitCommentReactionClientTests.cs} | 16 ++++-- Octokit.Tests/Octokit.Tests.csproj | 4 +- ...ervableCommitCommentReactionClientTests.cs | 56 +++++++++++++++++++ .../ObservableReactionsClientTests.cs | 54 ------------------ 4 files changed, 69 insertions(+), 61 deletions(-) rename Octokit.Tests/Clients/{ReactionsClientTests.cs => CommitCommentReactionClientTests.cs} (87%) create mode 100644 Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs delete mode 100644 Octokit.Tests/Reactive/ObservableReactionsClientTests.cs diff --git a/Octokit.Tests/Clients/ReactionsClientTests.cs b/Octokit.Tests/Clients/CommitCommentReactionClientTests.cs similarity index 87% rename from Octokit.Tests/Clients/ReactionsClientTests.cs rename to Octokit.Tests/Clients/CommitCommentReactionClientTests.cs index 5f838c8b..8f7087a0 100644 --- a/Octokit.Tests/Clients/ReactionsClientTests.cs +++ b/Octokit.Tests/Clients/CommitCommentReactionClientTests.cs @@ -1,14 +1,21 @@ using NSubstitute; -using Octokit; -using Octokit.Tests; using System; using System.Threading.Tasks; using Xunit; -public class ReactionsClientTests +namespace Octokit.Tests.Clients { - public class CommitComments + public class CommitCommentReactionClientTests { + public class TheCtor + { + [Fact] + public void EnsuresNonNullArguments() + { + Assert.Throws(() => new CommitCommentReactionClient(null)); + } + } + public class TheGetAllMethod { [Fact] @@ -53,4 +60,3 @@ public class ReactionsClientTests } } } - diff --git a/Octokit.Tests/Octokit.Tests.csproj b/Octokit.Tests/Octokit.Tests.csproj index 72afce19..41c611c2 100644 --- a/Octokit.Tests/Octokit.Tests.csproj +++ b/Octokit.Tests/Octokit.Tests.csproj @@ -85,6 +85,7 @@ + @@ -93,7 +94,6 @@ - @@ -207,9 +207,9 @@ + - diff --git a/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs new file mode 100644 index 00000000..3cbb86de --- /dev/null +++ b/Octokit.Tests/Reactive/ObservableCommitCommentReactionClientTests.cs @@ -0,0 +1,56 @@ +using NSubstitute; +using Octokit.Reactive; +using System; +using Xunit; + +namespace Octokit.Tests.Reactive +{ + public class ObservableCommitCommentReactionClientTests + { + 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.CommitComments.GetAll("fake", "repo", 42); + _githubClient.Received().Reaction.CommitComments.GetAll("fake", "repo", 42); + } + + [Fact] + public void EnsuresArgumentsNotNull() + { + + 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))); + Assert.Throws(() => _client.CommitComments.CreateReaction("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.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction); + } + } + } +} diff --git a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs b/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs deleted file mode 100644 index 845d7bc1..00000000 --- a/Octokit.Tests/Reactive/ObservableReactionsClientTests.cs +++ /dev/null @@ -1,54 +0,0 @@ -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))); - Assert.Throws(() => client.CommitComments.CreateReaction("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.CommitComments.CreateReaction("fake", "repo", 1, newReaction); - githubClient.Received().Reaction.CommitComments.CreateReaction("fake", "repo", 1, newReaction); - } - } - } - } -} -