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); }
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); }
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); }
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); }