public void GetEnumerator() { // Create a new heap. ConcurrentBinaryMinHeap <int> heap = new ConcurrentBinaryMinHeap <int>(); // Enqueue a few elements in the queue. heap.Push(1f, 2); heap.Push(3f, 6); heap.Push(2f, 4); // Use the enumerator of heap (using disposes it when we're finished). using (IEnumerator <PriorityValuePair <int> > enumerator = heap.GetEnumerator()) { // Expect the first element to have the highest priority, and expect MoveNext() to // return true until the last element. After the end of the heap is reached, it // then returns false. // Note: Since the heap doesn't guarantee the order of elements after the first, we // can only be certain of the root element and after that we really can't be sure // of the order -- just the length. Assert.That(enumerator.MoveNext(), Is.True); Assert.That(enumerator.Current.Value, Is.EqualTo(6)); Assert.That(enumerator.MoveNext(), Is.True); Assert.That(enumerator.MoveNext(), Is.True); Assert.That(enumerator.MoveNext(), Is.False); } }