public void TestReadWrite() { using (MemoryStream ms = new MemoryStream(SequencedBytes(20))) using (Stream s = new ClampedStream(ms, 10, 5)) { byte[] test = new byte[200]; Assert.AreEqual(5, s.Read(test, 0, 200)); Array.Resize(ref test, 5); Assert.AreEqual(new byte[] { 10, 11, 12, 13, 14 }, test); s.Position = 0; s.Write(new byte[] { 1, 2, 3, 4, 5 }, 0, 5); s.Position = 0; Assert.AreEqual(new byte[] { 1, 2, 3, 4, 5 }, IOStream.ReadAllBytes(s)); } }
public void TestWritePastEnd() { using (Stream s = new ClampedStream(new MemoryStream(new byte[255]), 2, 10)) s.Write(new byte[20], 0, 20); Assert.Fail(); }