public int CalculateRiskFor(AffectedGraph graph) { //TODO make interface take the hash not the graph (so it canbe reused between strategies instead of built n times) if (graph == null) return 0; var root = graph.GetRootNode(); if (root == null) return 0; var visited = new Dictionary<string, int>(); var hash = GraphNodeHashBuilder.GetHashFrom(graph); var testsScore = RecurseFrom(root.FullName, hash, 0, 0, visited); var complexity = root.Complexity > 1.0m ? root.Complexity : 1.0m; var overallScore = testsScore/complexity; var ret = overallScore > 1.0m ? 1.0m : overallScore; return (int) (ret * 100m); }
public int CalculateRiskFor(AffectedGraph graph) { if (graph == null) { return(0); } var root = graph.GetRootNode(); if (root == null) { return(0); } var connections = GraphNodeHashBuilder.GetHashFrom(graph); var risk = RecurseRisk(root.FullName, connections, new Dictionary <string, bool>()); if (risk.nottested + risk.tested == 0) { return(0); } return((int)(risk.tested / (decimal)(risk.nottested + risk.tested) * 100.0m)); }