public void TestReadAllAndLength(string chunkedData, string dechunkedData) { var stream = new DechunkedStream(new ByteArray(ASCIIEncoding.ASCII.GetBytes(chunkedData))); Assert.Equal(dechunkedData, ASCIIEncoding.ASCII.GetString(stream.ReadBytes())); stream = new DechunkedStream(new ByteArray(ASCIIEncoding.ASCII.GetBytes(chunkedData))); Assert.Equal(dechunkedData.Length, stream.Length); }
public void TestEmptyStream() { var stream = new DechunkedStream(EmptyData.Instance); Assert.Equal(0, stream.Length); Assert.Throws(typeof(IndexOutOfRangeException), delegate() { stream.ReadByte(0); }); Assert.Throws(typeof(IndexOutOfRangeException), delegate() { stream.ReadBytesToBuffer(new byte[] { 5 }, 0, 1, 0); }); }
public void TestReadByte(string chunkedData, long index, string dechunkedData) { var stream = new DechunkedStream(new ByteArray(ASCIIEncoding.ASCII.GetBytes(chunkedData))); Assert.Equal(dechunkedData, ASCIIEncoding.ASCII.GetString(new byte[] { stream.ReadByte(index) })); }
public void TestPartialRead(string chunkedData, long start, int length, string dechunkedData) { var stream = new DechunkedStream(new ByteArray(ASCIIEncoding.ASCII.GetBytes(chunkedData))); Assert.Equal(dechunkedData, ASCIIEncoding.ASCII.GetString(stream.ReadBytes(start, length))); }