Example #1
0
        public void ShouldRemoveStartOfStringNode()
        {
            // Arrange
            var startOfStringNode = new StartOfStringNode();
            var childNodes        = new List <RegexNode>
            {
                startOfStringNode,
                new CharacterNode('a'),
                new CharacterNode('b'),
                new CharacterNode('c')
            };
            var rootNode = new ConcatenationNode(childNodes);
            var target   = new AnchorRemovalMutator();

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

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

            mutation.OriginalNode.ShouldBe(startOfStringNode);
            mutation.ReplacementNode.ShouldBeNull();
            mutation.ReplacementPattern.ShouldBe("abc");
            mutation.DisplayName.ShouldBe("Regex anchor removal mutation");
            mutation.Description.ShouldBe("Anchor \"\\A\" was removed at offset 0.");
        }
        public void ToStringShouldReturnBackslashUppercaseA()
        {
            // Arrange
            var target = new StartOfStringNode();

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

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

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

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