Ejemplo n.º 1
0
        public void DeleteTheBest()
        {
            Random r = new Random();

            List <int> values = new List <int>();

            for (int i = 0; i < 100; i++)
            {
                values.Add(r.Next(100) - r.Next(100));
            }

            foreach (int value in values)
            {
                heap.Insert(value);
            }

            int deleteCount = r.Next(values.Count);

            List <int> sortedValues = values.ToList();

            sortedValues.Sort(comparision);
            sortedValues.Reverse();
            int expectedTheBestValue = sortedValues.Skip(deleteCount).FirstOrDefault();

            for (int i = 0; i < deleteCount; i++)
            {
                Assert.IsTrue(heap.DeleteTheBest());
            }

            Assert.AreEqual(values.Count - deleteCount, heap.Count);
            Assert.AreEqual(expectedTheBestValue, heap.GetTheBest());
        }