wrote some tests to verify the behaviour of the pagination

This commit is contained in:
Brendan Forster
2016-02-14 15:47:29 +11:00
parent 03ea831489
commit 4da9f3e8f7
@@ -75,6 +75,83 @@ public class ReleasesClientTests
}
}
public class TheGetAllMethod
{
readonly IReleasesClient _releaseClient;
const string owner = "octokit";
const string name = "octokit.net";
public TheGetAllMethod()
{
var github = Helper.GetAuthenticatedClient();
_releaseClient = github.Repository.Release;
}
[IntegrationTest]
public async Task ReturnsReleases()
{
var releases = await _releaseClient.GetAll(owner, name);
Assert.NotEmpty(releases);
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfReleasesWithoutStart()
{
var options = new ApiOptions
{
PageSize = 5,
PageCount = 1
};
var releases = await _releaseClient.GetAll(owner, name, options);
Assert.Equal(5, releases.Count);
}
[IntegrationTest]
public async Task ReturnsCorrectCountOfReleasesWithStart()
{
var options = new ApiOptions
{
PageSize = 5,
PageCount = 1,
StartPage = 2
};
var releases = await _releaseClient.GetAll(owner, name, options);
Assert.Equal(5, releases.Count);
}
[IntegrationTest]
public async Task ReturnsDistinctResultsBasedOnStartPage()
{
var startOptions = new ApiOptions
{
PageSize = 5,
PageCount = 1
};
var firstPage = await _releaseClient.GetAll(owner, name, startOptions);
var skipStartOptions = new ApiOptions
{
PageSize = 5,
PageCount = 1,
StartPage = 2
};
var secondPage = await _releaseClient.GetAll(owner, name, skipStartOptions);
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
Assert.NotEqual(firstPage[1].Id, secondPage[1].Id);
Assert.NotEqual(firstPage[2].Id, secondPage[2].Id);
Assert.NotEqual(firstPage[3].Id, secondPage[3].Id);
Assert.NotEqual(firstPage[4].Id, secondPage[4].Id);
}
}
public class TheEditMethod : IDisposable
{
private readonly IGitHubClient _github;