示例#1
0
        public async Task CanCreatePendingReview()
        {
            using (var context = await _github.CreateRepositoryContext("test-repo"))
            {
                await _github.CreateTheWorld(context.Repository);

                var pullRequest = await _github2.CreatePullRequest(context.Repository);

                var body = "A review comment message";

                var review = new PullRequestReviewCreate()
                {
                    CommitId = pullRequest.Head.Sha,
                    Body     = body,
                    Comments = new List <DraftPullRequestReviewComment>
                    {
                        new DraftPullRequestReviewComment("comment 1", "README.md", 1),
                        new DraftPullRequestReviewComment("comment 2", "README.md", 2)
                    }
                };

                var createdReview = await _client.Create(context.RepositoryOwner, context.RepositoryName, pullRequest.Number, review);

                Assert.NotNull(createdReview);
                Assert.Equal(body, createdReview.Body);
                Assert.Equal(PullRequestReviewState.Pending, createdReview.State);
                Assert.Equal(pullRequest.Head.Sha, createdReview.CommitId);
            }
        }
示例#2
0
        public async Task CanDismissReview()
        {
            using (var context = await _github.CreateRepositoryContext("test-repo"))
            {
                await _github.CreateTheWorld(context.Repository);

                var pullRequest = await _github2.CreatePullRequest(context.Repository);

                var createdReview = await _github.CreatePullRequestReview(context.Repository, pullRequest.Number, "A pending review", PullRequestReviewEvent.RequestChanges);

                var dismissedReview = await _client.Dismiss(context.RepositoryOwner, context.RepositoryName, pullRequest.Number, createdReview.Id, new PullRequestReviewDismiss { Message = "No soup for you!" });

                Assert.Equal(PullRequestReviewState.Dismissed, dismissedReview.State);
            }
        }
示例#3
0
        public async Task CanDeleteReview()
        {
            using (var context = await _github.CreateRepositoryContext("test-repo"))
            {
                await _github.CreateTheWorld(context.Repository);

                var pullRequest = await _github2.CreatePullRequest(context.Repository);

                var createdReview = await _github.CreatePullRequestReview(context.Repository, pullRequest.Number, "A pending review");

                await _client.Delete(context.RepositoryOwner, context.RepositoryName, pullRequest.Number, createdReview.Id);

                var retrievedReviews = await _client.GetAll(context.RepositoryOwner, context.RepositoryName, pullRequest.Number);

                Assert.False(retrievedReviews.Any(x => x.Id == createdReview.Id));
            }
        }
示例#4
0
        public async Task CreatesPullRequestCard()
        {
            await _github.CreateTheWorld(_context.Repository);

            var project = await CreateRepositoryProjectHelper(_github, _context.RepositoryId);

            var pullRequest = await _github.CreatePullRequest(_context.Repository);

            var column = await CreateColumnHelper(_github, project.Id);

            var card = await CreatePullRequestCardHelper(_github, pullRequest.Id, column.Id);

            Assert.NotNull(card);
        }
示例#5
0
        public async Task CanSubmitCommentedReview()
        {
            using (var context = await _github.CreateRepositoryContext("test-repo"))
            {
                await _github.CreateTheWorld(context.Repository);

                var pullRequest = await _github2.CreatePullRequest(context.Repository);

                var createdReview = await _github.CreatePullRequestReview(context.Repository, pullRequest.Number, "A pending review");

                var submitMessage = new PullRequestReviewSubmit
                {
                    Body  = "Roger roger!",
                    Event = PullRequestReviewEvent.Comment
                };
                var submittedReview = await _client.Submit(context.RepositoryOwner, context.RepositoryName, pullRequest.Number, createdReview.Id, submitMessage);

                Assert.Equal("Roger roger!", submittedReview.Body);
                Assert.Equal(PullRequestReviewState.Commented, submittedReview.State);
            }
        }