Пример #1
0
        public void FibonacciHeapEnumeratorTest()
        {
            FibonacciHeap <Int32, String> heap = new FibonacciHeap <Int32, String>(this.values.OrderBy(value => value.Key));

            IEnumerator enumerator = this.values.OrderBy(value => value.Key).GetEnumerator();
            IEnumerator <KeyValuePair <Int32, String> > heapEnumerator = heap.GetEnumerator();
            IEnumerator heapCollectionEnumerator = (heap as IEnumerable).GetEnumerator();

            while (enumerator.MoveNext())
            {
                heapEnumerator.MoveNext().ShouldBeTrue();
                heapCollectionEnumerator.MoveNext().ShouldBeTrue();

                heapEnumerator.Current.ShouldBe(enumerator.Current);
                heapEnumerator.Current.ShouldBe(heapCollectionEnumerator.Current);
            }

            // exceptions

            heap.Insert(0, "0");

            Should.Throw <InvalidOperationException>(() => heapEnumerator.MoveNext());
        }