public void TraverseTests() { var root = new BinaryTreeNode <int>(1, null); var left = root.AddLeft(2); left.AddRight(5); left.AddLeft(4); root.AddRight(3); var inOrderArray = new int[] { 4, 2, 5, 1, 3 }; var preOrderArray = new int[] { 1, 2, 4, 5, 3 }; var postOrderArray = new int[] { 4, 5, 2, 3, 1 }; var idx = 0; root.InOrderTraversal((value) => { Assert.AreEqual <int>(inOrderArray[idx], value); idx++; }); idx = 0; root.PreOrderTraversal((value) => { Assert.AreEqual <int>(preOrderArray[idx], value); idx++; }); idx = 0; root.PostOrderTraversal((value) => { Assert.AreEqual <int>(postOrderArray[idx], value); idx++; }); }