Files
octokit.net/Octokit.Tests/Reactive/ObservablePullRequestReviewCommentReactionsClientTests.cs
Henrik Andersson 43381c4a53 Pagination support to Reactions Clients (#1948)
* Add pagination to *CommitCommentReactionsClient

* Add unit tests for *CommitCommentReactionsClient

* Add integration tests for *CommitCommentReactionsClient

* Add pagination to *IssueCommentReactionsClient

* Add unit tests for *IssueCommentReactionsClient

* Add integration tests for *IssueCommentReactionsClient

* Add pagination to *IssueReactionsClient

* Add unit tests for *IssueReactionsClient

* Add integration tests for *IssueReactionsClient

* Add pagination to *PullRequestReviewCommentReactionsClient

* Add unit tests for *PullRequestReviewCommentReactionsClient

* Add integration tests for *PullRequestReviewCommentReactionsClient

* Remove rogue using statement and whitespace

* Add null check tests for GetAll with repositoryid overload
2019-02-27 21:29:33 +10:00

145 lines
5.5 KiB
C#

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