public void Should_Return_Comment_Source() { // Given var commentSource = "foo"; var thread = new GitPullRequestCommentThread { Id = 123, Status = CommentThreadStatus.Active, ThreadContext = new CommentThreadContext() { FilePath = "/foo.cs" }, Comments = new List <Comment>(), Properties = new PropertiesCollection() }; thread.SetCommentSource(commentSource); // When var result = thread.GetCommentSource(); // Then result.ShouldBe(commentSource); }
/// <summary> /// Converts a <see cref="GitPullRequestCommentThread"/> from TFS to a <see cref="IPullRequestDiscussionThread"/> as used in this addin. /// </summary> /// <param name="thread">TFS thread to convert.</param> /// <returns>Converted thread.</returns> public static IPullRequestDiscussionThread ToPullRequestDiscussionThread(this GitPullRequestCommentThread thread) { thread.NotNull(nameof(thread)); if (thread.Comments == null) { throw new InvalidOperationException("Comments list is not created."); } FilePath filePath = null; if (thread.ThreadContext != null && thread.ThreadContext.FilePath != null) { filePath = thread.ThreadContext.FilePath.TrimStart('/'); } return(new PullRequestDiscussionThread( thread.Id, thread.Status.ToPullRequestDiscussionStatus(), filePath, thread.Comments.Select(x => x.ToPullRequestDiscussionComment())) { CommentSource = thread.GetCommentSource(), Resolution = thread.Status.ToPullRequestDiscussionResolution() }); }
public void Should_Throw_If_Thread_Is_Null() { // Given GitPullRequestCommentThread thread = null; // When var result = Record.Exception(() => thread.GetCommentSource()); // Then result.IsArgumentNullException("thread"); }
/// <summary> /// Converts a <see cref="GitPullRequestCommentThread"/> from TFS to a <see cref="IPrcaDiscussionThread"/> as used in this addin. /// </summary> /// <param name="thread">TFS thread to convert.</param> /// <returns>Converted thread.</returns> public static IPrcaDiscussionThread ToPrcaDiscussionThread(this GitPullRequestCommentThread thread) { thread.NotNull(nameof(thread)); return(new PrcaDiscussionThread( thread.Id, thread.Status.ToPrcaDiscussionStatus(), new FilePath(thread.ThreadContext.FilePath.TrimStart('/')), thread.Comments.Select(x => x.ToPrcaDiscussionComment())) { CommentSource = thread.GetCommentSource(), }); }
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 }; // When var result = Record.Exception(() => thread.GetCommentSource()); // Then result.IsInvalidOperationException("Properties collection is not created."); }
/// <summary> /// Checks if the custom comment source value used to decorate comments created by this addin /// has a specific value. /// </summary> /// <param name="thread">Thread to check.</param> /// <param name="value">Value to check for.</param> /// <returns><c>True</c> if the value is identical, <c>False</c> otherwise.</returns> public static bool IsCommentSource(this GitPullRequestCommentThread thread, string value) { thread.NotNull(nameof(thread)); return(thread.GetCommentSource() == value); }