public void TestEnumerator() { var queue = new TreeQueue <int>(); TreeQueue <int> .Enumerator enumerator = queue.GetEnumerator(); Assert.Equal(0, enumerator.Current); Assert.False(enumerator.MoveNext()); Assert.Equal(0, enumerator.Current); Assert.False(enumerator.MoveNext()); Assert.Equal(0, enumerator.Current); // Adding an item to the queue invalidates it, but Current is still unchecked queue.Enqueue(1); Assert.Throws <InvalidOperationException>(() => enumerator.MoveNext()); Assert.Equal(0, enumerator.Current); enumerator = queue.GetEnumerator(); Assert.Equal(0, enumerator.Current); Assert.True(enumerator.MoveNext()); Assert.Equal(1, enumerator.Current); // Reset has no effect due to boxing the value type ((IEnumerator <int>)enumerator).Reset(); Assert.Equal(1, enumerator.Current); Assert.False(enumerator.MoveNext()); Assert.Equal(1, enumerator.Current); }