示例#1
0
        static void WriteFileHashes(StringBuilder sb, IndexViewModel indexView)
        {
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine("--------");
            sb.AppendLine("Source File Hashes");

            var rows = new List <string[]>();

            foreach (var entry in indexView.SourceFileMaps)
            {
                rows.Add(new string[] { entry.SourceFilePath, entry.SourceHashSha256 });
            }

            var hashTable = new AsciiTable
            {
                Columns      = new[] { "File", "Fingerprint (SHA256)" },
                Rows         = rows.ToArray(),
                SplitterChar = ' '
            };

            hashTable.WriteToString(sb);
        }
示例#2
0
        static void WriteCoverageTable(StringBuilder sb, IndexViewModel indexView)
        {
            sb.AppendLine();
            sb.AppendLine();
            sb.AppendLine("--------");
            sb.AppendLine("Coverage");

            var rows = new List <string[]>();

            string[] CreateRow(string rowName, CoverageStats entry)
            {
                return(new string[]
                {
                    rowName,
                    $"{entry.LineCoveredCount}/{entry.LineCount}",
                    $"{entry.LineCoveragePercent}%",
                    $"{entry.BranchCoveredCount}/{entry.BranchCount}",
                    $"{entry.BranchCoveragePercent}%",
                    $"{entry.FunctionCoveredCount}/{entry.FunctionCount}",
                    $"{entry.FunctionCoveragePercent}%"
                });
            }

            foreach (var entry in indexView.SourceFileMaps)
            {
                rows.Add(CreateRow(entry.SourceFilePath, entry));
            }

            var coverageTable = new AsciiTable
            {
                Columns = new[] { "File", "Lines", string.Empty, "Branches", string.Empty, "Functions", string.Empty },
                Rows    = rows.ToArray(),
                Footer  = CreateRow("All files", indexView)
            };

            coverageTable.WriteToString(sb);
        }