mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-07 04:16:51 +00:00
added unit tests
This commit is contained in:
@@ -16,38 +16,150 @@ namespace Octokit.Tests.Reactive
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllMethod
|
||||
public class TheGetMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(githubClient);
|
||||
var options = new ApiOptions();
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
client.GetAll("fake", "repo", options);
|
||||
githubClient.Received().Repository.Page.GetAll("fake", "repo", options);
|
||||
client.Get("fake", "repo");
|
||||
|
||||
gitHubClient.Received().Repository.Page.Get("fake", "repo");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
client.Get(1);
|
||||
|
||||
gitHubClient.Received().Repository.Page.Get(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(githubClient);
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
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));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get(null, "name"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.Get("owner", null));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetAllMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
client.GetAll("fake", "repo");
|
||||
|
||||
gitHubClient.Received().Repository.Page.GetAll("fake", "repo");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonEmptyArguments()
|
||||
public void RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var githubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(githubClient);
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetAll("", "repo", new ApiOptions()));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAll("owner", "", new ApiOptions()));
|
||||
client.GetAll(1);
|
||||
|
||||
gitHubClient.Received().Repository.Page.GetAll(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
client.GetAll("fake", "repo", options);
|
||||
|
||||
gitHubClient.Received().Repository.Page.GetAll("fake", "repo", options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithApiOptionsWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
client.GetAll(1, options);
|
||||
|
||||
gitHubClient.Received().Repository.Page.GetAll(1, options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAll(null, "repo", ApiOptions.None));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", null, ApiOptions.None));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAll("owner", "repo", null));
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetAll(1, null));
|
||||
|
||||
Assert.Throws<ArgumentException>(() => client.GetAll("", "repo", ApiOptions.None));
|
||||
Assert.Throws<ArgumentException>(() => client.GetAll("owner", "", ApiOptions.None));
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetLatestBuildMethod
|
||||
{
|
||||
[Fact]
|
||||
public void RequestsCorrectUrl()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
client.GetLatest("fake", "repo");
|
||||
|
||||
gitHubClient.Received().Repository.Page.GetLatest("fake", "repo");
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
client.GetLatest(1);
|
||||
|
||||
gitHubClient.Received().Repository.Page.GetLatest(1);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void EnsuresNonNullArguments()
|
||||
{
|
||||
var gitHubClient = Substitute.For<IGitHubClient>();
|
||||
var client = new ObservableRepositoryPagesClient(gitHubClient);
|
||||
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetLatest(null, "name"));
|
||||
Assert.Throws<ArgumentNullException>(() => client.GetLatest("owner", null));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user