Exemple #1
0
        public void ShouldHaveHelpText()
        {
            var target = new IgnoreMutationsInput();

            target.HelpText.ShouldBe(@"The given mutators will be excluded for this mutation testrun.
    This argument takes a json array as value. Example: ['string', 'logical'] | default: []");
        }
Exemple #2
0
        public void ShouldReturnEmptyLinqExpressionsWithNonLinqOptions()
        {
            var target = new IgnoreMutationsInput {
                SuppliedInput = new[] { "gibberish" }
            };
            var linqExpressions = target.ValidateLinqExpressions();

            linqExpressions.ShouldBeEmpty();
        }
Exemple #3
0
        public void ShouldIgnoreMutatorWithOptions()
        {
            var target = new IgnoreMutationsInput {
                SuppliedInput = new string[] { "linq.Sum", "string.empty", "logical.equal" }
            };

            var result = target.Validate();

            result.ShouldBeEmpty();
        }
Exemple #4
0
        public void ShouldHaveDefault()
        {
            var target = new IgnoreMutationsInput {
                SuppliedInput = new string[] { }
            };

            var result = target.Validate();

            result.ShouldBeEmpty();
        }
Exemple #5
0
        public void ShouldValidateExcludedMutation()
        {
            var target = new IgnoreMutationsInput {
                SuppliedInput = new[] { "gibberish" }
            };

            var ex = Should.Throw <InputException>(() => target.Validate());

            ex.Message.ShouldBe($"Invalid excluded mutation (gibberish). The excluded mutations options are [Statement, Arithmetic, Block, Equality, Boolean, Logical, Assignment, Unary, Update, Checked, Linq, String, Bitwise, Initializer, Regex]");
        }
Exemple #6
0
        public void ShouldHaveDefaultLinqExpressions()
        {
            var target = new IgnoreMutationsInput {
                SuppliedInput = new string[] { }
            };

            var linqExpressions = target.ValidateLinqExpressions();

            linqExpressions.ShouldBeEmpty();
        }
Exemple #7
0
        public void ShouldValidateExcludedLinqExpression(string method)
        {
            var target = new IgnoreMutationsInput
            {
                SuppliedInput = new[] { method }
            };

            var ex = Should.Throw <InputException>(() => target.ValidateLinqExpressions());

            ex.Message.ShouldBe($"Invalid excluded linq expression ({string.Join(".", method.Split(".").Skip(1))}). The excluded linq expression options are [{string.Join(", ", AllLinqExpressions)}]");
        }
Exemple #8
0
        public void ShouldIgnoreStatementMutator()
        {
            var target = new IgnoreMutationsInput
            {
                SuppliedInput = new[] { "statement" }
            };

            var mutators = target.Validate();

            mutators.ShouldHaveSingleItem().ShouldBe(Mutator.Statement);
        }
Exemple #9
0
        public void ShouldReturnMultipleMutators()
        {
            var target = new IgnoreMutationsInput {
                SuppliedInput = new[] {
                    Mutator.String.ToString(),
                Mutator.Logical.ToString()
                }
            };

            var result = target.Validate();

            result.Count().ShouldBe(2);
            result.First().ShouldBe(Mutator.String);
            result.Last().ShouldBe(Mutator.Logical);
        }
Exemple #10
0
        public void ShouldReturnMultipleLinqExpressions()
        {
            var target = new IgnoreMutationsInput
            {
                SuppliedInput = new[] {
                    "linq.FirstOrDefault",
                    "linq.First",
                }
            };

            var linqExpressions = target.ValidateLinqExpressions();

            linqExpressions.Count().ShouldBe(2);
            linqExpressions.First().ShouldBe(LinqExpression.FirstOrDefault);
            linqExpressions.Last().ShouldBe(LinqExpression.First);
        }
Exemple #11
0
        public void ShouldIgnoreIncorrectFormatWhenValidateLinqExpressions()
        {
            var target = new IgnoreMutationsInput
            {
                SuppliedInput = new[] {
                    "linq.Max",
                    "linq.Sum",
                    "test",
                }
            };

            var linqExpressions = target.ValidateLinqExpressions();

            linqExpressions.Count().ShouldBe(2);
            linqExpressions.First().ShouldBe(LinqExpression.Max);
            linqExpressions.Last().ShouldBe(LinqExpression.Sum);
        }