Exemple #1
0
        private static void RunTestCase(string markdown, Tuple <string, string[]>[] expectedOutlines)
        {
            markdown = newline.Replace(markdown, "\r\n");
            var snapshot = new MockSnapshot(markdown.Replace("{[", "").Replace("]}", ""));

            var expected  = new List <TagSpan <IOutliningRegionTag> >();
            var lastIndex = 0;

            for (int i = 0; i < expectedOutlines.Length; i++)
            {
                var spanStart = markdown.IndexOf("{[", lastIndex);
                if (spanStart < 0)
                {
                    throw new ArgumentException("Not enough test delimiters");
                }

                markdown = markdown.Remove(spanStart, 2);
                var spanEnd = markdown.IndexOf("]}", spanStart);
                markdown = markdown.Remove(spanEnd, 2);
                expected.Add(new TagSpan <IOutliningRegionTag>(
                                 new SnapshotSpan(snapshot, Span.FromBounds(spanStart, spanEnd)),
                                 new SimpleOutlineTag(expectedOutlines[i])
                                 ));
                lastIndex = spanEnd;
            }
            if (markdown != snapshot.GetText())
            {
                throw new ArgumentException("Unexpected test delimiters");
            }

            var artifacts = new ArtifactCollection(new MarkdownCodeArtifactProcessor());

            artifacts.Build(markdown);

            var tagger = new MarkdownOutlineTagger(artifacts, (c, t) => new SimpleOutlineTag(c, t));
            var actual = tagger.GetTags(new NormalizedSnapshotSpanCollection(new SnapshotSpan(
                                                                                 snapshot,
                                                                                 new Span(0, markdown.Length)
                                                                                 )));

            actual
            .Select(ts => new { ts.Span.Span, ts.Tag })
            .ShouldAllBeEquivalentTo(expected.Select(ts => new { ts.Span.Span, ts.Tag }));
        }
        private static void RunTestCase(string markdown, Tuple<string, string[]>[] expectedOutlines)
        {
            markdown = newline.Replace(markdown, "\r\n");
            var snapshot = new MockSnapshot(markdown.Replace("{[", "").Replace("]}", ""));

            var expected = new List<TagSpan<IOutliningRegionTag>>();
            var lastIndex = 0;
            for (int i = 0; i < expectedOutlines.Length; i++)
            {
                var spanStart = markdown.IndexOf("{[", lastIndex);
                if (spanStart < 0)
                    throw new ArgumentException("Not enough test delimiters");

                markdown = markdown.Remove(spanStart, 2);
                var spanEnd = markdown.IndexOf("]}", spanStart);
                markdown = markdown.Remove(spanEnd, 2);
                expected.Add(new TagSpan<IOutliningRegionTag>(
                    new SnapshotSpan(snapshot, Span.FromBounds(spanStart, spanEnd)),
                    new SimpleOutlineTag(expectedOutlines[i])
                ));
                lastIndex = spanEnd;
            }
            if (markdown != snapshot.GetText())
                throw new ArgumentException("Unexpected test delimiters");

            var artifacts = new ArtifactCollection(new MarkdownCodeArtifactProcessor());
            artifacts.Build(markdown);

            var tagger = new MarkdownOutlineTagger(artifacts, (c, t) => new SimpleOutlineTag(c, t));
            var actual = tagger.GetTags(new NormalizedSnapshotSpanCollection(new SnapshotSpan(
                snapshot,
                new Span(0, markdown.Length)
            )));

            actual
                .Select(ts => new { ts.Span.Span, ts.Tag })
                .ShouldAllBeEquivalentTo(expected.Select(ts => new { ts.Span.Span, ts.Tag }));
        }