/// <summary> /// Adds the given historic coverage. /// </summary> /// <param name="historicCoverage">The historic coverage.</param> internal void AddHistoricCoverage(HistoricCoverage historicCoverage) { this.historicCoverages.Add(historicCoverage); }
/// <summary> /// Reads all historic coverage files created by <see cref="HistoryReportGenerator"/> and adds the information to all classes. /// </summary> internal void ApplyHistoricCoverage() { Logger.Info(Resources.ReadingHistoricReports); foreach (var file in Directory.EnumerateFiles(this.historyDirectory, "*_CoverageHistory.xml").OrderBy(f => f)) { try { XDocument document = XDocument.Load(file); DateTime date = DateTime.ParseExact(document.Root.Attribute("date").Value, "yyyy-MM-dd_HH-mm-ss", CultureInfo.InvariantCulture); foreach (var assemblyElement in document.Root.Elements("assembly")) { Assembly assembly = this.assemblies .SingleOrDefault(a => a.Name == assemblyElement.Attribute("name").Value); if (assembly == null) { continue; } foreach (var classElement in assemblyElement.Elements("class")) { Class @class = assembly.Classes .SingleOrDefault(c => c.Name == classElement.Attribute("name").Value); if (@class == null) { continue; } HistoricCoverage historicCoverage = new HistoricCoverage(date) { CoveredLines = int.Parse(classElement.Attribute("coveredlines").Value, CultureInfo.InvariantCulture), CoverableLines = int.Parse(classElement.Attribute("coverablelines").Value, CultureInfo.InvariantCulture), TotalLines = int.Parse(classElement.Attribute("totallines").Value, CultureInfo.InvariantCulture), CoveredBranches = int.Parse(classElement.Attribute("coveredbranches").Value, CultureInfo.InvariantCulture), TotalBranches = int.Parse(classElement.Attribute("totalbranches").Value, CultureInfo.InvariantCulture) }; @class.AddHistoricCoverage(historicCoverage); } } } catch (Exception ex) { Logger.ErrorFormat(" " + Resources.ErrorDuringReadingHistoricReport, file, ex.Message); } } }