/// <summary>
        /// Initializes a new instance of the <see cref="PullRequestRetriever"/> class.
        /// </summary>
        /// <param name="builder">The <see cref="IPullRequestBuilder"/> instance to build pull request objects with.</param>
        /// <param name="client">The <see cref="IPullRequestsClient"/> to use for interfacing with GitHub.</param>
        /// <param name="connection">
        /// The <see cref="IConnection"/> object to interface use when interfacing with GitHub.
        /// </param>
        /// <param name="repository">The <see cref="GitHubRepository"/> containing the pull request to comment on.</param>
        public PullRequestRetriever(
            IPullRequestBuilder builder,
            IPullRequestsClient client,
            IConnection connection,
            GitHubRepository repository)
        {
            if (builder == null)
            {
                throw new ArgumentNullException("builder");
            }

            if (client == null)
            {
                throw new ArgumentNullException("client");
            }

            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            this.builder = builder;
            this.client = client;
            this.connection = connection;
            this.repository = repository;
        }
        public ObservablePullRequestsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client     = client.Repository.PullRequest;
            _connection = client.Connection;
        }
        public ObservablePullRequestsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, "client");

            _client = client.Repository.PullRequest;
            _connection = client.Connection;
        }
示例#4
0
    public PullRequestsClientTests()
    {
        _github = Helper.GetAuthenticatedClient();

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

        _context = _github.CreateRepositoryContext("source-repo").Result;
    }
示例#5
0
    public PullRequestsClientTests()
    {
        _github = Helper.GetAuthenticatedClient();

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

        _context = _github.CreateRepositoryContext("source-repo").Result;
    }
        public ObservablePullRequestsClient(IGitHubClient client)
        {
            Ensure.ArgumentNotNull(client, nameof(client));

            _client       = client.Repository.PullRequest;
            _connection   = client.Connection;
            Review        = new ObservablePullRequestReviewsClient(client);
            ReviewComment = new ObservablePullRequestReviewCommentsClient(client);
            ReviewRequest = new ObservablePullRequestReviewRequestsClient(client);
        }
    public PullRequestsClientTests()
    {
        _client = Helper.GetAuthenticatedClient();

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

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

        _repository = _client.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
    }
示例#8
0
        private static void RetrieveCommits(IPullRequestsClient prClient,
                                            PullRequestLocator prLocator,
                                            CommitsCombiner combiner)
        {
            var commits = prClient.Commits(prLocator.Owner, prLocator.Repository,
                                           prLocator.PullRequestNumber).Result;

            DispatcherHelper.RunAsync(() =>
            {
                combiner.Add(commits);
            });
        }
        public void SetUp()
        {
            var mockLogger = Substitute.For <ILogger <GitUtils> >();

            _gitUtils = new GitUtils(mockLogger);

            _mockClient = Substitute.For <IGitHubClient>();
            _mockRepositoryBranchesClient = Substitute.For <IRepositoryBranchesClient>();
            _mockPullRequestsClient       = Substitute.For <IPullRequestsClient>();
            _mockClient.Repository.Branch.Returns(_mockRepositoryBranchesClient);
            _mockClient.Repository.PullRequest.Returns(_mockPullRequestsClient);
        }
    public PullRequestsClientTests()
    {
        _client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
        {
            Credentials = Helper.Credentials
        };

        _fixture = _client.Repository.PullRequest;

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

        _repository = _client.Repository.Create(new NewRepository { Name = repoName, AutoInit = true }).Result;
    }
    public PullRequestsClientTests()
    {
        _client = Helper.GetAuthenticatedClient();

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

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

        _repository = _client.Repository.Create(new NewRepository {
            Name = repoName, AutoInit = true
        }).Result;
    }
    public PullRequestsClientTests()
    {
        _client = new GitHubClient(new ProductHeaderValue("OctokitTests"))
        {
            Credentials = Helper.Credentials
        };

        _fixture = _client.Repository.PullRequest;

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

        _repository = _client.Repository.Create(new NewRepository {
            Name = repoName, AutoInit = true
        }).Result;
    }
示例#13
0
        public void SetUp()
        {
            _compareResults       = new MockCompareResult();
            _gitHubClient         = Substitute.For <IGitHubClient>();
            _repoClient           = Substitute.For <IRepositoriesClient>();
            _commitsClient        = Substitute.For <IRepositoryCommitsClient>();
            _prClient             = Substitute.For <IPullRequestsClient>();
            _contentsClient       = Substitute.For <IRepositoryContentsClient>();
            _fileContentPersist   = Substitute.For <IFileContentPersist>();
            _diffTool             = Substitute.For <IDiffToolLauncher>();
            _patchService         = Substitute.For <IPatchService>();
            _reviewClient         = Substitute.For <IIssueCommentsClient>();
            _commentsBuilder      = Substitute.For <ICommentsBuilder>();
            _commentsPersist      = Substitute.For <ICommentsPersist>();
            _repoHistoryPersist   = Substitute.For <IRepoHistoryPersist>();
            _backgroundTaskRunner = Substitute.For <IBackgroundTaskRunner>();
            var userManager = Substitute.For <IUserManager>();

            _gitHubClient.Repository.Returns(_repoClient);
            _repoClient.Commit.Returns(_commitsClient);
            _repoClient.PullRequest.Returns(_prClient);
            _repoClient.Content.Returns(_contentsClient);
            _gitHubClient.Issue.Comment.Returns(_reviewClient);

            _commitsClient.Compare(Arg.Any <string>(),
                                   Arg.Any <string>(),
                                   Arg.Any <string>(),
                                   Arg.Any <string>()
                                   ).Returns(Task.FromResult((CompareResult)_compareResults));

            _mainWindowVm = new MainWindowVm(_gitHubClient, _fileContentPersist,
                                             _diffTool, _patchService, _commentsBuilder,
                                             _commentsPersist, _repoHistoryPersist, _backgroundTaskRunner, userManager)
            {
                PullRequestLocator = _pullRequestLocator,
                IsUrlMode          = false
            };

            _pullRequest = new MockPullRequest {
                Number = _pullRequestLocator.PullRequestNumber
            };
            _prClient.Get(_mainWindowVm.PullRequestLocator.Owner, _mainWindowVm.PullRequestLocator.Repository,
                          _mainWindowVm.PullRequestLocator.PullRequestNumber).Returns(Task.FromResult((PullRequest)_pullRequest));

            _baseFileName = MainWindowVm.BuildBaseFileName(_pullRequest.Base.Sha, _compareResults.File1.Filename);
            _headFileName = MainWindowVm.BuildHeadFileName(_pullRequest.Head.Sha, _compareResults.File1.Filename);

            _commentsContainer = new CommentsContainer {
                GeneralComments = GeneralComments
            };
            _commentsContainer.FileComments.Add(new FileComment
            {
                FileName     = _compareResults.File1.Filename,
                Comments     = Comment1,
                ReviewStatus = ReviewStatus1
            });
            _commentsContainer.FileComments.Add(new FileComment
            {
                FileName     = _compareResults.File2.Filename,
                Comments     = Comment2,
                ReviewStatus = ReviewStatus2
            });
            _commentsPersist.Load(Arg.Is <PullRequestLocator>(x => x.Equals(_pullRequestLocator)))
            .Returns(Task.FromResult(_commentsContainer));

            _backgroundTaskRunner.WhenForAnyArgs(x => x.RunInBackground(null)).Do(args =>
            {
                var a = args[0] as Action;
                a.Invoke();
            });

            _commentsPersist.ClearReceivedCalls();
            _backgroundTaskRunner.ClearReceivedCalls();
        }