diff --git a/BinaryTree.Test/UnitTest1.cs b/BinaryTree.Test/UnitTest1.cs index 04f3f44..e1ce156 100644 --- a/BinaryTree.Test/UnitTest1.cs +++ b/BinaryTree.Test/UnitTest1.cs @@ -51,5 +51,63 @@ public void TestMethod3() Node parent = bt.findParent(32); Assert.AreEqual(47, parent.value); } + + /// + /// Creates a tree with negative values. + /// Expected to work the same as positive values. + /// + [TestMethod] + public void FindParent_NegativeValueTree_Success() + { + BSTree bt = new BSTree(); + int[] arr1 = { -22, -5, -91, -2, -47, -13, -32, -45, -95 }; + + for (int i = 0; i < arr1.Length; i++) + { + bt.insert(arr1[i]); + } + + Node parent = bt.findParent(-32); + Assert.AreEqual(-47, parent.value); + } + + /// + /// Attempts to locate the parent node of a value that was not + /// given to the tree to manage. Expected return is null. + /// + [TestMethod] + public void FindParent_NonExistantValue_Null() + { + BSTree bt = new BSTree(); + int[] arr1 = { 22, 5, 91, 2, 47, 13, 32, 45, 95 }; + + for (int i = 0; i < arr1.Length; i++) + { + bt.insert(arr1[i]); + } + + Node parent = bt.findParent(-32); + // Assert.AreEqual(null, parent.value); + Assert.AreEqual(null, parent); + } + + + /// + /// Insert 10 equal values to create tree. + /// + [TestMethod] + public void Insert_SameValue_Success() + { + BSTree bt = new BSTree(); + int[] arr1 = { 42, 42, 42, 42, 42, 42, 42, 42, 42, 42 }; + + for (int i = 0; i < arr1.Length; i++) + { + bt.insert(arr1[i]); + } + + var nodeCount = bt.count(); + Assert.AreEqual(10, nodeCount); + } } }