public void Enumerator_Success()
{
string item1 = "Accept";
string item2 = "Content-Length";
string item3 = "Name";
WebHeaderCollection w = new WebHeaderCollection();
w[item1] = "text/plain";
w[item2] = "123";
w[item3] = "value";
IEnumerable collection = w;
IEnumerator e = collection.GetEnumerator();
for (int i = 0; i < 2; i++)
{
// Not started
Assert.Throws<InvalidOperationException>(() => e.Current);
Assert.True(e.MoveNext());
Assert.Same(item1, e.Current);
Assert.True(e.MoveNext());
Assert.Same(item2, e.Current);
Assert.True(e.MoveNext());
Assert.Same(item3, e.Current);
Assert.False(e.MoveNext());
Assert.False(e.MoveNext());
Assert.False(e.MoveNext());
// Ended
Assert.Throws<InvalidOperationException>(() => e.Current);
e.Reset();
}
}
}