public void TestAccept() { BinarySearchTree <int, string> tree = GetTestTree(); TrackingVisitor <KeyValuePair <int, string> > visitor = new TrackingVisitor <KeyValuePair <int, string> >(); tree.Accept(visitor); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <int, string>(4, "4")), true); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <int, string>(6, "6")), true); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <int, string>(2, "2")), true); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <int, string>(5, "5")), true); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <int, string>(19, "19")), true); Assert.AreEqual(visitor.TrackingList.Contains(new KeyValuePair <int, string>(1, "1")), true); Assert.AreEqual(visitor.TrackingList.Count, 6); }
public void TestNullVisitor() { BinarySearchTree <int, string> tree = new BinarySearchTree <int, string>(); tree.Accept(null); }