Exemplo n.º 1
0
        public void TagHelperPrefixDirective_DuplicatesCauseError()
        {
            // Arrange
            var expectedDiagnostic = RazorDiagnosticFactory.CreateParsing_DuplicateDirective(
                new SourceSpan(null, 22 + Environment.NewLine.Length, 1, 0, 16), "tagHelperPrefix");
            var source = TestRazorSourceDocument.Create(
                @"@tagHelperPrefix ""th:""
@tagHelperPrefix ""th""",
                filePath: null);

            // Act
            var document = RazorSyntaxTree.Parse(source);

            // Assert
            var erroredNode    = document.Root.DescendantNodes().Last(n => n.GetSpanContext()?.ChunkGenerator is TagHelperPrefixDirectiveChunkGenerator);
            var chunkGenerator = Assert.IsType <TagHelperPrefixDirectiveChunkGenerator>(erroredNode.GetSpanContext().ChunkGenerator);
            var diagnostic     = Assert.Single(chunkGenerator.Diagnostics);

            Assert.Equal(expectedDiagnostic, diagnostic);
        }