added unit tests

This commit is contained in:
aedampir@gmail.com
2016-05-25 12:40:26 +07:00
parent 2b41b0d553
commit 622c19a974
2 changed files with 65 additions and 4 deletions
@@ -27,6 +27,10 @@ namespace Octokit.Tests.Reactive
{
Assert.Throws<ArgumentNullException>(() => _client.GetAll(null, "repo", 1));
Assert.Throws<ArgumentNullException>(() => _client.GetAll("owner", null, 1));
Assert.Throws<ArgumentNullException>(() => _client.GetAll(null, "repo", 1, ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => _client.GetAll("owner", null, 1, ApiOptions.None));
Assert.Throws<ArgumentNullException>(() => _client.GetAll("owner", "repo", 1, null));
}
[Fact]
@@ -34,6 +38,9 @@ namespace Octokit.Tests.Reactive
{
Assert.Throws<ArgumentException>(() => _client.GetAll("", "repo", 1));
Assert.Throws<ArgumentException>(() => _client.GetAll("owner", "", 1));
Assert.Throws<ArgumentException>(() => _client.GetAll("", "repo", 1, ApiOptions.None));
Assert.Throws<ArgumentException>(() => _client.GetAll("owner", "", 1, ApiOptions.None));
}
[Fact]
@@ -43,10 +50,15 @@ namespace Octokit.Tests.Reactive
async whitespace => await _client.GetAll(whitespace, "repo", 1));
await AssertEx.ThrowsWhenGivenWhitespaceArgument(
async whitespace => await _client.GetAll("owner", whitespace, 1));
await AssertEx.ThrowsWhenGivenWhitespaceArgument(
async whitespace => await _client.GetAll(whitespace, "repo", 1, ApiOptions.None));
await AssertEx.ThrowsWhenGivenWhitespaceArgument(
async whitespace => await _client.GetAll("owner", whitespace, 1, ApiOptions.None));
}
[Fact]
public void GetsFromCorrectUrl()
public void RequestsCorrectUrl()
{
var expectedUri = ApiUrls.DeploymentStatuses("owner", "repo", 1);
@@ -54,8 +66,28 @@ namespace Octokit.Tests.Reactive
_githubClient.Connection.Received(1)
.Get<List<DeploymentStatus>>(Arg.Is(expectedUri),
Arg.Any<IDictionary<string, string>>(),
Arg.Any<string>());
Args.EmptyDictionary,
null);
}
[Fact]
public void RequestsCorrectUrlWitApiOptions()
{
var expectedUri = ApiUrls.DeploymentStatuses("owner", "repo", 1);
var options = new ApiOptions
{
StartPage = 1,
PageCount = 1,
PageSize = 1
};
_client.GetAll("owner", "repo", 1, options);
_githubClient.Connection.Received(1)
.Get<List<DeploymentStatus>>(Arg.Is(expectedUri),
Arg.Is<Dictionary<string, string>>(dictionary => dictionary.Count == 2),
null);
}
}