public void InsertionTest() { Console.WriteLine("AVLTree Insertion Test is running..."); var avlTree = new AvlTree <int>(); var rnd = new Random(); //Generate 20000 random integer var testData = new int[20000]; for (var i = 0; i < 20000; i++) { testData[i] = rnd.Next(-20000, 20000); } var counter = 0; foreach (var e in testData) { var res = avlTree.Insert(e); if (res) { counter++; CallTreeValidation(avlTree.Root); _ = TreeHeightVerification(avlTree.Root); BalancingFactorVerification(avlTree.Root); Assert.AreEqual(counter, avlTree.TreeSize); Assert.AreEqual(avlTree.InOrderTraverse().Count(), avlTree.TreeSize); } } var inOrderList = avlTree.InOrderTraverse().ToList(); Assert.AreEqual(inOrderList.Count, counter); Assert.AreEqual(counter, avlTree.TreeSize); CallTreeValidation(avlTree.Root); _ = TreeHeightVerification(avlTree.Root); BalancingFactorVerification(avlTree.Root); //Test clear the tree here avlTree.ClearTheTree(); Assert.AreEqual(0, avlTree.TreeSize); Assert.IsNull(avlTree.Root); Console.WriteLine("AVLTree Insertion Test has finished running..."); }