mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-05 03:30:34 +00:00
added unit tests
This commit is contained in:
@@ -31,6 +31,17 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new RepositoryForksClient(connection);
|
||||
|
||||
await client.GetAll(1);
|
||||
|
||||
connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/forks"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithApiOptions()
|
||||
{
|
||||
@@ -49,6 +60,24 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryIdWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new RepositoryForksClient(connection);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
await client.GetAll(1, options);
|
||||
|
||||
connection.Received().GetAll<Repository>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/forks"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRequestParameters()
|
||||
{
|
||||
@@ -62,6 +91,19 @@ namespace Octokit.Tests.Clients
|
||||
Arg.Is<Dictionary<string, string>>(d => d["sort"] == "stargazers"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryIdWithRequestParameters()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new RepositoryForksClient(connection);
|
||||
|
||||
await client.GetAll(1, new RepositoryForksListRequest { Sort = Sort.Stargazers });
|
||||
|
||||
connection.Received().GetAll<Repository>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "repositories/1/forks"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["sort"] == "stargazers"), Args.ApiOptions);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRequestParametersWithApiOptions()
|
||||
{
|
||||
@@ -82,6 +124,26 @@ namespace Octokit.Tests.Clients
|
||||
Arg.Is<Dictionary<string, string>>(d => d["sort"] == "stargazers"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task RequestsCorrectUrlWithRepositoryIdWithRequestParametersWithApiOptions()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new RepositoryForksClient(connection);
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageCount = 1,
|
||||
StartPage = 1,
|
||||
PageSize = 1
|
||||
};
|
||||
|
||||
await client.GetAll(1, new RepositoryForksListRequest { Sort = Sort.Stargazers }, options);
|
||||
|
||||
connection.Received().GetAll<Repository>(
|
||||
Arg.Is<Uri>(u => u.ToString() == "repositories/1/forks"),
|
||||
Arg.Is<Dictionary<string, string>>(d => d["sort"] == "stargazers"), options);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -98,6 +160,9 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", null, new RepositoryForksListRequest(), ApiOptions.None));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll("owner", "name", new RepositoryForksListRequest(), null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(1, (ApiOptions)null));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAll(1, new RepositoryForksListRequest(), null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name"));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("owner", ""));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAll("", "name", ApiOptions.None));
|
||||
@@ -124,6 +189,19 @@ namespace Octokit.Tests.Clients
|
||||
connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "repos/fake/repo/forks"), newRepositoryFork);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void RequestsCorrectUrlWithRepositoryId()
|
||||
{
|
||||
var connection = Substitute.For<IApiConnection>();
|
||||
var client = new RepositoryForksClient(connection);
|
||||
|
||||
var newRepositoryFork = new NewRepositoryFork();
|
||||
|
||||
client.Create(1, newRepositoryFork);
|
||||
|
||||
connection.Received().Post<Repository>(Arg.Is<Uri>(u => u.ToString() == "repositories/1/forks"), newRepositoryFork);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
@@ -133,6 +211,8 @@ namespace Octokit.Tests.Clients
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", null, new NewRepositoryFork()));
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create("owner", "name", null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.Create(1, null));
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("", "name", new NewRepositoryFork()));
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.Create("owner", "", new NewRepositoryFork()));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user