public DeploymentStatusClientTests()
    {
        var github = Helper.GetAuthenticatedClient();

        _deploymentsClient = github.Repository.Deployment;
        _context = github.CreateRepositoryContext("public-repo").Result;

        var blob = new NewBlob
        {
            Content = "Hello World!",
            Encoding = EncodingType.Utf8
        };

        var blobResult = github.Git.Blob.Create(_context.RepositoryOwner, _context.RepositoryName, blob).Result;

        var newTree = new NewTree();
        newTree.Tree.Add(new NewTreeItem
        {
            Type = TreeType.Blob,
            Mode = FileMode.File,
            Path = "README.md",
            Sha = blobResult.Sha
        });

        var treeResult = github.Git.Tree.Create(_context.RepositoryOwner, _context.RepositoryName, newTree).Result;
        var newCommit = new NewCommit("test-commit", treeResult.Sha);

        var commit = github.Git.Commit.Create(_context.RepositoryOwner, _context.RepositoryName, newCommit).Result;

        var newDeployment = new NewDeployment(commit.Sha) { AutoMerge = false };
        _deployment = _deploymentsClient.Create(_context.RepositoryOwner, _context.RepositoryName, newDeployment).Result;
    }
    public AssigneesClientTests()
    {
        _github = Helper.GetAuthenticatedClient();
        var repoName = Helper.MakeNameWithTimestamp("public-repo");

        _context = _github.CreateRepositoryContext(new NewRepository(repoName)).Result;
    }
    public RepositoryDeployKeysClientTests()
    {
        var github = Helper.GetAuthenticatedClient();

        _fixture = github.Repository.DeployKeys;
        _context = github.CreateRepositoryContext("public-repo").Result;
    }
 public TheCreateReactionMethod()
 {
     _github = Helper.GetAuthenticatedClient();
     var repoName = Helper.MakeNameWithTimestamp("public-repo");
     _issuesClient = _github.Issue;
     _context = _github.CreateRepositoryContext(new NewRepository(repoName)).Result;
 }
    public BlobClientTests()
    {
        var github = Helper.GetAuthenticatedClient();
        _fixture = github.Git.Blob;

        _context = github.CreateRepositoryContext("public-repo").Result;
    }
        public TheGetReleasesMethod()
        {
            var github = Helper.GetAuthenticatedClient();
            _releaseClient = github.Repository.Release;

            _context = github.CreateRepositoryContext("public-repo").Result;
        }
    public ReferencesClientTests()
    {
        _github = Helper.GetAuthenticatedClient();

        _fixture = _github.Git.Reference;

        _context = _github.CreateRepositoryContext("public-repo").Result;
    }
Example #8
0
    public TreeClientTests()
    {
        _github = Helper.GetAuthenticatedClient();

        _fixture = _github.GitDatabase.Tree;

        _context = _github.CreateRepositoryContext("public-repo").Result;
    }
Example #9
0
    public PullRequestsClientTests()
    {
        _github = Helper.GetAuthenticatedClient();

        _fixture = _github.Repository.PullRequest;
        _repositoryCommentsClient = _github.Repository.RepositoryComments;

        _context = _github.CreateRepositoryContext("source-repo").Result;
    }
        public ObservableIssueTimelineClientTests()
        {
            var github = Helper.GetAuthenticatedClient();

            _client = new ObservableGitHubClient(github);

            var reponame = Helper.MakeNameWithTimestamp("public-repo");
            _context = github.CreateRepositoryContext(new NewRepository(reponame)).Result;
        }
    public MilestonesClientTests()
    {
        var github = Helper.GetAuthenticatedClient();

        _milestonesClient = github.Issue.Milestone;
        var repoName = Helper.MakeNameWithTimestamp("public-repo");

        _context = github.CreateRepositoryContext(new NewRepository(repoName)).Result;
    }
    public PullRequestReviewCommentsClientTests()
    {
        _github = Helper.GetAuthenticatedClient();

        _client = _github.PullRequest.Comment;

        // We'll create a pull request that can be used by most tests
        _context = _github.CreateRepositoryContext("test-repo").Result;
    }
    public MergingClientTests()
    {
        _github = new GitHubClient(new ProductHeaderValue("OctokitTests"))
        {
            Credentials = Helper.Credentials
        };

        _fixture = _github.Repository.Merging;
        _context = _github.CreateRepositoryContext("public-repo").Result;
    }
        public StarredClientTests()
        {
            _client = Helper.GetAuthenticatedClient();
            _fixture = _client.Activity.Starring;

            var github = Helper.GetAuthenticatedClient();
            var repoName = Helper.MakeNameWithTimestamp("public-repo1");

            _repositoryContext = github.CreateRepositoryContext(new NewRepository(repoName)).Result;

            _fixture.RemoveStarFromRepo(_repositoryContext.RepositoryOwner, _repositoryContext.RepositoryName).Wait();
            _fixture.RemoveStarFromRepo("octokit", "octokit.net").Wait();
            _fixture.StarRepo(_repositoryContext.RepositoryOwner, _repositoryContext.RepositoryName).Wait();
            _fixture.StarRepo("octokit", "octokit.net").Wait();
        }
Example #15
0
            public TheGetMethod()
            {
                var github = Helper.GetAuthenticatedClient();

                fixture = github.Git.Tag;
                context = github.CreateRepositoryContext("public-repo").Result;

                var blob = new NewBlob
                {
                    Content = "Hello World!",
                    Encoding = EncodingType.Utf8
                };
                var blobResult = github.Git.Blob.Create(context.RepositoryOwner, context.RepositoryName, blob).Result;

                sha = blobResult.Sha;
            }
 public RepositorySummary(RepositoryContext context)
 {
     Name = context.Repository.Name;
     Owner = context.Repository.Owner.Login;
 }
        public TheAddRequiredStatusChecksContextsMethod()
        {
            var github = Helper.GetAuthenticatedClient();
            _client = github.Repository.Branch;

            _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result;
        }
    /// <summary>
    /// Creates the base state for testing (creates a repo, a commit in master, a branch, a commit in the branch and a pull request)
    /// </summary>
    /// <returns></returns>
    async Task<PullRequestData> CreatePullRequest(RepositoryContext context)
    {
        var repoName = context.RepositoryName;

        // Creating a commit in master

        var createdCommitInMaster = await CreateCommit(repoName, "Hello World!", "README.md", "heads/master", "A master commit message");

        // Creating a branch

        var newBranch = new NewReference(branchRef, createdCommitInMaster.Sha);
        await _github.Git.Reference.Create(Helper.UserName, repoName, newBranch);

        // Creating a commit in the branch

        var createdCommitInBranch = await CreateCommit(repoName, "Hello from the fork!", path, branchHead, "A branch commit message");

        // Creating a pull request

        var pullRequest = new NewPullRequest("Nice title for the pull request", branchName, "master");
        var createdPullRequest = await _github.PullRequest.Create(Helper.UserName, repoName, pullRequest);

        var data = new PullRequestData
        {
            Sha = createdCommitInBranch.Sha,
            Number = createdPullRequest.Number,
        };

        return data;
    }
        public TheDeleteMethod()
        {
            var gitHubClient = Helper.GetAuthenticatedClient();

            var repoName = Helper.MakeNameWithTimestamp("public-repo");

            _context = gitHubClient.CreateRepositoryContext(new NewRepository(repoName)).Result;

            _issuesClient = gitHubClient.Issue;
            _issueCommentsClient = gitHubClient.Issue.Comment;
        }
        public TheDeleteMethod()
        {
            _github = Helper.GetAuthenticatedClient();

            _context = _github.CreateRepositoryContext("public-repo").Result;
        }
            public TheCheckWatchedMethod()
            {
                var github = Helper.GetAuthenticatedClient();

                _watchingClient = github.Activity.Watching;

                _context = github.CreateRepositoryContext("public-repo").Result;
            }
        public TheUpdateBranchProtectionMethod()
        {
            var github = Helper.GetAuthenticatedClient();
            _client = github.Repository.Branch;

            _userRepoContext = github.CreateRepositoryWithProtectedBranch().Result;
            _orgRepoContext = github.CreateOrganizationRepositoryWithProtectedBranch().Result;
        }
        public TheUploadAssetMethod()
        {
            _github = Helper.GetAuthenticatedClient();
            _releaseClient = _github.Repository.Release;

            _context = _github.CreateRepositoryContext("public-repo").Result;
        }
 public TheEditBranchMethod()
 {
     var github = Helper.GetAuthenticatedClient();
     _context = github.CreateRepositoryContext("source-repo").Result;
     _fixture = github.Repository;
 }
        public TestsWithNewRepository()
        {
            _github = Helper.GetAuthenticatedClient();

            _fixture = _github.Repository.Commits;

            _context = _github.CreateRepositoryContext("source-repo").Result;
        }