public void OnAllMutantsTested(IReadOnlyInputComponent inputComponent) { // setup display handlers inputComponent.DisplayFolder = (int depth, IReadOnlyInputComponent current) => { // show depth _chalk.Default($"{new string('-', depth)} {Path.DirectorySeparatorChar}{Path.GetFileName(current.Name)} "); DisplayComponent(current); }; inputComponent.DisplayFile = (int depth, IReadOnlyInputComponent current) => { // show depth _chalk.Default($"{new string('-', depth)} {current.Name} "); DisplayComponent(current); foreach (var mutant in current.TotalMutants) { if (mutant.ResultStatus == MutantStatus.Killed || mutant.ResultStatus == MutantStatus.Timeout) { _chalk.Green($"[{mutant.ResultStatus}] "); } else { _chalk.Red($"[{mutant.ResultStatus}] "); } _chalk.Default($"{mutant.Mutation.DisplayName} on line {mutant.Mutation.OriginalNode.GetLocation().GetLineSpan().StartLinePosition.Line + 1}: '{mutant.Mutation.OriginalNode}' ==> '{mutant.Mutation.ReplacementNode}'{Environment.NewLine}"); } }; // print empty line for readability _chalk.Default($"{Environment.NewLine}{Environment.NewLine}All mutants have been tested, and your mutation score has been calculated{Environment.NewLine}"); // start recursive invocation of handlers inputComponent.Display(1); }
public void OnAllMutantsTested(IReadOnlyInputComponent reportComponent) { var files = new List <FileLeaf>(); FolderComposite rootFolder = null; reportComponent.DisplayFolder = (int _, IReadOnlyInputComponent current) => { rootFolder ??= (FolderComposite)current; }; reportComponent.DisplayFile = (int _, IReadOnlyInputComponent current) => { var fileLeaf = (FileLeaf)current; files.Add((FileLeaf)current); }; // print empty line for readability _consoleWriter.WriteLine(); _consoleWriter.WriteLine(); _consoleWriter.WriteLine("All mutants have been tested, and your mutation score has been calculated"); // start recursive invocation of handlers reportComponent.Display(0); var filePathLength = Math.Max(9, files.Max(f => f.RelativePathToProjectFile?.Length ?? 0) + 1); _consoleWriter.WriteLine($"┌─{new string('─', filePathLength)}┬──────────┬──────────┬───────────┬────────────┬──────────┬─────────┐"); _consoleWriter.WriteLine($"│ File{new string(' ', filePathLength - 4)}│ % score │ # killed │ # timeout │ # survived │ # no cov │ # error │"); _consoleWriter.WriteLine($"├─{new string('─', filePathLength)}┼──────────┼──────────┼───────────┼────────────┼──────────┼─────────┤"); DisplayComponent(rootFolder, filePathLength); foreach (var file in files) { DisplayComponent(file, filePathLength); } _consoleWriter.WriteLine($"└─{new string('─', filePathLength)}┴──────────┴──────────┴───────────┴────────────┴──────────┴─────────┘"); }
public void OnAllMutantsTested(IReadOnlyInputComponent reportComponent) { // setup display handlers reportComponent.DisplayFolder = (int depth, IReadOnlyInputComponent current) => { // show depth _chalk.Default($"{new string('-', depth)} {Path.DirectorySeparatorChar}{Path.GetFileName(current.Name)} "); DisplayComponent(current); }; reportComponent.DisplayFile = (int depth, IReadOnlyInputComponent current) => { // show depth _chalk.Default($"{new string('-', depth)} {current.Name} "); DisplayComponent(current); foreach (var mutant in current.TotalMutants) { if (mutant.ResultStatus == MutantStatus.Killed || mutant.ResultStatus == MutantStatus.Timeout) { _chalk.Green($"[{mutant.ResultStatus}] "); } else if (mutant.ResultStatus == MutantStatus.NoCoverage) { _chalk.Yellow($"[{mutant.ResultStatus}] "); } else { _chalk.Red($"[{mutant.ResultStatus}] "); } _chalk.Default(mutant.LongName + Environment.NewLine); } }; // print empty line for readability _chalk.Default($"{Environment.NewLine}{Environment.NewLine}All mutants have been tested, and your mutation score has been calculated{Environment.NewLine}"); // start recursive invocation of handlers reportComponent.Display(1); }
public void OnAllMutantsTested(IReadOnlyInputComponent reportComponent) { var rootFolderProcessed = false; // setup display handlers reportComponent.DisplayFolder = (int _, IReadOnlyInputComponent current) => { // show depth var continuationLines = ParentContinuationLines(current); var stringBuilder = new StringBuilder(); foreach (var item in continuationLines.SkipLast(1)) { stringBuilder.Append(item ? ContinueLine : NoLine); } var folderLines = string.Empty; if (continuationLines.Count > 0) { folderLines = continuationLines.Last() ? BranchLine : FinalBranchLine; } var name = current.Name; if (name == null && !rootFolderProcessed) { name = "All files"; rootFolderProcessed = true; } if (!string.IsNullOrWhiteSpace(name)) { _chalk.Default($"{stringBuilder}{folderLines}{name}"); DisplayComponent(current); } }; reportComponent.DisplayFile = (int _, IReadOnlyInputComponent current) => { // show depth var continuationLines = ParentContinuationLines(current); var stringBuilder = new StringBuilder(); foreach (var item in continuationLines.SkipLast(1)) { stringBuilder.Append(item ? ContinueLine : NoLine); } _chalk.Default($"{stringBuilder}{(continuationLines.Last() ? BranchLine : FinalBranchLine)}{current.Name}"); DisplayComponent(current); stringBuilder.Append(continuationLines.Last() ? ContinueLine : NoLine); var prefix = stringBuilder.ToString(); foreach (var mutant in current.TotalMutants) { var isLastMutant = current.TotalMutants.Last() == mutant; _chalk.Default($"{prefix}{(isLastMutant ? FinalBranchLine : BranchLine)}"); switch (mutant.ResultStatus) { case MutantStatus.Killed: case MutantStatus.Timeout: _chalk.Green($"[{mutant.ResultStatus}]"); break; case MutantStatus.NoCoverage: _chalk.Yellow($"[{mutant.ResultStatus}]"); break; default: _chalk.Red($"[{mutant.ResultStatus}]"); break; } _chalk.Default($" {mutant.Mutation.DisplayName} on line {mutant.Line}{Environment.NewLine}"); _chalk.Default($"{prefix}{(isLastMutant ? NoLine : ContinueLine)}{BranchLine}[-] {mutant.Mutation.OriginalNode}{Environment.NewLine}"); _chalk.Default($"{prefix}{(isLastMutant ? NoLine : ContinueLine)}{FinalBranchLine}[+] {mutant.Mutation.ReplacementNode}{Environment.NewLine}"); } }; // print empty line for readability _chalk.Default($"{Environment.NewLine}{Environment.NewLine}All mutants have been tested, and your mutation score has been calculated{Environment.NewLine}"); // start recursive invocation of handlers reportComponent.Display(1); }