Esempio n. 1
0
        private void DisplayComponent(IReadOnlyProjectComponent inputComponent)
        {
            var mutationScore = inputComponent.GetMutationScore();

            // Convert the threshold integer values to decimal values
            _consoleWriter.Write($" [{ inputComponent.DetectedMutants().Count()}/{ inputComponent.TotalMutants().Count()} ");

            if (inputComponent.IsComponentExcluded(_options.Mutate))
            {
                _consoleWriter.Write(Output.Bright.Black("(Excluded)"));
            }
            else if (double.IsNaN(mutationScore))
            {
                _consoleWriter.Write(Output.Bright.Black("(N/A)"));
            }
            else
            {
                // print the score as a percentage
                string scoreText = string.Format("({0:P2})", mutationScore);
                if (inputComponent.CheckHealth(_options.Thresholds) is Health.Good)
                {
                    _consoleWriter.Write(Output.Green(scoreText));
                }
                else if (inputComponent.CheckHealth(_options.Thresholds) is Health.Warning)
                {
                    _consoleWriter.Write(Output.Yellow(scoreText));
                }
                else if (inputComponent.CheckHealth(_options.Thresholds) is Health.Danger)
                {
                    _consoleWriter.Write(Output.Red(scoreText));
                }
            }
            _consoleWriter.WriteLine("]");
        }
        private string DisplayComponent(IReadOnlyProjectComponent inputComponent)
        {
            var mutationScore = inputComponent.GetMutationScore();

            var stringBuilder = new StringBuilder();

            // Convert the threshold integer values to decimal values
            stringBuilder.Append($" [[{ inputComponent.DetectedMutants().Count()}/{ inputComponent.TotalMutants().Count()} ");

            if (inputComponent.IsComponentExcluded(_options.Mutate))
            {
                stringBuilder.Append("[Gray](Excluded)[/]");
            }
            else if (double.IsNaN(mutationScore))
            {
                stringBuilder.Append("[Gray](N/A)[/]");
            }
            else
            {
                // print the score as a percentage
                var scoreText = string.Format("({0:P2})", mutationScore);
                if (inputComponent.CheckHealth(_options.Thresholds) is Health.Good)
                {
                    stringBuilder.Append($"[Green]{scoreText}[/]");
                }
                else if (inputComponent.CheckHealth(_options.Thresholds) is Health.Warning)
                {
                    stringBuilder.Append($"[Yellow]{scoreText}[/]");
                }
                else if (inputComponent.CheckHealth(_options.Thresholds) is Health.Danger)
                {
                    stringBuilder.Append($"[Red]{scoreText}[/]");
                }
            }

            stringBuilder.Append("]]");

            return(stringBuilder.ToString());
        }
        private void DisplayComponent(IReadOnlyProjectComponent inputComponent, Table table)
        {
            var columns = new List <IRenderable>
            {
                new Text(inputComponent.RelativePath ?? "All files")
            };

            var mutationScore = inputComponent.GetMutationScore();

            if (inputComponent.IsComponentExcluded(_options.Mutate))
            {
                columns.Add(new Markup("[Gray]Excluded[/]"));
            }
            else if (double.IsNaN(mutationScore))
            {
                columns.Add(new Markup("[Gray]N/A[/]"));
            }
            else
            {
                var scoreText = $"{mutationScore * 100:N2}";

                var checkHealth = inputComponent.CheckHealth(_options.Thresholds);
                if (checkHealth is Health.Good)
                {
                    columns.Add(new Markup($"[Green]{scoreText}[/]"));
                }
                else if (checkHealth is Health.Warning)
                {
                    columns.Add(new Markup($"[Yellow]{scoreText}[/]"));
                }
                else if (checkHealth is Health.Danger)
                {
                    columns.Add(new Markup($"[Red]{scoreText}[/]"));
                }
            }

            var mutants = inputComponent.Mutants.ToList();

            columns.Add(new Text(mutants.Count(m => m.ResultStatus == MutantStatus.Killed).ToString()));
            columns.Add(new Text(mutants.Count(m => m.ResultStatus == MutantStatus.Timeout).ToString()));
            columns.Add(new Text((inputComponent.TotalMutants().Count() - inputComponent.DetectedMutants().Count()).ToString()));
            columns.Add(new Text(mutants.Count(m => m.ResultStatus == MutantStatus.NoCoverage).ToString()));
            columns.Add(new Text(mutants.Count(m => m.ResultStatus == MutantStatus.CompileError).ToString()));

            table.AddRow(columns);
        }
Esempio n. 4
0
        private void DisplayComponent(IReadOnlyProjectComponent inputComponent, int filePathLength)
        {
            _consoleWriter.Write($"│ {(inputComponent.RelativePath ?? "All files").PadRight(filePathLength)}│ ");

            var mutationScore = inputComponent.GetMutationScore();

            if (inputComponent.IsComponentExcluded(_options.Mutate))
            {
                _consoleWriter.Write(Output.Bright.Black("Excluded"));
            }
            else if (double.IsNaN(mutationScore))
            {
                _consoleWriter.Write(Output.Bright.Black("     N/A"));
            }
            else
            {
                var scoreText = $"{mutationScore * 100:N2}".PadLeft(8);

                var checkHealth = inputComponent.CheckHealth(_options.Thresholds);
                if (checkHealth is Health.Good)
                {
                    _consoleWriter.Write(Output.Green(scoreText));
                }
                else if (checkHealth is Health.Warning)
                {
                    _consoleWriter.Write(Output.Yellow(scoreText));
                }
                else if (checkHealth is Health.Danger)
                {
                    _consoleWriter.Write(Output.Red(scoreText));
                }
            }

            var mutants = inputComponent.Mutants.ToList();

            _consoleWriter.Write($" │ {mutants.Count(m => m.ResultStatus == MutantStatus.Killed),8}");
            _consoleWriter.Write($" │ {mutants.Count(m => m.ResultStatus == MutantStatus.Timeout),9}");
            _consoleWriter.Write($" │ {inputComponent.TotalMutants().Count() - inputComponent.DetectedMutants().Count(),10}");
            _consoleWriter.Write($" │ {mutants.Count(m => m.ResultStatus == MutantStatus.NoCoverage),8}");
            _consoleWriter.Write($" │ {mutants.Count(m => m.ResultStatus == MutantStatus.CompileError),7}");
            _consoleWriter.WriteLine($" │");
        }