public void TestReadOneByOneWholeStream() { var array = new byte[] { 0, 1, 2, 3, 4, 5 }; var chunkedStream = new ChunkedStream(); chunkedStream.Write(array, 1, 3); chunkedStream.Write(array, 2, 4); chunkedStream.Write(array, 3, 3); var b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[1]); b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[2]); b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[3]); b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[2]); b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[3]); b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[4]); b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[5]); b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[3]); b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[4]); b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[5]); }
public void TestMixCopy() { var array = new byte[] { 0, 1, 2, 3, 4, 5 }; var chunkedStream = new ChunkedStream(); chunkedStream.Write(array, 1, 3); chunkedStream.Write(array, 2, 4); chunkedStream.Write(array, 3, 3); var b = chunkedStream.ReadByte(); Assert.AreEqual(b, array[1]); var destArray = new byte[8]; chunkedStream.Read(destArray, 0, destArray.Length); Assert.AreEqual(array[2], destArray[0]); Assert.AreEqual(array[3], destArray[1]); Assert.AreEqual(array[2], destArray[2]); Assert.AreEqual(array[3], destArray[3]); Assert.AreEqual(array[4], destArray[4]); Assert.AreEqual(array[5], destArray[5]); Assert.AreEqual(array[3], destArray[6]); Assert.AreEqual(array[4], destArray[7]); }
private void TestReadByte(string input, int chunkSize, string expected) { var inner = new ByteArray(ASCIIEncoding.ASCII.GetBytes(input)); var chunked = new ChunkedStream(inner, chunkSize); for (int i = 0; i < expected.Length; ++i) { Assert.Equal(ASCIIEncoding.ASCII.GetBytes(expected.Substring(i, 1))[0], chunked.ReadByte(i)); } }