Exemple #1
0
        public void ReportComponent_ShouldCalculateMutationScore_TwoFolders()
        {
            var target = new CsharpFolderComposite()
            {
                Name = "RootFolder"
            };

            target.Add(new CsharpFileLeaf()
            {
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        ResultStatus = MutantStatus.Killed
                    }
                }
            });
            target.Add(new CsharpFileLeaf()
            {
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        ResultStatus = MutantStatus.Survived
                    }
                }
            });

            var result = target.GetMutationScore();

            result.ShouldBe(0.5);
        }
Exemple #2
0
        public void ReportComponent_ShouldCalculateMutationScore_NoMutations()
        {
            var target = new CsharpFolderComposite();

            target.Add(new CsharpFileLeaf()
            {
                Mutants = new Collection <Mutant>()
                {
                }
            });

            var result = target.GetMutationScore();

            result.ShouldBe(double.NaN);
        }
Exemple #3
0
        public void ReportComponent_ShouldCalculateMutationScore_Recursive()
        {
            var target    = new CsharpFolderComposite();
            var subFolder = new CsharpFolderComposite();

            target.Add(new CsharpFileLeaf()
            {
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        ResultStatus = MutantStatus.Killed
                    }
                }
            });
            target.Add(new CsharpFileLeaf()
            {
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        ResultStatus = MutantStatus.Survived
                    }
                }
            });
            target.Add(subFolder);
            subFolder.Add(new CsharpFileLeaf()
            {
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        ResultStatus = MutantStatus.Survived
                    }, new Mutant()
                    {
                        ResultStatus = MutantStatus.Killed
                    }
                }
            });

            var result = target.GetMutationScore();

            result.ShouldBe(0.5);
        }
Exemple #4
0
        public void ReportComponent_ShouldCalculateMutationScore_OneMutation()
        {
            var target = new CsharpFolderComposite();

            target.Add(new CsharpFileLeaf()
            {
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        ResultStatus = MutantStatus.Killed
                    }
                }
            });

            var result = target.GetMutationScore();

            result.ShouldBe(1);
        }
Exemple #5
0
        public void ReportComponent_ShouldCalculateMutationScore_BuildErrorIsNull()
        {
            var target = new CsharpFolderComposite();

            target.Add(new CsharpFileLeaf()
            {
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        ResultStatus = MutantStatus.CompileError
                    }
                }
            });

            var result = target.GetMutationScore();

            result.ShouldBe(double.NaN);
        }
Exemple #6
0
        public void ReportComponent_ShouldCalculateMutationScore_OnlyKilledIsSuccessful(MutantStatus status, double expectedScore)
        {
            var target = new CsharpFolderComposite();

            target.Add(new CsharpFileLeaf()
            {
                Mutants = new Collection <Mutant>()
                {
                    new Mutant()
                    {
                        ResultStatus = status
                    }
                }
            });

            var result = target.GetMutationScore();

            result.ShouldBe(expectedScore);
        }