public void ReturnsCorrectItem() { // Starting at -1 because that's the initial position of the reader when nothing has been read yet. for (int i = -1; i < _data.Length; i++) { // If there are items after the current one: if (i + 1 < _data.Length) { Assert.AreEqual(_data[i + 1], _arrayReader.Peek()); _arrayReader.Read(); } } }
public void ReturnsNullWhenNoMoreItemsOnNullableType() { // This test needs an array with nullable type so it // initializes its own instance: var nullableData = new int?[] { 1, 2, 3, 4 }; var nullableArrayReader = new ArrayReader <int?>(nullableData); // Read to the end: while (nullableArrayReader.Read()) { } Assert.AreEqual(null, nullableArrayReader.Peek()); }