public void Test_Traverse_RootNode_Has_No_Children_RootNode_Visited() { var rootNode = new MockNode(); _tree.RootNode = rootNode; var traverser = new LevelorderTraversalStrategy(); traverser.Traverse <object>(_tree, _visitor); Assert.IsTrue(rootNode.WasVisisted); Assert.IsTrue(_visitor.NodesVisited.Count == 1); }
public void Test_Traverse_RootNode_Has_Children_Tree_Visited_In_Preorder_Order() { //Preorder pattern is 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 var expected = new List <int> { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 }; BuildTreeForTest(); var traverser = new LevelorderTraversalStrategy(); traverser.Traverse <object>(_tree, _visitor); Assert.IsTrue(_visitor.NodesVisited.SequenceEqual(expected)); }