Example #1
0
        public void GetClassifiedSpans_ReturnsAttributeSpansInDocumentOrder()
        {
            // Arrange
            var expectedSpans = new[]
            {
                new ClassifiedSpan(new SourceSpan("test.cshtml", 14, 0, 14, 1), new SourceSpan("test.cshtml", 0, 0, 0, 49), SpanKind.Code, BlockKind.Tag, AcceptedCharacters.AnyExceptNewline),
                new ClassifiedSpan(new SourceSpan("test.cshtml", 23, 0, 23, 2), new SourceSpan("test.cshtml", 0, 0, 0, 49), SpanKind.Markup, BlockKind.Tag, AcceptedCharacters.Any),
                new ClassifiedSpan(new SourceSpan("test.cshtml", 32, 0, 32, 4), new SourceSpan("test.cshtml", 0, 0, 0, 49), SpanKind.Code, BlockKind.Tag, AcceptedCharacters.AnyExceptNewline),
            };
            var codeDocument = GetCodeDocument(
                @"<taghelper id=1 class=""th"" show=true></taghelper>");
            var syntaxTree = codeDocument.GetSyntaxTree();
            var service    = new DefaultRazorSyntaxFactsService();

            // Act
            var spans = service.GetClassifiedSpans(syntaxTree);

            // Assert
            Assert.Equal(expectedSpans, spans);
        }
Example #2
0
        public void GetClassifiedSpans_ReturnsExpectedSpans()
        {
            // Arrange
            var expectedSpans = new[]
            {
                new ClassifiedSpan(new SourceSpan("test.cshtml", 0, 0, 0, 5), new SourceSpan("test.cshtml", 0, 0, 0, 5), SpanKind.Markup, BlockKind.Tag, AcceptedCharacters.Any),
                new ClassifiedSpan(new SourceSpan("test.cshtml", 5, 0, 5, 6), new SourceSpan("test.cshtml", 0, 0, 0, 42), SpanKind.Markup, BlockKind.Markup, AcceptedCharacters.Any),
                new ClassifiedSpan(new SourceSpan("test.cshtml", 34, 1, 27, 2), new SourceSpan("test.cshtml", 0, 0, 0, 42), SpanKind.Markup, BlockKind.Markup, AcceptedCharacters.Any),
                new ClassifiedSpan(new SourceSpan("test.cshtml", 36, 2, 0, 6), new SourceSpan("test.cshtml", 36, 2, 0, 6), SpanKind.Markup, BlockKind.Tag, AcceptedCharacters.Any),
            };
            var codeDocument = GetCodeDocument(
                @"<div>
    <taghelper></taghelper>
</div>");
            var syntaxTree = codeDocument.GetSyntaxTree();
            var service    = new DefaultRazorSyntaxFactsService();

            // Act
            var spans = service.GetClassifiedSpans(syntaxTree);

            // Assert
            Assert.Equal(expectedSpans, spans);
        }