public void Remove_ANotExistingElementFromATwoLevelTree_TheCorrectTree() { var notExistingNode = SimpleTree.NotExistingElement; var bst = SimpleTree.Create(); bst.Remove(notExistingNode.Key); NodeAssert.NotNullAndEqual(bst.Root, SimpleTree.RootElement); NodeAssert.BothChildrenAreNotNull(bst.Root); NodeAssert.NotNullAndEqual(bst.Root.Right, SimpleTree.SecondBiggestElement); NodeAssert.BothChildrenAreNotNull(bst.Root.Right); NodeAssert.NotNullAndEqual(bst.Root.Left, SimpleTree.SecondSmallestElement); NodeAssert.BothChildrenAreNotNull(bst.Root.Left); }
public void Remove_TheRootFromAThreeLevelTree_TheCorrectTree() { var firstNode = Node(9); var rootNode = ComplexTree.RootElement; var bst = ComplexTree.Create(); bst.Remove(firstNode.Key); bst.Remove(rootNode.Key); NodeAssert.NotNullAndEqual(bst.Root, Node(10)); NodeAssert.BothChildrenAreNotNull(bst.Root); NodeAssert.NotNullAndEqual(bst.Root.Right, Node(12)); NodeAssert.BothChildrenAreNotNull(bst.Root.Right); NodeAssert.BothChildrenAreNull(bst.Root.Right.Left); NodeAssert.BothChildrenAreNotNull(bst.Root.Right.Right); NodeAssert.NotNullAndEqual(bst.Root.Left, Node(4)); NodeAssert.BothChildrenAreNotNull(bst.Root.Left); NodeAssert.BothChildrenAreNotNull(bst.Root.Left.Left); NodeAssert.BothChildrenAreNotNull(bst.Root.Left.Right); }