public void ShouldInsertIntoBinarySearchTreeWithoutRoot() { //Arrange int value = 3; BinarySearchTreeStructure.BinarySearchTree bst = new BinarySearchTreeStructure.BinarySearchTree(); //Act bst.Insert(value); var result = bst.Root; //Assert Assert.AreEqual(value, result.Data); }
public void ShouldGetSortedValuesFromBinarySearchTree() { //Arrange BinarySearchTreeStructure.BinarySearchTree bst = new BinarySearchTreeStructure.BinarySearchTree(); Node root = new Node() { Data = 4, Left = new Node() { Data = 2, Left = new Node() { Data = 1 }, Right = new Node() { Data = 3 } }, Right = new Node() { Data = 6, Left = new Node() { Data = 5 }, Right = new Node() { Data = 7 } } }; bst.Root = root; var expectedValue = new int[] { 1, 2, 3, 4, 5, 6, 7 }.ToList(); //Act List <int> result = bst.GetSortedValues(); //Assert CollectionAssert.AreEqual(expectedValue, result); }