public void TestGet() { ArrayRandomAccessSource s = new ArrayRandomAccessSource(data); try { for (int i = 0; i < data.Length; i++) { int ch = s.Get(i); Assert.IsFalse(ch == -1); Assert.AreEqual(data[i], (byte)ch, "Position " + i); } Assert.AreEqual(-1, s.Get(data.Length)); } finally { s.Close(); } }
public void TestGetArray() { byte[] chunk = new byte[257]; ArrayRandomAccessSource s = new ArrayRandomAccessSource(data); try { int pos = 0; int count = s.Get(pos, chunk, 0, chunk.Length); while (count != -1) { AssertArrayEqual(data, pos, chunk, 0, count); pos += count; count = s.Get(pos, chunk, 0, chunk.Length); } Assert.AreEqual(-1, s.Get(pos, chunk, 0, chunk.Length)); } finally { s.Close(); } }