using NSubstitute; using Octokit.Reactive; using System; using Xunit; namespace Octokit.Tests.Reactive { public class ObservableCommitCommentReactionsClientTests { public class TheCtor { [Fact] public void EnsuresNonNullArguments() { Assert.Throws(() => new ObservableCommitCommentReactionsClient(null)); } } public class TheGetAllMethod { [Fact] public void RequestsCorrectUrl() { var gitHubClient = Substitute.For(); var client = new ObservableCommitCommentReactionsClient(gitHubClient); client.GetAll("fake", "repo", 42); gitHubClient.Received().Reaction.CommitComment.GetAll("fake", "repo", 42); } [Fact] public void RequestsCorrectUrlApiOptions() { var gitHubClient = Substitute.For(); var client = new ObservableCommitCommentReactionsClient(gitHubClient); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAll("fake", "repo", 42, options); gitHubClient.Received().Reaction.CommitComment.GetAll("fake", "repo", 42, options); } [Fact] public void RequestsCorrectUrlWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableCommitCommentReactionsClient(gitHubClient); client.GetAll(1, 42); gitHubClient.Received().Reaction.CommitComment.GetAll(1, 42); } [Fact] public void RequestsCorrectUrlWithRepositoryIdApiOptions() { var gitHubClient = Substitute.For(); var client = new ObservableCommitCommentReactionsClient(gitHubClient); var options = new ApiOptions { PageCount = 1, StartPage = 1, PageSize = 1 }; client.GetAll(1, 42, options); gitHubClient.Received().Reaction.CommitComment.GetAll(1, 42, options); } [Fact] public void EnsuresNotNullArguments() { var gitHubClient = Substitute.For(); var client = new ObservableCommitCommentReactionsClient(gitHubClient); Assert.Throws(() => client.GetAll(null, "name", 1)); Assert.Throws(() => client.GetAll("owner", null, 1)); Assert.Throws(() => client.GetAll("owner", "name", 1, null)); Assert.Throws(() => client.GetAll("", "name", 1)); Assert.Throws(() => client.GetAll("owner", "", 1)); } [Fact] public void EnsuresNotNullArgumentsWithRepositoryId() { var gitHubClient = Substitute.For(); var client = new ObservableCommitCommentReactionsClient(gitHubClient); Assert.Throws(() => client.GetAll(1, 1, null)); } } public class TheCreateMethod { [Fact] public void RequestsCorrectUrl() { var githubClient = Substitute.For(); var client = new ObservableCommitCommentReactionsClient(githubClient); var newReaction = new NewReaction(ReactionType.Confused); client.Create("fake", "repo", 1, newReaction); githubClient.Received().Reaction.CommitComment.Create("fake", "repo", 1, newReaction); } [Fact] public void RequestsCorrectUrlWithRepositoryId() { var githubClient = Substitute.For(); var client = new ObservableCommitCommentReactionsClient(githubClient); var newReaction = new NewReaction(ReactionType.Confused); client.Create(1, 1, newReaction); githubClient.Received().Reaction.CommitComment.Create(1, 1, newReaction); } [Fact] public void EnsuresNotNullArguments() { var gitHubClient = Substitute.For(); var client = new ObservableCommitCommentReactionsClient(gitHubClient); Assert.Throws(() => client.Create(null, "name", 1, new NewReaction(ReactionType.Heart))); Assert.Throws(() => client.Create("owner", null, 1, new NewReaction(ReactionType.Heart))); Assert.Throws(() => client.Create("owner", "name", 1, null)); Assert.Throws(() => client.Create(1, 1, null)); Assert.Throws(() => client.Create("", "name", 1, new NewReaction(ReactionType.Heart))); Assert.Throws(() => client.Create("owner", "", 1, new NewReaction(ReactionType.Heart))); } } } }