Beispiel #1
0
        public CoberturaReport ConvertToCobertura()
        {
            GetBaseDirectory();

            _coberturaReport = new CoberturaReport();

            _coberturaReport.BranchesCovered = 0;
            _coberturaReport.BranchesValid   = 0;
            _coberturaReport.BranchRate      = 0;

            _coberturaReport.Complexity = 0;

            _coberturaReport.LinesValid   = _report.TotalStatements;
            _coberturaReport.LineRate     = _report.CoveragePercent * 0.01m;
            _coberturaReport.LinesCovered = _report.CoveredStatements;

            _coberturaReport.Sources = new List <string>
            {
                _baseDirectory
            };

            _coberturaReport.Timestamp = DateTime.UtcNow;
            _coberturaReport.Version   = "0";

            _coberturaReport.Packages = _report.Assemblies?
                                        .Select(GetCoberturaPackage)
                                        .ToList();

            return(_coberturaReport);
        }
        private CoberturaReport GenerateReport()
        {
            var report = new CoberturaReport
            {
                LineRate        = 1,
                BranchRate      = 0.958333333333333m,
                LinesCovered    = 567,
                LinesValid      = 567,
                BranchesCovered = 69,
                BranchesValid   = 72,
                Complexity      = 0,
                Version         = "0",
                Timestamp       = new DateTime(2018, 3, 1, 14, 30, 30, DateTimeKind.Utc),
                Sources         = new List <string> {
                    "D:\\Visual Studio Projects\\Dangl.Calculator"
                },
                Packages = new List <CoberturaPackage>
                {
                    new CoberturaPackage
                    {
                        Name       = "Dangl.Calculator",
                        LineRate   = 1,
                        BranchRate = 0.958333333333333m,
                        Complexity = 0,
                        Classes    = new List <CoberturaClass>
                        {
                            new CoberturaClass
                            {
                                Name       = "Dangl.Calculator.CalculationResult",
                                FileName   = "src\\Dangl.Calculator\\CalculationResult.cs",
                                LineRate   = 1,
                                BranchRate = 1,
                                Complexity = 0,
                                Lines      = new List <CoberturaLine>
                                {
                                    new CoberturaLine {
                                        Number = 17, Hits = 161, IsBranch = false
                                    }
                                },
                                Methods = new List <CoberturaMethod>
                                {
                                    new CoberturaMethod
                                    {
                                        Name       = ".ctor",
                                        Signature  = "()",
                                        LineRate   = 1,
                                        BranchRate = 1,
                                        Lines      = new List <CoberturaLine>
                                        {
                                            new CoberturaLine {
                                                Number = 17, Hits = 161, IsBranch = false
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            return(report);
        }