Example #1
0
        public void GetDesiredIndentation_ReturnsCorrectIndentation_ForMarkupWithinCodeBlock()
        {
            // Arrange
            var source     = $@"@{{
    <div>
";
            var syntaxTree = GetSyntaxTree(source);
            var service    = new DefaultRazorIndentationFactsService();

            // Act
            var indentation = service.GetDesiredIndentation(
                syntaxTree,
                previousLineEndIndex: GetLineEndIndexForLine(source, 1),
                getLineContent: line => GetLineContent(source, line),
                indentSize: 4,
                tabSize: 4);

            // Assert
            Assert.Equal(4, indentation);
        }
Example #2
0
        public void GetDesiredIndentation_ReturnsNull_IfOwningSpanIsCode()
        {
            // Arrange
            var source     = $@"
@{{
";
            var syntaxTree = GetSyntaxTree(source);
            var service    = new DefaultRazorIndentationFactsService();

            // Act
            var indentation = service.GetDesiredIndentation(
                syntaxTree,
                previousLineEndIndex: GetLineEndIndexForLine(source, 1),
                getLineContent: line => GetLineContent(source, line),
                indentSize: 4,
                tabSize: 1);

            // Assert
            Assert.Null(indentation);
        }
Example #3
0
        public void GetDesiredIndentation_ReturnsNull_IfOwningSpanIsNone()
        {
            // Arrange
            var customDirective = DirectiveDescriptor.CreateSingleLineDirective("custom");
            var source          = $@"
@custom
";
            var syntaxTree      = GetSyntaxTree(source, new[] { customDirective });
            var service         = new DefaultRazorIndentationFactsService();

            // Act
            var indentation = service.GetDesiredIndentation(
                syntaxTree,
                previousLineEndIndex: GetLineEndIndexForLine(source, 1),
                getLineContent: line => GetLineContent(source, line),
                indentSize: 4,
                tabSize: 1);

            // Assert
            Assert.Null(indentation);
        }
Example #4
0
        public void GetDesiredIndentation_ReturnsCorrectIndentation_ForMarkupWithinDirectiveBlock()
        {
            // Arrange
            var customDirective = DirectiveDescriptor.CreateRazorBlockDirective("custom");
            var source          = $@"@custom
{{
    <div>
}}";
            var syntaxTree      = GetSyntaxTree(source, new[] { customDirective });
            var service         = new DefaultRazorIndentationFactsService();

            // Act
            var indentation = service.GetDesiredIndentation(
                syntaxTree,
                previousLineEndIndex: GetLineEndIndexForLine(source, 2),
                getLineContent: line => GetLineContent(source, line),
                indentSize: 4,
                tabSize: 4);

            // Assert
            Assert.Equal(4, indentation);
        }