public void SpanOnCommentGroupShouldStartAfter()
        {
            // Arrange
            var comment = new CommentGroupNode("This is a comment.");
            var a       = new CharacterNode('a');
            var b       = new CharacterNode('b')
            {
                Prefix = comment
            };
            var concat = new ConcatenationNode(new List <RegexNode> {
                a, b
            });

            // Act
            var(commentStart, commentLength) = comment.GetSpan();
            var(aStart, aLength)             = a.GetSpan();
            var(bStart, bLength)             = b.GetSpan();
            var(concatStart, concatLength)   = concat.GetSpan();

            // Assert
            concatStart.ShouldBe(0);
            concatLength.ShouldBe(a.ToString().Length + b.ToString().Length);
            aStart.ShouldBe(0);
            aLength.ShouldBe(1);
            commentStart.ShouldBe(1);
            commentLength.ShouldBe(comment.ToString().Length);
            bStart.ShouldBe(commentStart + commentLength);
            bLength.ShouldBe(1);
        }
        public void SpanLengthOfEmptyConcatenationNodeShouldBeEqualToToStringLength()
        {
            // Arrange
            var target = new ConcatenationNode();

            // Act
            var(_, Length) = target.GetSpan();

            // Assert
            Length.ShouldBe(target.ToString().Length);
        }
        public void SpanLengthOConcatenationNodeWithChildNodesShouldBeEqualToToStringLength()
        {
            // Arrange
            var childNodes = new List <RegexNode> {
                new CharacterNode('a'), new CharacterNode('b'), new CharacterNode('c')
            };
            var target = new ConcatenationNode(childNodes);

            // Act
            var(_, Length) = target.GetSpan();

            // Assert
            Length.ShouldBe(target.ToString().Length);
        }
        public void SpanLengthOfConcatenationNodeShouldIncludeChildNodesPrefix()
        {
            // Arrange
            var childNode = new CharacterNode('a')
            {
                Prefix = new CommentGroupNode("Comment")
            };
            var target = new ConcatenationNode(childNode);

            // Act
            var(_, Length) = target.GetSpan();

            // Assert
            Length.ShouldBe(target.ToString().Length);
        }
        public void SpanLengthOfConcatenationNodeShouldNotIncludeItsOwnPrefix()
        {
            // Arrange
            var prefix = new CommentGroupNode("Comment");
            var target = new ConcatenationNode()
            {
                Prefix = prefix
            };

            // Act
            var(_, Length) = target.GetSpan();

            // Assert
            Length.ShouldBe(target.ToString().Length - prefix.ToString().Length);
        }