Added unit tests for Reactive functions

This commit is contained in:
Prayank Mathur
2016-04-10 17:02:37 +05:30
parent 8ca8227ba0
commit 2f1943a640
5 changed files with 66 additions and 0 deletions
@@ -0,0 +1,48 @@
using System;
using NSubstitute;
using Octokit.Reactive;
using Xunit;
namespace Octokit.Tests.Reactive
{
public class ObservableRepositoryPagesClientTests
{
public class TheGetAllMethod
{
[Fact]
public void RequestsCorrectUrl()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryPagesClient(githubClient);
var options = new ApiOptions();
client.GetAll("fake", "repo", options);
githubClient.Repository.Page.Received().GetAll("fake", "repo", options);
}
[Fact]
public void EnsuresNonNullArguments()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryPagesClient(githubClient);
var options = new ApiOptions();
Assert.Throws<ArgumentNullException>(() => client.GetAll(null, "repo", new ApiOptions()));
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", null, new ApiOptions()));
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", "repo", null));
}
[Fact]
public void EnsuresNonEmptyArguments()
{
var githubClient = Substitute.For<IGitHubClient>();
var client = new ObservableRepositoryPagesClient(githubClient);
var options = new ApiOptions();
Assert.Throws<ArgumentException>(() => client.GetAll("", "repo", new ApiOptions()));
Assert.Throws<ArgumentException>(() => client.GetAll("owner", "", new ApiOptions()));
}
}
}
}