public void when_no_root_node_get_root_node_returns_null() { var g = new AffectedGraph(); g.AddNode(new AffectedGraphNode("foo", false, false, false, "name", "bar::foo", "assembly", "type", new List <TestDescriptor>(), false, false, 0)); Assert.IsNull(g.GetRootNode()); }
public void when_root_node_get_root_node_returns_root_node() { var g = new AffectedGraph(); var root = new AffectedGraphNode("foo", false, false, true, "name", "bar::foo", "assembly", "type", new List <TestDescriptor>(), false, false, 0); g.AddNode(root); g.AddNode(new AffectedGraphNode("foo", false, false, false, "name", "bar::foo2", "assembly", "type", new List <TestDescriptor>(), false, false, 0)); Assert.AreEqual(root, g.GetRootNode()); }
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)); }
public void the_root_node_is_the_searched_node() { Assert.AreEqual("GrandChild", _graph.GetRootNode().Name); }