Beispiel #1
0
        public void ShouldNotMutateStatementWithArguments(string method)
        {
            var target = new NegateConditionMutator();

            var node = GenerateExpressions(method);

            var result = target.ApplyMutations(node).ToList();

            result.Count.ShouldBe(0);
        }
        public void MutatesStatementWithMethodCallWithNoArguments(string method)
        {
            var target = new NegateConditionMutator();

            var node = GenerateExpressions(method);

            var result = target.ApplyMutations(node).ToList();

            result.Count.ShouldBe(1);
            result.First().ReplacementNode.ToString().ShouldBe("!(Method())");
        }
Beispiel #3
0
        [InlineData("var y = x is object result ? result.ToString() : null;")] // can't mutate inline var declaration
        public void ShouldNotMutateThis(string method)
        {
            var        target = new NegateConditionMutator();
            SyntaxTree tree   = CSharpSyntaxTree.ParseText(method);


            var expressionSyntax = tree.GetRoot().DescendantNodes().OfType <ConditionalExpressionSyntax>().Single();
            var result           = target.ApplyMutations(expressionSyntax.Condition).ToList();

            result.ShouldBeEmpty();
        }
Beispiel #4
0
        public void MutatesStatementWithMethodCallWithNoArguments(string method)
        {
            var target = new NegateConditionMutator();

            var node = GenerateExpressions(method);

            var result = target.ApplyMutations(node).ToList();

            var mutation = result.ShouldHaveSingleItem();

            mutation.ReplacementNode.ToString().ShouldBe("!(Method())");
            mutation.DisplayName.ShouldBe("Negate expression");
        }
Beispiel #5
0
        public void ShouldBeMutationlevelStandard()
        {
            var target = new NegateConditionMutator();

            target.MutationLevel.ShouldBe(MutationLevel.Standard);
        }