Esempio n. 1
0
        public void MutationShouldNotContainOriginalNodesPrefixInDescription()
        {
            // Arrange
            var prefix          = new CommentGroupNode("This is a comment.");
            var startOfLineNode = new StartOfLineNode()
            {
                Prefix = prefix
            };
            var childNodes = new List <RegexNode>
            {
                startOfLineNode,
                new CharacterNode('a'),
                new CharacterNode('b'),
                new CharacterNode('c')
            };
            var rootNode = new ConcatenationNode(childNodes);
            var target   = new AnchorRemovalMutator();

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

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

            mutation.OriginalNode.ShouldBe(startOfLineNode);
            mutation.ReplacementNode.ShouldBeNull();
            mutation.ReplacementPattern.ShouldBe("(?#This is a comment.)abc");
            mutation.DisplayName.ShouldBe("Regex anchor removal mutation");
            mutation.Description.ShouldBe("Anchor \"^\" was removed at offset 22.");
        }
Esempio n. 2
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.");
        }
Esempio n. 3
0
        public void MutateShouldNotMutateNonAnchorNode()
        {
            // Arrange
            var characterNode = new CharacterNode('a');
            var rootNode      = new ConcatenationNode(characterNode);
            var target        = new AnchorRemovalMutator();

            // Act
            var result = target.Mutate(characterNode, rootNode);

            // Assert
            result.ShouldBeEmpty();
        }