public void Should_Return_Message() { // Given var message = "foo"; var thread = new GitPullRequestCommentThread { Id = 123, Status = CommentThreadStatus.Active, ThreadContext = new CommentThreadContext() { FilePath = "/foo.cs" }, Comments = new List <Comment>(), Properties = new PropertiesCollection() }; thread.SetIssueMessage(message); // When var result = thread.GetIssueMessage(); // Then result.ShouldBe(message); }
public void Should_Throw_If_Thread_Is_Null() { // Given GitPullRequestCommentThread thread = null; var value = "foo"; // When var result = Record.Exception(() => thread.SetIssueMessage(value)); // Then result.IsArgumentNullException("thread"); }
private bool AddThreadProperties( GitPullRequestCommentThread thread, GitPullRequestIterationChanges changes, IIssue issue, int iterationId, string commentSource) { thread.NotNull(nameof(thread)); changes.NotNull(nameof(changes)); issue.NotNull(nameof(issue)); var properties = new PropertiesCollection(); if (issue.AffectedFileRelativePath != null) { if (this.tfsPullRequest.CodeReviewId > 0) { var changeTrackingId = this.TryGetCodeFlowChangeTrackingId(changes, issue.AffectedFileRelativePath); if (changeTrackingId < 0) { // Don't post comment if we couldn't determine the change. return(false); } AddCodeFlowProperties(issue, iterationId, changeTrackingId, properties); } else { throw new NotSupportedException("Legacy code reviews are not supported."); } } // A VSTS UI extension will recognize this and format the comments differently. properties.Add("CodeAnalysisThreadType", "CodeAnalysisIssue"); thread.Properties = properties; // Add a custom property to be able to distinguish all comments created this way. thread.SetCommentSource(commentSource); // Add a custom property to be able to return issue message from existing threads, // without any formatting done by this addin, back to Cake.Issues.PullRequests. thread.SetIssueMessage(issue.Message); return(true); }
public void Should_Throw_If_Properties_Are_Null() { // Given var thread = new GitPullRequestCommentThread { Id = 123, Status = CommentThreadStatus.Active, ThreadContext = new CommentThreadContext { FilePath = "/foo.cs" }, Comments = new List <Comment>(), Properties = null }; var value = "foo"; // When var result = Record.Exception(() => thread.SetIssueMessage(value)); // Then result.IsInvalidOperationException("Properties collection is not created."); }