public static void UpdateTagSpansRaisesTagsChangedEventOnlyOnce() { var buffer = new FakeTextBuffer(string.Empty); var tagger = new TestableTemplateTagger(buffer); tagger.CreateTagSpansMethod = analysis => { tagger.CreateTagSpan(analysis.TextSnapshot.CreateTrackingSpan(new Span(), SpanTrackingMode.EdgeNegative), new ErrorTag()); tagger.CreateTagSpan(analysis.TextSnapshot.CreateTrackingSpan(new Span(), SpanTrackingMode.EdgeNegative), new ErrorTag()); }; int tagsChangedEventCount = 0; tagger.TagsChanged += (sender, args) => tagsChangedEventCount++; tagger.UpdateTagSpans(new TemplateAnalysis(new FakeTextSnapshot(string.Empty), null, null)); Assert.Equal(1, tagsChangedEventCount); }
public static void UpdateTagSpansRemovesOldSpans() { var buffer = new FakeTextBuffer(string.Empty); var tagger = new TestableTemplateTagger(buffer); tagger.CreateTagSpan(buffer.CurrentSnapshot.CreateTrackingSpan(new Span(), SpanTrackingMode.EdgeNegative), new ErrorTag()); tagger.UpdateTagSpans(new TemplateAnalysis(null, null, null)); Assert.Equal(0, tagger.GetTags(new NormalizedSnapshotSpanCollection(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length))).Count()); }
public static void TemplateChangeRemovesOldTagSpans() { var buffer = new FakeTextBuffer(string.Empty); var tagger = new TestableTemplateTagger(buffer); tagger.CreateTagSpan(buffer.CurrentSnapshot.CreateTrackingSpan(new Span(), SpanTrackingMode.EdgeNegative), new ErrorTag()); buffer.CurrentSnapshot = new FakeTextSnapshot(string.Empty); Assert.False(tagger.GetTaggedSpans(new SnapshotSpan(buffer.CurrentSnapshot, 0, buffer.CurrentSnapshot.Length)).Any()); }
public static void TemplateChangeRaisesTagsChangedEvent() { var buffer = new FakeTextBuffer(string.Empty); var tagger = new TestableTemplateTagger(buffer); tagger.CreateTagSpan(buffer.CurrentSnapshot.CreateTrackingSpan(new Span(), SpanTrackingMode.EdgeNegative), new ErrorTag()); bool tagsChangedEventRaised = false; tagger.TagsChanged += (sender, args) => tagsChangedEventRaised = true; buffer.CurrentSnapshot = new FakeTextSnapshot(string.Empty); Assert.True(tagsChangedEventRaised); }