public void Traverse_PostOrder() { GenericBinaryTree<TestObject_Integer> testTree = new GenericBinaryTree<TestObject_Integer>(); TestObject_TraversalMethodSource testHandler = new TestObject_TraversalMethodSource(); GenericBinaryTree<TestObject_Integer>.HandleItem testDelegate = testHandler.HandleNode; testTree.Add(new TestObject_Integer(4)); testTree.Add(new TestObject_Integer(2)); testTree.Add(new TestObject_Integer(6)); testTree.Add(new TestObject_Integer(1)); testTree.Add(new TestObject_Integer(3)); testTree.Add(new TestObject_Integer(5)); testTree.Add(new TestObject_Integer(7)); bool traverseResult = false; traverseResult = testTree.Traverse(TraverseType.PostOrder, testDelegate); string expectedResult = "1325764"; Assert.IsTrue(traverseResult); Assert.IsFalse(testTree.HasErrors); Assert.AreEqual(expectedResult, testHandler.ToString()); }
public void Traverse_None() { GenericBinaryTree<TestObject_Integer> testTree = new GenericBinaryTree<TestObject_Integer>(); TestObject_TraversalMethodSource testHandler = new TestObject_TraversalMethodSource(); GenericBinaryTree<TestObject_Integer>.HandleItem testDelegate = testHandler.HandleNode; testTree.Add(new TestObject_Integer(4)); testTree.Add(new TestObject_Integer(2)); testTree.Add(new TestObject_Integer(6)); testTree.Add(new TestObject_Integer(1)); testTree.Add(new TestObject_Integer(3)); testTree.Add(new TestObject_Integer(5)); testTree.Add(new TestObject_Integer(7)); bool traverseResult = true; traverseResult = testTree.Traverse(TraverseType.None, testDelegate); Assert.IsFalse(traverseResult); Assert.IsTrue(testTree.HasErrors); }