protected async Task TestBraceHighlightingAsync(string markup, ParseOptions options = null)
        {
            using (var workspace = CreateWorkspace(markup, options))
            {
                WpfTestCase.RequireWpfFact($"{nameof(AbstractBraceHighlightingTests)}.{nameof(TestBraceHighlightingAsync)} creates asynchronous taggers");

                var provider = new BraceHighlightingViewTaggerProvider(
                    GetBraceMatchingService(workspace),
                    workspace.GetService <IForegroundNotificationService>(),
                    AggregateAsynchronousOperationListener.EmptyListeners);

                var testDocument = workspace.Documents.First();
                var buffer       = testDocument.TextBuffer;
                var document     = buffer.CurrentSnapshot.GetRelatedDocumentsWithChanges().FirstOrDefault();
                var context      = new TaggerContext <BraceHighlightTag>(
                    document, buffer.CurrentSnapshot,
                    new SnapshotPoint(buffer.CurrentSnapshot, testDocument.CursorPosition.Value));
                await provider.ProduceTagsAsync_ForTestingPurposesOnly(context);

                var expectedHighlights = testDocument.SelectedSpans.Select(ts => ts.ToSpan()).OrderBy(s => s.Start).ToList();
                var actualHighlights   = context.tagSpans.Select(ts => ts.Span.Span).OrderBy(s => s.Start).ToList();

                Assert.Equal(expectedHighlights, actualHighlights);
            }
        }
        protected async Task TestBraceHighlightingAsync(string markup)
        {
            using (var workspace = await CreateWorkspaceAsync(markup))
            {
                WpfTestCase.RequireWpfFact($"{nameof(AbstractBraceHighlightingTests)}.{nameof(TestBraceHighlightingAsync)} creates asynchronous taggers");

                var provider = new BraceHighlightingViewTaggerProvider(
                    workspace.GetService<IBraceMatchingService>(),
                    workspace.GetService<IForegroundNotificationService>(),
                    AggregateAsynchronousOperationListener.EmptyListeners);

                var testDocument = workspace.Documents.First();
                var buffer = testDocument.TextBuffer;
                var document = buffer.CurrentSnapshot.GetRelatedDocumentsWithChanges().FirstOrDefault();
                var context = new TaggerContext<BraceHighlightTag>(
                    document, buffer.CurrentSnapshot,
                    new SnapshotPoint(buffer.CurrentSnapshot, testDocument.CursorPosition.Value));
                await provider.ProduceTagsAsync_ForTestingPurposesOnly(context);

                var expectedHighlights = testDocument.SelectedSpans.Select(ts => ts.ToSpan()).OrderBy(s => s.Start).ToList();
                var actualHighlights = context.tagSpans.Select(ts => ts.Span.Span).OrderBy(s => s.Start).ToList();

                Assert.Equal(expectedHighlights, actualHighlights);
            }
        }
        protected async Task TestBraceHighlightingAsync(
            string markup,
            ParseOptions options        = null,
            bool swapAnglesWithBrackets = false
            )
        {
            MarkupTestFile.GetPositionAndSpans(
                markup,
                out var text,
                out int cursorPosition,
                out var expectedSpans
                );

            // needed because markup test file can't support [|[|] to indicate selecting
            // just an open bracket.
            if (swapAnglesWithBrackets)
            {
                text = text.Replace("<", "[").Replace(">", "]");
            }

            using (var workspace = CreateWorkspace(text, options))
            {
                WpfTestRunner.RequireWpfFact(
                    $"{nameof(AbstractBraceHighlightingTests)}.{nameof(TestBraceHighlightingAsync)} creates asynchronous taggers"
                    );

                var provider = new BraceHighlightingViewTaggerProvider(
                    workspace.GetService <IThreadingContext>(),
                    GetBraceMatchingService(workspace),
                    workspace.GetService <IForegroundNotificationService>(),
                    AsynchronousOperationListenerProvider.NullProvider
                    );

                var testDocument = workspace.Documents.First();
                var buffer       = testDocument.GetTextBuffer();
                var document     = buffer.CurrentSnapshot
                                   .GetRelatedDocumentsWithChanges()
                                   .FirstOrDefault();
                var context = new TaggerContext <BraceHighlightTag>(
                    document,
                    buffer.CurrentSnapshot,
                    new SnapshotPoint(buffer.CurrentSnapshot, cursorPosition)
                    );
                await provider.GetTestAccessor().ProduceTagsAsync(context);

                var expectedHighlights = expectedSpans
                                         .Select(ts => ts.ToSpan())
                                         .OrderBy(s => s.Start)
                                         .ToList();
                var actualHighlights = context.tagSpans
                                       .Select(ts => ts.Span.Span)
                                       .OrderBy(s => s.Start)
                                       .ToList();

                Assert.Equal(expectedHighlights, actualHighlights);
            }
        }
Пример #4
0
        private static async Task <IEnumerable <ITagSpan <BraceHighlightTag> > > ProduceTagsAsync(
            TestWorkspace workspace,
            ITextBuffer buffer,
            int position)
        {
            var producer = new BraceHighlightingViewTaggerProvider(
                workspace.ExportProvider.GetExportedValue <IThreadingContext>(),
                workspace.GetService <IBraceMatchingService>(),
                AsynchronousOperationListenerProvider.NullProvider);

            var context = new TaggerContext <BraceHighlightTag>(
                buffer.CurrentSnapshot.GetRelatedDocumentsWithChanges().FirstOrDefault(),
                buffer.CurrentSnapshot, new SnapshotPoint(buffer.CurrentSnapshot, position));
            await producer.GetTestAccessor().ProduceTagsAsync(context);

            return(context.tagSpans);
        }
Пример #5
0
        private async Task <IEnumerable <ITagSpan <BraceHighlightTag> > > ProduceTagsAsync(
            TestWorkspace workspace,
            ITextBuffer buffer,
            int position)
        {
            var view     = new Mock <ITextView>();
            var producer = new BraceHighlightingViewTaggerProvider(
                workspace.GetService <IBraceMatchingService>(),
                workspace.GetService <IForegroundNotificationService>(),
                AggregateAsynchronousOperationListener.EmptyListeners);

            var context = new TaggerContext <BraceHighlightTag>(
                buffer.CurrentSnapshot.GetRelatedDocumentsWithChanges().FirstOrDefault(),
                buffer.CurrentSnapshot, new SnapshotPoint(buffer.CurrentSnapshot, position));
            await producer.ProduceTagsAsync_ForTestingPurposesOnly(context);

            return(context.tagSpans);
        }
Пример #6
0
        protected void TestBraceHighlighting(string markup)
        {
            using (var workspace = CreateWorkspace(markup))
            {
                var provider = new BraceHighlightingViewTaggerProvider(
                    workspace.GetService <IBraceMatchingService>(),
                    workspace.GetService <IForegroundNotificationService>(),
                    AggregateAsynchronousOperationListener.EmptyListeners);

                var testDocument = workspace.Documents.First();
                var buffer       = testDocument.TextBuffer;
                var document     = buffer.CurrentSnapshot.GetRelatedDocumentsWithChanges().FirstOrDefault();
                var context      = new TaggerContext <BraceHighlightTag>(
                    document, buffer.CurrentSnapshot,
                    new SnapshotPoint(buffer.CurrentSnapshot, testDocument.CursorPosition.Value));
                provider.ProduceTagsAsync_ForTestingPurposesOnly(context).Wait();

                var expectedHighlights = testDocument.SelectedSpans.Select(ts => ts.ToSpan()).OrderBy(s => s.Start).ToList();
                var actualHighlights   = context.tagSpans.Select(ts => ts.Span.Span).OrderBy(s => s.Start).ToList();

                Assert.Equal(expectedHighlights, actualHighlights);
            }
        }