public void AddAndRemoveElements() { var r = new Random(); const int totalElements = 10000; var elements = Enumerable.Range(1, totalElements).Select(x => r.Next(totalElements)).ToList(); var target = new BinaryMinHeap<int>(); foreach (var i in elements) { target.Add(i); } Assert.AreEqual(totalElements, target.Count); elements.Sort(); for (var i = 0; i < totalElements; i++) { Assert.AreEqual(elements[i], target.RemoveMin()); } }
public void Should_throw_on_empty_removes() { Assert.That(() => _emptyIntMinHeap.Remove(1), Throws.InvalidOperationException); Assert.That(() => _emptyIntMinHeap.RemoveMin(), Throws.InvalidOperationException); }