public void BinarySearchTree_04_Remove_02_OnNonEmptyTree_ElementNotExisting() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntModerate(); // Act & Assert Assert.Throws(typeof(BinarySearchTreeElementNotFoundException), () => tree.Remove(40)); }
public void BinarySearchTree_05_ToString_03_OnModerateTree() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntModerate(); string expected = "3 7 8 12 17 24 26 32 34 37 42 45 50"; // Act string actual = tree.ToString(); // Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_02_FindMin_04_OnModerateIntTree() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntModerate(); int expected = 3; // Act int actual = tree.FindMin(); // Act & Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_04_Remove_06_OnNonEmptyTree_ElementWithBothChilds() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntModerate(); string expected = "[ [ NIL 3 [ [ NIL 7 NIL ] 8 [ NIL 12 NIL ] ] ] 17 [ [ NIL 24 NIL ] 26 [ [ NIL 34 [ [ NIL 37 NIL ] 42 NIL ] ] 45 [ NIL 50 NIL ] ] ] ]"; // Act tree.Remove(32); string actual = tree.ToInfixString(); // Assert Assert.AreEqual(expected, actual); }
public void BinarySearchTree_03_RemoveMin_04_OnModerateIntTree() { // Arrange IBinarySearchTree <int> tree = DSBuilder.CreateBinarySearchTreeIntModerate(); string expected = "[ [ [ NIL 7 NIL ] 8 [ NIL 12 NIL ] ] 17 [ [ NIL 24 NIL ] 26 [ NIL 32 [ [ NIL 34 [ [ NIL 37 NIL ] 42 NIL ] ] 45 [ NIL 50 NIL ] ] ] ] ]"; // Act tree.RemoveMin(); string actual = tree.ToInfixString(); // Assert Assert.AreEqual(expected, actual); }