private ReportTestStatistics CalculateStatistics(ReportVersion version) { var statistics = new ReportTestStatistics(); //Calucate all the stats // Load test results xml from the latest version var xmlPath = Path.Combine(version.Path, "TestResult.xml"); if(File.Exists(xmlPath)) { var document = LoadXml(xmlPath); var total = document.Root.Attributes().First(x => x.Name == "total").Value; int noOfTests = int.Parse(total); statistics.NumberOfTests = noOfTests; var failures = document.Root.Attributes().First(x => x.Name == "failures").Value; int noOfFailures = int.Parse(failures); statistics.Failures = noOfFailures; var inconclusive = document.Root.Attributes().First(x => x.Name == "inconclusive").Value; int noOfInconclusive = int.Parse(inconclusive); statistics.Inconclusive = noOfInconclusive; int success = noOfTests - noOfFailures - noOfInconclusive; statistics.Success = success; } return statistics; }
private IEnumerable<ReportVersion> GetVersions(string path) { var results = new List<ReportVersion>(); foreach (var versionPath in Directory.GetDirectories(path)) { var info = new DirectoryInfo(versionPath); var version = new ReportVersion() {Version = info.Name, Date = info.CreationTime, Path = info.FullName}; version.Statistics = CalculateStatistics(version); results.Add(version); } return results.OrderByDescending(x => x.Date); }