private IEnumerable <CodeCoverageStatistics> ReadDataFromNodes(XmlDocument doc, string summaryXmlLocation) { var listCoverageStats = new List <CodeCoverageStatistics>(); if (doc == null) { return(null); } //read data from report nodes XmlNode reportNode = doc.SelectSingleNode("report"); if (reportNode != null) { XmlNodeList counterNodeList = doc.SelectNodes("/report/counter"); if (counterNodeList != null) { foreach (XmlNode counterNode in counterNodeList) { var coverageStatistics = new CodeCoverageStatistics(); if (counterNode.Attributes != null) { if (counterNode.Attributes["type"] != null) { coverageStatistics.Label = ToTitleCase(counterNode.Attributes["type"].Value); coverageStatistics.Position = CodeCoverageUtilities.GetPriorityOrder(coverageStatistics.Label); } if (counterNode.Attributes[_covered] != null) { float covered; if (!float.TryParse(counterNode.Attributes[_covered].Value, out covered)) { throw new InvalidDataException(StringUtil.Loc("InvalidValueInXml", _covered, summaryXmlLocation)); } coverageStatistics.Covered = (int)covered; if (counterNode.Attributes[_missed] != null) { float missed; if (!float.TryParse(counterNode.Attributes[_missed].Value, out missed)) { throw new InvalidDataException(StringUtil.Loc("InvalidValueInXml", _missed, summaryXmlLocation)); } coverageStatistics.Total = (int)missed + (int)covered; } } } listCoverageStats.Add(coverageStatistics); } } } return(listCoverageStats.AsEnumerable()); }
private CodeCoverageStatistics GetCCStats(string labelTag, string coveredTag, string validTag, string priorityTag, string summaryXmlLocation, XmlNode reportNode) { CodeCoverageStatistics coverageStatistics = null; if (reportNode.Attributes[coveredTag] != null && reportNode.Attributes[validTag] != null) { coverageStatistics = new CodeCoverageStatistics(); coverageStatistics.Label = labelTag; coverageStatistics.Position = CodeCoverageUtilities.GetPriorityOrder(priorityTag); coverageStatistics.Covered = (int)ParseFromXML(coveredTag, summaryXmlLocation, reportNode); coverageStatistics.Total = (int)ParseFromXML(validTag, summaryXmlLocation, reportNode); } return(coverageStatistics); }