public void TestThatGraphCanBeWalkedFromRoot() { var root = new SimpleNode("root"); var child = new SimpleNode("child"); root.AddChild(child); var graph = new GraphBuilder<SimpleNode>(GetChildren).Build(root); var result = graph.Walk().Aggregate("", (str, node) => str + node.ToString()); Assert.AreEqual("rootchild", result); }
public void TestThatWalkingIsDepthFirst() { var root = new SimpleNode("root"); var child11 = new SimpleNode("child11"); var child12 = new SimpleNode("child12"); var child111 = new SimpleNode("child111"); root.AddChild(child11); root.AddChild(child12); child11.AddChild(child111); var graph = new GraphBuilder<SimpleNode>(GetChildren).Build(root); var result = graph.Walk().Aggregate("", (str, node) => str + node.ToString()); Assert.AreEqual("rootchild11child111child12", result); }