示例#1
0
        public void AtApplicableRazorBlock_FunctionsBlock_ReturnsTrue()
        {
            // Arrange
            var syntaxTree = GetSyntaxTree("@functions { }");

            // Act
            var result = BraceSmartIndenter.AtApplicableRazorBlock(13, syntaxTree);

            // Assert
            Assert.True(result);
        }
示例#2
0
        public void AtApplicableRazorBlock_ExplicitCodeBlock_ReturnsTrue()
        {
            // Arrange
            var syntaxTree = GetSyntaxTree("@{ }");

            // Act
            var result = BraceSmartIndenter.AtApplicableRazorBlock(3, syntaxTree);

            // Assert
            Assert.True(result);
        }
示例#3
0
        public void AtApplicableRazorBlock_NestedIfBlock_ReturnsFalse()
        {
            // Arrange
            var syntaxTree = GetSyntaxTree("@{ if (true) { } }");

            // Act
            var result = BraceSmartIndenter.AtApplicableRazorBlock(14, syntaxTree);

            // Assert
            Assert.False(result);
        }
示例#4
0
        public void AtApplicableRazorBlock_WhenNoOwner_ReturnsFalse()
        {
            // Arrange
            var syntaxTree     = RazorSyntaxTree.Parse(TestRazorSourceDocument.Create("@DateTime.Now"));
            var changePosition = 14; // 1 after the end of the content

            // Act
            var result = BraceSmartIndenter.AtApplicableRazorBlock(changePosition, syntaxTree);

            // Assert
            Assert.False(result);
        }
示例#5
0
        public void AtApplicableRazorBlock_AtExplicitCodeBlocksCode_ReturnsTrue()
        {
            // Arrange
            var syntaxTree     = RazorSyntaxTree.Parse(TestRazorSourceDocument.Create("@{}"));
            var changePosition = 2;

            // Act
            var result = BraceSmartIndenter.AtApplicableRazorBlock(changePosition, syntaxTree);

            // Assert
            Assert.True(result);
        }
示例#6
0
        public void AtApplicableRazorBlock_AtMarkup_ReturnsFalse()
        {
            // Arrange
            var syntaxTree     = RazorSyntaxTree.Parse(TestRazorSourceDocument.Create("<p></p>"));
            var changePosition = 2;

            // Act
            var result = BraceSmartIndenter.AtApplicableRazorBlock(changePosition, syntaxTree);

            // Assert
            Assert.False(result);
        }
示例#7
0
        public void AtApplicableRazorBlock_AtMetacode_ReturnsTrue()
        {
            // Arrange
            var parseOptions   = RazorParserOptions.Create(options => options.Directives.Add(FunctionsDirective.Directive));
            var syntaxTree     = RazorSyntaxTree.Parse(TestRazorSourceDocument.Create("@functions {}"), parseOptions);
            var changePosition = 12;

            // Act
            var result = BraceSmartIndenter.AtApplicableRazorBlock(changePosition, syntaxTree);

            // Assert
            Assert.True(result);
        }