コード例 #1
0
        public void ToStringOnNamedGroupNodeWithUseQuotesTrueShouldReturnNamedGroupWithNameBetweenSingleQuotes()
        {
            // Arrange
            var target = new NamedGroupNode("name", true);

            // Act
            var result = target.ToString();

            // Assert
            result.ShouldBe("(?'name')");
        }
コード例 #2
0
        public void ToStringOnNamedGroupNodeWithUseQuotesFalseShouldReturnNamedGroupWithNameBetweenBrackets()
        {
            // Arrange
            var target = new NamedGroupNode("name", false);

            // Act
            var result = target.ToString();

            // Assert
            result.ShouldBe("(?<name>)");
        }
コード例 #3
0
        public void ToStringOnNamedGroupNodeWithChildNodeShouldReturnNamedGroupWithChildNode()
        {
            // Arrange
            var childNode = new CharacterNode('a');
            var target    = new NamedGroupNode("name", false, childNode);

            // Act
            var result = target.ToString();

            // Assert
            result.ShouldBe("(?<name>a)");
        }
コード例 #4
0
        public void ToStringOnNamedGroupNodeWithMultipleChildNodesShouldReturnNamedGroupWithChildNodes()
        {
            // Arrange
            var childNodes = new List <RegexNode> {
                new CharacterNode('a'), new CharacterNode('b'), new CharacterNode('c')
            };
            var target = new NamedGroupNode("name", false, childNodes);

            // Act
            var result = target.ToString();

            // Assert
            result.ShouldBe("(?<name>abc)");
        }
コード例 #5
0
        public void ToStringOnNamedGroupNodeWithprefixShouldReturnPrefixBeforeNamedGroupNode()
        {
            // Arrange
            var comment = new CommentGroupNode("This is a comment.");
            var target  = new NamedGroupNode("name", false)
            {
                Prefix = comment
            };

            // Act
            var result = target.ToString();

            // Assert
            result.ShouldBe("(?#This is a comment.)(?<name>)");
        }