-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1304 from shiftkey/shiftkey-repository-pages-api-…
…options Added ApiOption overloads to methods on I(Observable)RepositoryPagesClient
- Loading branch information
Showing
11 changed files
with
217 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
Octokit.Tests.Integration/Clients/RepositoryPagesClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Threading.Tasks; | ||
using Octokit; | ||
using Octokit.Tests.Integration; | ||
using Xunit; | ||
|
||
public class RepositoryPagesClientTests | ||
{ | ||
public class TheGetMethod | ||
{ | ||
readonly IRepositoryPagesClient _repositoryPagesClient; | ||
const string owner = "octokit"; | ||
const string name = "octokit.net"; | ||
|
||
public TheGetMethod() | ||
{ | ||
var github = Helper.GetAuthenticatedClient(); | ||
_repositoryPagesClient = github.Repository.Page; | ||
} | ||
|
||
[IntegrationTest(Skip= "These tests require repository admin rights - see https://github.com/octokit/octokit.net/issues/1263 for discussion")] | ||
public async Task ReturnsMetadata() | ||
{ | ||
var data = await _repositoryPagesClient.Get(owner, name); | ||
Assert.Equal("https://api.github.com/repos/octokit/octokit.net/pages", data.Url); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -103,4 +103,4 @@ public void Dispose() | |
{ | ||
Helper.DeleteRepo(_repository); | ||
} | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
Octokit.Tests.Integration/Reactive/ObservableRepositoryPagesClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
using System.Reactive.Linq; | ||
using System.Threading.Tasks; | ||
using Octokit.Reactive; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Integration.Reactive | ||
{ | ||
public class ObservableRepositoryPagesClientTests | ||
{ | ||
public class TheGetAllMethod | ||
{ | ||
readonly ObservableRepositoryPagesClient _repositoryPagesClient; | ||
const string owner = "octokit"; | ||
const string name = "octokit.net"; | ||
|
||
public TheGetAllMethod() | ||
{ | ||
var github = Helper.GetAuthenticatedClient(); | ||
|
||
_repositoryPagesClient = new ObservableRepositoryPagesClient(github); | ||
} | ||
|
||
[IntegrationTest(Skip = "These tests require repository admin rights - see https://github.com/octokit/octokit.net/issues/1263 for discussion")] | ||
public async Task ReturnsAllRepositoryPagesBuilds() | ||
{ | ||
var pages = await _repositoryPagesClient.GetAll(owner, name).ToList(); | ||
|
||
Assert.NotEmpty(pages); | ||
} | ||
|
||
[IntegrationTest(Skip = "These tests require repository admin rights - see https://github.com/octokit/octokit.net/issues/1263 for discussion")] | ||
public async Task ReturnsPageOfRepositoryBuilds() | ||
{ | ||
var options = new ApiOptions | ||
{ | ||
PageSize= 5, | ||
PageCount = 1 | ||
}; | ||
|
||
var pages = await _repositoryPagesClient.GetAll(owner, name, options).ToList(); | ||
|
||
Assert.Equal(5, pages.Count); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
Octokit.Tests/Reactive/ObservableRepositoryPagesClientTests.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using NSubstitute; | ||
using Octokit.Reactive; | ||
using Xunit; | ||
|
||
namespace Octokit.Tests.Reactive | ||
{ | ||
public class ObservableRepositoryPagesClientTests | ||
{ | ||
public class TheCtor | ||
{ | ||
[Fact] | ||
public void EnsuresNonNullArguments() | ||
{ | ||
Assert.Throws<ArgumentNullException>(() => new ObservableRepositoryPagesClient(null)); | ||
} | ||
} | ||
|
||
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.Received().Repository.Page.GetAll("fake", "repo", options); | ||
} | ||
|
||
[Fact] | ||
public void EnsuresNonNullArguments() | ||
{ | ||
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)); | ||
} | ||
|
||
[Fact] | ||
public void EnsuresNonEmptyArguments() | ||
{ | ||
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())); | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters