public void Insert() { var tree = new BinarySearchTree <MockComparable>(); var mock = new MockComparable(3); var node = new TNode <MockComparable>(mock); tree.Insert(node); Assert.IsNull(node.Parent, "#A01"); var mock2 = new MockComparable(7); var node2 = new TNode <MockComparable>(mock2); tree.Insert(node2); Assert.AreEqual(node2, node.RightChild, "#A02"); Assert.AreEqual(node, node2.Parent, "#A02bis"); }
public void MaximumMinimum() { var tree = new BinarySearchTree <MockComparable>(); var mock = new MockComparable(3); var node = new TNode <MockComparable>(mock); tree.Insert(node); Assert.AreEqual(3, tree.Maximum().Content.Value, "#AA01"); Assert.AreEqual(3, tree.Minimum().Content.Value, "#AA01bis"); var mock2 = new MockComparable(7); var node2 = new TNode <MockComparable>(mock2); tree.Insert(node2); Assert.AreEqual(7, tree.Maximum().Content.Value, "#AA02"); Assert.AreEqual(3, tree.Minimum().Content.Value, "#AA02bis"); }