public void TotalCrapLoadIsCalculatedAsTheSumOfCrapLoadForEachMethod() { var crapSummary = new CrapStatsEntry(_crapMethodData, 1); Assert.AreEqual(28.829629629629633d, crapSummary.CalculateTotalCrapLoad()); }
private XmlElement CreateStats(XmlDocument xmlDoc, CrapStatsEntry crapStatsEntry) { XmlElement stats = xmlDoc.CreateElement("stats"); XmlElement elem = xmlDoc.CreateElement("name"); var value = xmlDoc.CreateTextNode("name"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("totalCrap"); value = xmlDoc.CreateTextNode(crapStatsEntry.CalculateTotalCrap().ToString("0.0")); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("crap"); value = xmlDoc.CreateTextNode("0.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("median"); value = xmlDoc.CreateTextNode("0.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("average"); value = xmlDoc.CreateTextNode("0.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("stdDev"); value = xmlDoc.CreateTextNode("0.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("methodCount"); value = xmlDoc.CreateTextNode(crapStatsEntry.CalculateTotalMethods().ToString()); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("crapMethodCount"); value = xmlDoc.CreateTextNode(crapStatsEntry.CalculateTotalCrapMethods().ToString()); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("crapMethodPercent"); value = xmlDoc.CreateTextNode(crapStatsEntry.CalculateCrapMethodPercentage().ToString("0.0")); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("crapLoad"); value = xmlDoc.CreateTextNode(crapStatsEntry.CalculateTotalCrapLoad().ToString("0")); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("crapThreshold"); value = xmlDoc.CreateTextNode(crapStatsEntry.Threshold.ToString()); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("globalAverage"); value = xmlDoc.CreateTextNode("-1.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("globalCraploadAverage"); value = xmlDoc.CreateTextNode("-1.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("globalCrapMethodAverage"); value = xmlDoc.CreateTextNode("-1.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("globalTotalMethodAverage"); value = xmlDoc.CreateTextNode("-1.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("globalAverageDiff"); value = xmlDoc.CreateTextNode("0.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("globalCraploadAverageDiff"); value = xmlDoc.CreateTextNode("0.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("globalCrapMethodAverageDiff"); value = xmlDoc.CreateTextNode("0.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("globalTotalMethodAverageDiff"); value = xmlDoc.CreateTextNode("0.0"); elem.AppendChild(value); stats.AppendChild(elem); elem = xmlDoc.CreateElement("shareStatsUrl"); value = xmlDoc.CreateTextNode("http://www.crap4j.org/benchmark/stats/new?stat[project_hash]=1290006074016&stat[project_url]=test&stat[crap]=50.00&stat[crap_load]=5&stat[crap_methods]=1&stat[total_methods]=2&stat[ones]=0&stat[twos]=1&stat[fours]=0&stat[eights]=0&stat[sixteens]=1&stat[thirtytwos]=0&stat[sixtyfours]=0&stat[one28s]=0&stat[two56s]=0"); elem.AppendChild(value); stats.AppendChild(elem); elem = CreateHistogramElemnt(xmlDoc); stats.AppendChild(elem); return stats; }