added new unit tests

This commit is contained in:
aedampir@gmail.com
2016-06-15 15:56:32 +07:00
parent 1b3f678831
commit 52de714280
2 changed files with 102 additions and 27 deletions
@@ -18,33 +18,39 @@ namespace Octokit.Tests.Reactive
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<IGitHubClient>();
_client = new ObservableReactionsClient(_githubClient);
}
[Fact]
public void RequestsCorrectUrl()
{
_client.CommitComment.GetAll("fake", "repo", 42);
_githubClient.Received().Reaction.CommitComment.GetAll("fake", "repo", 42);
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableReactionsClient(gitHubClient);
client.CommitComment.GetAll("fake", "repo", 42);
gitHubClient.Received().Reaction.CommitComment.GetAll("fake", "repo", 42);
}
[Fact]
public void EnsuresArgumentsNotNull()
public void RequestsCorrectUrlWithRepositoryId()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableReactionsClient(gitHubClient);
Assert.Throws<ArgumentNullException>(() => _client.CommitComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentException>(() => _client.CommitComment.Create("", "name", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentNullException>(() => _client.CommitComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentException>(() => _client.CommitComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentNullException>(() => _client.CommitComment.Create("owner", "name", 1, null));
client.CommitComment.GetAll(1, 42);
gitHubClient.Received().Reaction.CommitComment.GetAll(1, 42);
}
[Fact]
public void EnsuresNotNullArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableReactionsClient(gitHubClient);
Assert.Throws<ArgumentNullException>(() => client.CommitComment.GetAll(null, "name", 1));
Assert.Throws<ArgumentNullException>(() => client.CommitComment.GetAll("owner", null, 1));
Assert.Throws<ArgumentException>(() => client.CommitComment.GetAll("", "name", 1));
Assert.Throws<ArgumentException>(() => client.CommitComment.GetAll("owner", "", 1));
}
}
@@ -58,8 +64,37 @@ namespace Octokit.Tests.Reactive
var newReaction = new NewReaction(ReactionType.Confused);
client.CommitComment.Create("fake", "repo", 1, newReaction);
githubClient.Received().Reaction.CommitComment.Create("fake", "repo", 1, newReaction);
}
[Fact]
public void RequestsCorrectUrlWithRepositoryId()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableReactionsClient(githubClient);
var newReaction = new NewReaction(ReactionType.Confused);
client.CommitComment.Create(1, 1, newReaction);
githubClient.Received().Reaction.CommitComment.Create(1, 1, newReaction);
}
[Fact]
public void EnsuresNotNullArguments()
{
var gitHubClient = Substitute.For<IGitHubClient>();
var client = new ObservableReactionsClient(gitHubClient);
Assert.Throws<ArgumentNullException>(() => client.CommitComment.Create(null, "name", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentNullException>(() => client.CommitComment.Create("owner", null, 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentNullException>(() => client.CommitComment.Create("owner", "name", 1, null));
Assert.Throws<ArgumentNullException>(() => client.CommitComment.Create(1, 1, null));
Assert.Throws<ArgumentException>(() => client.CommitComment.Create("", "name", 1, new NewReaction(ReactionType.Heart)));
Assert.Throws<ArgumentException>(() => client.CommitComment.Create("owner", "", 1, new NewReaction(ReactionType.Heart)));
}
}
}
}