mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-09 04:56:29 +00:00
Add ApiOption overloads to IIssuesClient and IObservableIssuesClient (#1274)
This commit is contained in:
@@ -36,8 +36,43 @@ public class ObservableIssuesClientTests
|
||||
}
|
||||
}
|
||||
|
||||
public class TheGetForRepositoryMethod
|
||||
public class TheGetAllForRepositoryMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
{
|
||||
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
var options = new ApiOptions();
|
||||
var request = new RepositoryIssueRequest();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository(null, "name", request, options).ToTask());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("", "name", request, options).ToTask());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", null, request, options).ToTask());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForRepository("owner", "", request, options).ToTask());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (ApiOptions)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", (RepositoryIssueRequest)null).ToTask());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", null, options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForRepository("owner", "name", request, null).ToTask());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReturnsEveryPageOfIssues()
|
||||
{
|
||||
@@ -82,9 +117,9 @@ public class ObservableIssuesClientTests
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"), Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, null, null)
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string,string>>(), null)
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, null, null)
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>(), null)
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
@@ -99,6 +134,21 @@ public class ObservableIssuesClientTests
|
||||
|
||||
public class TheGetAllForOwnedAndMemberRepositoriesMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories((ApiOptions)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories((IssueRequest)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories(null, new ApiOptions()).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(
|
||||
() => client.GetAllForOwnedAndMemberRepositories(new IssueRequest(), null).ToTask());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReturnsEveryPageOfIssues()
|
||||
{
|
||||
@@ -141,11 +191,12 @@ public class ObservableIssuesClientTests
|
||||
&& d["direction"] == "desc"
|
||||
&& d["state"] == "open"
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"), Arg.Any<string>())
|
||||
&& d["filter"] == "assigned"),
|
||||
Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, null, null)
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string,string>>(), null)
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, null, null)
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>(), null)
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
@@ -160,6 +211,31 @@ public class ObservableIssuesClientTests
|
||||
|
||||
public class TheGetAllForOrganizationMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresArgumentsNotNull()
|
||||
{
|
||||
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
var options = new ApiOptions();
|
||||
var request = new RepositoryIssueRequest();
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null, options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null, request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization(null, request, options).ToTask());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("").ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("", options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("", request).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentException>(() => client.GetAllForOrganization("", request, options).ToTask());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", (ApiOptions)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", (IssueRequest)null).ToTask());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", null, options).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForOrganization("org", request, null).ToTask());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReturnsEveryPageOfIssues()
|
||||
{
|
||||
@@ -204,10 +280,11 @@ public class ObservableIssuesClientTests
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"), Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, null, null)
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string,string>>(), null)
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, null, null)
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>(), null)
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => lastPageResponse));
|
||||
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
var results = await client.GetAllForOrganization("test").ToArray();
|
||||
@@ -221,6 +298,17 @@ public class ObservableIssuesClientTests
|
||||
|
||||
public class TheGetAllForCurrentMethod
|
||||
{
|
||||
[Fact]
|
||||
public async Task EnsuresNonNullArguments()
|
||||
{
|
||||
var client = new ObservableIssuesClient(Substitute.For<IGitHubClient>());
|
||||
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent((ApiOptions)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent((IssueRequest)null).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent(null, new ApiOptions()).ToTask());
|
||||
await Assert.ThrowsAsync<ArgumentNullException>(() => client.GetAllForCurrent(new IssueRequest(), null).ToTask());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ReturnsEveryPageOfIssues()
|
||||
{
|
||||
@@ -265,9 +353,9 @@ public class ObservableIssuesClientTests
|
||||
&& d["sort"] == "created"
|
||||
&& d["filter"] == "assigned"), Arg.Any<string>())
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => firstPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, null, null)
|
||||
gitHubClient.Connection.Get<List<Issue>>(secondPageUrl, Arg.Any<Dictionary<string, string>>(), null)
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => secondPageResponse));
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, null, null)
|
||||
gitHubClient.Connection.Get<List<Issue>>(thirdPageUrl, Arg.Any<Dictionary<string, string>>(), null)
|
||||
.Returns(Task.Factory.StartNew<IApiResponse<List<Issue>>>(() => lastPageResponse));
|
||||
var client = new ObservableIssuesClient(gitHubClient);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user