예제 #1
0
        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);
        }
예제 #2
0
        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); });
        }
예제 #3
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) }));
        }
예제 #4
0
        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)));
        }