mirror of
https://github.com/zoriya/octokit.net.git
synced 2026-06-04 11:24:44 +00:00
Add ApiOption overloads to methods on IRepoCollaboratorsClient (#1282)
This commit is contained in:
committed by
Brendan Forster
parent
159bc59c27
commit
63a8c1d70a
@@ -1,7 +1,4 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks;
|
||||
using Octokit;
|
||||
using Octokit.Tests.Integration;
|
||||
using Xunit;
|
||||
@@ -29,6 +26,91 @@ public class RepositoryCollaboratorClientTests
|
||||
Assert.Equal(2, collaborators.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfCollaboratorsWithoutStart()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
|
||||
{
|
||||
var fixture = github.Repository.Collaborator;
|
||||
|
||||
// add some collaborators
|
||||
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options);
|
||||
Assert.NotNull(collaborators);
|
||||
Assert.Equal(1, collaborators.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsCorrectCountOfCollaboratorsWithStart()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
|
||||
{
|
||||
var fixture = github.Repository.Collaborator;
|
||||
|
||||
// add some collaborators
|
||||
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
|
||||
|
||||
var options = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, options);
|
||||
Assert.NotNull(collaborators);
|
||||
Assert.Equal(1, collaborators.Count);
|
||||
}
|
||||
}
|
||||
|
||||
[IntegrationTest]
|
||||
public async Task ReturnsDistinctResultsBasedOnStartPage()
|
||||
{
|
||||
var github = Helper.GetAuthenticatedClient();
|
||||
var repoName = Helper.MakeNameWithTimestamp("public-repo");
|
||||
|
||||
using (var context = await github.CreateRepositoryContext(new NewRepository(repoName)))
|
||||
{
|
||||
var fixture = github.Repository.Collaborator;
|
||||
|
||||
// add some collaborators
|
||||
await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests");
|
||||
|
||||
var startOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1
|
||||
};
|
||||
|
||||
var firstPage = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, startOptions);
|
||||
|
||||
var skipStartOptions = new ApiOptions
|
||||
{
|
||||
PageSize = 1,
|
||||
PageCount = 1,
|
||||
StartPage = 2
|
||||
};
|
||||
|
||||
var secondPage = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, skipStartOptions);
|
||||
|
||||
Assert.NotEqual(firstPage[0].Id, secondPage[0].Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public class TheIsCollaboratorMethod
|
||||
|
||||
Reference in New Issue
Block a user