/// <summary>
        /// Sets the pull request comment thread status.
        /// </summary>
        /// <param name="threadId">The Id of the comment thread.</param>
        /// <param name="status">The comment thread status.</param>
        private void SetCommentThreadStatus(int threadId, CommentThreadStatus status)
        {
            if (!this.ValidatePullRequest())
            {
                return;
            }

            using (var gitClient = this.gitClientFactory.CreateGitClient(this.CollectionUrl, this.credentials))
            {
                var newThread = new GitPullRequestCommentThread
                {
                    Status = status,
                };

                gitClient
                .UpdateThreadAsync(
                    newThread,
                    this.RepositoryId,
                    this.PullRequestId,
                    threadId)
                .ConfigureAwait(false)
                .GetAwaiter()
                .GetResult();
            }
        }
예제 #2
0
            public void Should_Set_Correct_Resolution(
                CommentThreadStatus status,
                PullRequestDiscussionResolution expectedResult)
            {
                // Given
                var id       = 123;
                var filePath = "/foo.cs";
                var thread   =
                    new GitPullRequestCommentThread
                {
                    Id            = id,
                    Status        = status,
                    ThreadContext = new CommentThreadContext()
                    {
                        FilePath = filePath
                    },
                    Comments   = new List <Comment>(),
                    Properties = new PropertiesCollection()
                };

                // When
                var result = thread.ToPullRequestDiscussionThread();

                // Then
                result.Resolution.ShouldBe(expectedResult);
            }
예제 #3
0
            public void Should_Return_Correct_Value(
                CommentThreadStatus status,
                PullRequestDiscussionResolution expectedResult)
            {
                // Given

                // When
                var result = status.ToPullRequestDiscussionResolution();

                // Then
                result.ShouldBe(expectedResult);
            }
예제 #4
0
        /// <summary>
        /// Converts a <see cref="CommentThreadStatus"/> from TFS to a <see cref="PullRequestDiscussionStatus"/> as used in this addin.
        /// </summary>
        /// <param name="status">TFS status to convert.</param>
        /// <returns>Converted status.</returns>
        public static PullRequestDiscussionStatus ToPullRequestDiscussionStatus(this CommentThreadStatus status)
        {
            switch (status)
            {
            case CommentThreadStatus.Unknown:
                return(PullRequestDiscussionStatus.Unknown);

            case CommentThreadStatus.Active:
            case CommentThreadStatus.Pending:
                return(PullRequestDiscussionStatus.Active);

            case CommentThreadStatus.Fixed:
            case CommentThreadStatus.WontFix:
            case CommentThreadStatus.Closed:
            case CommentThreadStatus.ByDesign:
                return(PullRequestDiscussionStatus.Resolved);

            default:
                throw new PullRequestIssuesException("Unknown enumeration value");
            }
        }
예제 #5
0
        /// <summary>
        /// Sets the pull request comment thread status.
        /// </summary>
        /// <param name="threadId">The Id of the comment thread.</param>
        /// <param name="status">The comment thread status.</param>
        private void SetCommentThreadStatus(int threadId, CommentThreadStatus status)
        {
            if (!this.ValidatePullRequest())
            {
                return;
            }

            using (var gitClient = this.gitClientFactory.CreateGitClient(this.CollectionUrl, this.credentials))
            {
                var newThread = new GitPullRequestCommentThread
                {
                    Status = status,
                };

                gitClient.UpdateThreadAsync(
                    newThread,
                    this.RepositoryId,
                    this.PullRequestId,
                    threadId,
                    null,
                    CancellationToken.None).Wait();
            }
        }
예제 #6
0
        /// <summary>
        /// Start new comment thread
        /// </summary>
        /// <param name="TeamProjectName"></param>
        /// <param name="RepoName"></param>
        /// <param name="PrId"></param>
        /// <param name="Title"></param>
        /// <param name="Status"></param>
        static void CreateNewCommentThread(string TeamProjectName, string RepoName, int PrId, string Title, CommentThreadStatus Status = CommentThreadStatus.Active)
        {
            GitPullRequest pr = GitClient.GetPullRequestAsync(TeamProjectName, RepoName, PrId).Result;

            GitPullRequestCommentThread gitThread = new GitPullRequestCommentThread();

            gitThread.Status = Status;
            List <Microsoft.TeamFoundation.SourceControl.WebApi.Comment> comments = new List <Microsoft.TeamFoundation.SourceControl.WebApi.Comment>();

            comments.Add(new Microsoft.TeamFoundation.SourceControl.WebApi.Comment
            {
                Content = Title
            });
            gitThread.Comments = comments;

            var thread = GitClient.CreateThreadAsync(gitThread, TeamProjectName, RepoName, PrId).Result;
        }