示例#1
0
            public async Task RemovesReviewEnforcementForOrgRepo()
            {
                using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch())
                {
                    var repoOwner = context.RepositoryContext.RepositoryOwner;
                    var repoName  = context.RepositoryContext.RepositoryName;
                    var deleted   = await _client.RemoveReviewEnforcement(repoOwner, repoName, "master");

                    Assert.True(deleted);
                }
            }
        public async Task DeletesRProtectedBranchRestrictionsForOrgRepo()
        {
            using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch())
            {
                var repoOwner = context.RepositoryContext.RepositoryOwner;
                var repoName  = context.RepositoryContext.RepositoryName;
                var deleted   = await _client.DeleteProtectedBranchRestrictions(repoOwner, repoName, "master");

                Assert.True(deleted);
            }
        }
        public TheAddProtectedBranchUserRestrictionsMethod()
        {
            _github = Helper.GetAuthenticatedClient();
            _client = _github.Repository.Branch;

            _orgRepoContext = _github.CreateOrganizationRepositoryWithProtectedBranch().Result;
        }
        public async Task DeletesRProtectedBranchTeamRestrictionsForOrgRepo()
        {
            using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch())
            {
                var repoOwner    = context.RepositoryContext.RepositoryOwner;
                var repoName     = context.RepositoryContext.RepositoryName;
                var teamToRemove = new BranchProtectionTeamCollection()
                {
                    context.TeamContext.TeamName
                };
                var deleted = await _client.DeleteProtectedBranchTeamRestrictions(repoOwner, repoName, "master", teamToRemove);

                Assert.NotNull(deleted);
                Assert.Equal(0, deleted.Count);
            }
        }
        public TheAddProtectedBranchTeamRestrictionsMethod()
        {
            _github = Helper.GetAuthenticatedClient();
            _client = _github.Repository.Branch;

            _contextOrgTeam2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result;
            _orgRepoContext  = _github.CreateOrganizationRepositoryWithProtectedBranch().Result;
        }
        public async Task DeletesProtectedBranchUserRestrictionsForOrgRepo()
        {
            using (var context = await _github.CreateOrganizationRepositoryWithProtectedBranch())
            {
                var repoOwner = context.RepositoryContext.RepositoryOwner;
                var repoName  = context.RepositoryContext.RepositoryName;
                var user      = new BranchProtectionUserCollection()
                {
                    _github.User.Current().Result.Login
                };
                var restrictions = await _client.AddProtectedBranchUserRestrictions(repoOwner, repoName, "master", user);

                Assert.NotNull(restrictions);
                Assert.Equal(1, restrictions.Count);

                var deleted = await _client.DeleteProtectedBranchUserRestrictions(repoOwner, repoName, "master", user);

                Assert.NotNull(deleted);
                Assert.Equal(0, deleted.Count);
            }
        }
        public TheUpdateProtectedBranchTeamRestrictionsMethod()
        {
            _github = Helper.GetAuthenticatedClient();
            _client = _github.Repository.Branch;

            _contextOrgTeam2 = _github.CreateTeamContext(Helper.Organization, new NewTeam(Helper.MakeNameWithTimestamp("team2"))).Result;
            _orgRepoContext = _github.CreateOrganizationRepositoryWithProtectedBranch().Result;
        }
        public TheAddProtectedBranchUserRestrictionsMethod()
        {
            _github = Helper.GetAuthenticatedClient();
            _client = _github.Repository.Branch;

            _orgRepoContext = _github.CreateOrganizationRepositoryWithProtectedBranch().Result;
        }