예제 #1
0
        public void ShouldRemoveEndOfStringNode()
        {
            // Arrange
            var endOfStringNode = new EndOfStringNode();
            var childNodes      = new List <RegexNode>
            {
                new CharacterNode('a'),
                new CharacterNode('b'),
                new CharacterNode('c'),
                endOfStringNode
            };
            var rootNode = new ConcatenationNode(childNodes);
            var target   = new AnchorRemovalMutator();

            // Act
            var result = target.ApplyMutations(endOfStringNode, rootNode);

            // Assert
            var mutation = result.ShouldHaveSingleItem();

            mutation.OriginalNode.ShouldBe(endOfStringNode);
            mutation.ReplacementNode.ShouldBeNull();
            mutation.ReplacementPattern.ShouldBe("abc");
            mutation.DisplayName.ShouldBe("Regex anchor removal mutation");
            mutation.Description.ShouldBe("Anchor \"\\z\" was removed at offset 3.");
        }
        public void ToStringShouldReturnBackslashLowercaseZ()
        {
            // Arrange
            var target = new EndOfStringNode();

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

            // Assert
            result.ShouldBe(@"\z");
        }
        public void ToStringOnEndOfStringNodeWithPrefixShouldReturnCommentBeforeBackslashLowercaseZ()
        {
            // Arrange
            var comment = new CommentGroupNode("This is a comment.");
            var target  = new EndOfStringNode()
            {
                Prefix = comment
            };

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

            // Assert
            result.ShouldBe(@"(?#This is a comment.)\z");
        }