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 = new ObservableRepoCollaboratorsClient(github); // 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).ToList(); Assert.NotNull(collaborators); Assert.Equal(1, collaborators.Count); } }
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 = new ObservableRepoCollaboratorsClient(github); // 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).ToList(); var skipStartOptions = new ApiOptions { PageSize = 1, PageCount = 1, StartPage = 2 }; var secondPage = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName, skipStartOptions).ToList(); Assert.NotEqual(firstPage[0].Id, secondPage[0].Id); } }
public async Task ReturnsAdminPermissionForOwnerWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = new ObservableRepoCollaboratorsClient(github); var permission = await fixture.ReviewPermission(context.RepositoryId, context.RepositoryOwner); Assert.Equal(PermissionLevel.Admin, permission.Permission); } }
public async Task ReturnsWritePermissionForCollaborator() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = new ObservableRepoCollaboratorsClient(github); // add a collaborator await fixture.Add(context.RepositoryOwner, context.RepositoryName, "alfhenrik-test-2"); var permission = await fixture.ReviewPermission(context.RepositoryOwner, context.RepositoryName, "alfhenrik-test-2"); Assert.Equal(PermissionLevel.Write, permission.Permission); } }
public async Task ReturnsTrueIfUserIsCollaborator() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = new ObservableRepoCollaboratorsClient(github); // add a collaborator fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); var isCollab = await fixture.IsCollaborator(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); Assert.True(isCollab); } }
public async Task ReturnsAllCollaborators() { var github = Helper.GetAuthenticatedClient(); var repoName = Helper.MakeNameWithTimestamp("public-repo"); using (var context = await github.CreateRepositoryContext(new NewRepository(repoName))) { var fixture = new ObservableRepoCollaboratorsClient(github); // add a collaborator await fixture.Add(context.RepositoryOwner, context.RepositoryName, "m-zuber-octokit-integration-tests"); var collaborators = await fixture.GetAll(context.RepositoryOwner, context.RepositoryName).ToList(); Assert.NotNull(collaborators); Assert.Equal(2, collaborators.Count); } }
public async Task ReturnsNonePermissionForPrivateRepositoryWithRepositoryId() { var github = Helper.GetAuthenticatedClient(); var userDetails = await github.User.Current(); if (userDetails.Plan.PrivateRepos == 0) { throw new Exception("Test cannot complete, account is on free plan"); } var repoName = Helper.MakeNameWithTimestamp("private-repo"); using (var context = await github.CreateRepositoryContext(new NewRepository(repoName) { Private = true })) { var fixture = new ObservableRepoCollaboratorsClient(github); var permission = await fixture.ReviewPermission(context.RepositoryId, "alfhenrik-test-2"); Assert.Equal(PermissionLevel.None, permission.Permission); } }