diff --git a/Octokit.Tests.Integration/Clients/RepositoryPagesClientTests.cs b/Octokit.Tests.Integration/Clients/RepositoryPagesClientTests.cs new file mode 100644 index 00000000..3dbdd3a5 --- /dev/null +++ b/Octokit.Tests.Integration/Clients/RepositoryPagesClientTests.cs @@ -0,0 +1,86 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Octokit; +using Octokit.Tests.Integration; +using Octokit.Tests.Integration.Helpers; +using Xunit; + +public class RepositoryPagesClientTests +{ + public class TheGetAllMethod + { + readonly IRepositoryPagesClient _repositoryPagesClient; + const string owner = "octokit"; + const string name = "octokit.net"; + + public TheGetAllMethod() + { + var github = Helper.GetAuthenticatedClient(); + _repositoryPagesClient = github.Repository.Page; + } + + [IntegrationTest] + public async Task ReturnsPages() + { + var pages = await _repositoryPagesClient.GetAll(owner, name); + Assert.NotEmpty(pages); + } + + [IntegrationTest] + public async Task ReturnsCorrectCountOfPagesWithoutStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var pages = await _repositoryPagesClient.GetAll(owner, name, options); + Assert.Equal(5, pages.Count); + } + + [IntegrationTest] + public async Task ReturnCorrectCountOfPagesWithStart() + { + var options = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var pages = await _repositoryPagesClient.GetAll(owner, name, options); + Assert.Equal(5, pages.Count); + } + + [IntegrationTest] + public async Task ReturnsDistinctResultsBasedOnStartPage() + { + var startOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1 + }; + + var firstPage = await _repositoryPagesClient.GetAll(owner, name, startOptions); + + var skipStartOptions = new ApiOptions + { + PageSize = 5, + PageCount = 1, + StartPage = 2 + }; + + var secondPage = await _repositoryPagesClient.GetAll(owner, name, skipStartOptions); + + Assert.NotEqual(firstPage[0].Url, secondPage[0].Url); + Assert.NotEqual(firstPage[1].Url, secondPage[1].Url); + Assert.NotEqual(firstPage[2].Url, secondPage[2].Url); + Assert.NotEqual(firstPage[3].Url, secondPage[3].Url); + Assert.NotEqual(firstPage[4].Url, secondPage[4].Url); + } + } +} \ No newline at end of file diff --git a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj index 26098482..da5d7e9e 100644 --- a/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj +++ b/Octokit.Tests.Integration/Octokit.Tests.Integration.csproj @@ -101,6 +101,7 @@ + diff --git a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs index 4907c3d1..29932402 100644 --- a/Octokit.Tests/Clients/RepositoryPagesClientTests.cs +++ b/Octokit.Tests/Clients/RepositoryPagesClientTests.cs @@ -31,7 +31,7 @@ namespace Octokit.Tests.Clients } } - public class TheGetAllBuildsMethod + public class TheGetAllMethod { [Fact] public void RequestsCorrectUrl()