public void ShouldNotRaiseTagsChangedOnLeftHandSideLinesChanged() { var file = CreateSessionFile(); var manager = CreateSessionManager(file); var target = new InlineCommentTagger( Substitute.For <IGitService>(), Substitute.For <IGitClient>(), Substitute.For <IDiffService>(), Substitute.For <ITextView>(), CreateBuffer(), manager); var span = CreateSpan(14); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); var raised = false; target.TagsChanged += (s, e) => raised = true; ((ISubject <IReadOnlyList <Tuple <int, DiffSide> > >)file.LinesChanged).OnNext(new[] { Tuple.Create(14, DiffSide.Left), }); Assert.False(raised); }
public void ShouldRaiseTagsChangedOnFileLinesChanged() { var file = CreateSessionFile(); var manager = CreateSessionManager(file, DiffSide.Right); var target = new InlineCommentTagger( Substitute.For <IGitService>(), Substitute.For <IGitClient>(), Substitute.For <IDiffService>(), Substitute.For <ITextView>(), CreateBuffer(), manager); var session = manager.GetTextBufferInfo(null).Session; var span = CreateSpan(14); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); var raised = false; target.TagsChanged += (s, e) => raised = e.Span.Start == 140; ((ISubject <IReadOnlyList <Tuple <int, DiffSide> > >)file.LinesChanged).OnNext(new[] { Tuple.Create(14, DiffSide.Right), }); Assert.True(raised); }
public void ShouldNotReturnAddNewCommentTagForDeletedLineOnRhs() { var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(DiffSide.Right)); // Line 13 has an delete diff entry. var span = CreateSpan(13); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.That(result, Is.Empty); }
public void ShouldReturnShowCommentTagForLhs() { var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(DiffSide.Left)); // Line 12 has an existing LHS comment. var span = CreateSpan(12); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.That(result, Has.One.Items); Assert.That(result[0].Tag, Is.InstanceOf <ShowInlineCommentTag>()); }
public void ShouldReturnAddNewCommentTagForAddedLine() { var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager()); // Line 11 has an add diff entry. var span = CreateSpan(11); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.Single(result); Assert.IsType <AddInlineCommentTag>(result[0].Tag); }
public void ShouldReturnAddCommentTagForLhs() { var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(DiffSide.Left)); // Line 13 has an delete diff entry. var span = CreateSpan(13); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.Single(result); Assert.IsType <AddInlineCommentTag>(result[0].Tag); }
public void ShouldReturnAddNewCommentTagForAddedLineOnRhs() { var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(DiffSide.Right)); // Line 11 has an add diff entry. var span = CreateSpan(11); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.That(result, Has.One.Items); Assert.That(result[0].Tag, Is.InstanceOf <AddInlineCommentTag>()); }
public void ShouldReturnShowCommentTagForRhs() { var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(DiffSide.Right)); // Line 10 has an existing RHS comment. var span = CreateSpan(10); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.Single(result); Assert.IsType <ShowInlineCommentTag>(result[0].Tag); }
public void ShouldReturnShowAnnotationTagForRhs() { var file = CreateSessionFile(withComments: false, withAnnotations: true); var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(file, DiffSide.Right)); // Line 10 has an existing Annotation comment. var span = CreateSpan(10); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.That(result, Has.One.Items); Assert.That(result[0].Tag, Is.InstanceOf <ShowInlineCommentTag>()); }
public void ShouldReturnAddCommentTagForLhs() { var file = CreateSessionFile(); var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(file, DiffSide.Left)); // Line 13 has an delete diff entry. var span = CreateSpan(13); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.That(result, Has.One.Items); Assert.That(result[0].Tag, Is.InstanceOf <AddInlineCommentTag>()); }
public void ShouldReturnAddNewCommentTagForAddedLineOnRhs() { var target = new InlineCommentTagger( Substitute.For <IGitService>(), Substitute.For <IGitClient>(), Substitute.For <IDiffService>(), Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(DiffSide.Right)); // Line 11 has an add diff entry. var span = CreateSpan(11); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.Equal(1, result.Count); Assert.IsType <AddInlineCommentTag>(result[0].Tag); }
public void ShouldReturnShowCommentTagForLhs() { var target = new InlineCommentTagger( Substitute.For <IGitService>(), Substitute.For <IGitClient>(), Substitute.For <IDiffService>(), Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(DiffSide.Left)); // Line 12 has an existing LHS comment. var span = CreateSpan(12); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.Equal(1, result.Count); Assert.IsType <ShowInlineCommentTag>(result[0].Tag); }
public void ShouldAlwaysCallSessionGetFileWithHeadCommitShaForLeftHandSide() { var sessionManager = CreateSessionManager( CreateSessionFile(), DiffSide.Left, "123"); var session = sessionManager.CurrentSession; var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), sessionManager); // Line 11 has an add diff entry. var span = CreateSpan(11); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); session.Received(1).GetFile("file.cs", "HEAD"); }
public void FirstPassShouldReturnEmptyTags() { var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager()); var result = target.GetTags(CreateSpan(10)); Assert.That(result, Is.Empty); }
public void ShouldReturnShowInlineTagForComment() { var file = CreateSessionFile(); var target = new InlineCommentTagger( Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager(file)); // Line 10 has an existing RHS comment. var span = CreateSpan(10); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); Assert.That(result, Has.One.Items); var showInlineTag = result[0].Tag as ShowInlineCommentTag; Assert.That(showInlineTag, Is.Not.Null); Assert.That(showInlineTag.Thread, Is.Not.Null); Assert.That(showInlineTag.Annotations, Is.Null); }
public void ShouldRaiseTagsChangedOnFileLinesChanged(bool inlineCommentMarginVisible, bool expectRaised) { var file = CreateSessionFile(); var manager = CreateSessionManager(file); var target = new InlineCommentTagger( CreateTextView(inlineCommentMarginVisible), CreateBuffer(), manager); var span = CreateSpan(14); var firstPass = target.GetTags(span); var result = target.GetTags(span).ToList(); var raised = false; target.TagsChanged += (s, e) => raised = e.Span.Start == 140; ((ISubject <IReadOnlyList <Tuple <int, DiffSide> > >)file.LinesChanged).OnNext(new[] { Tuple.Create(14, DiffSide.Right), }); Assert.That(raised, Is.EqualTo(expectRaised)); }
public void FirstPassShouldReturnEmptyTags() { var target = new InlineCommentTagger( Substitute.For <IGitService>(), Substitute.For <IGitClient>(), Substitute.For <IDiffService>(), Substitute.For <ITextView>(), Substitute.For <ITextBuffer>(), CreateSessionManager()); var result = target.GetTags(CreateSpan(10)); Assert.Empty(result); }