Ejemplo n.º 1
0
        public void TypicalOverread()
        {
            int toRead = 13;

            byte[] buf             = new byte[toRead];
            var    compositeStream = new CompositeReadStream(TypicalStreams());

            Assert.Equal(TotalLength, compositeStream.Remaining());
            Assert.Equal(TotalLength, compositeStream.Length);
            Assert.Equal(0, compositeStream.Position);
            Assert.Equal(toRead, compositeStream.Read(buf, 0, toRead));
            Assert.Equal(toRead, compositeStream.Position);
            Assert.Equal(TotalLength - toRead, compositeStream.Remaining());
            Assert.Equal(TotalLength, compositeStream.Length);
        }
Ejemplo n.º 2
0
        public void EmptyRead()
        {
            var compositeStream = new CompositeReadStream(EnumerableExt <Stream> .Empty);

            Assert.Equal(0, compositeStream.Remaining());
            Assert.Equal(0, compositeStream.Length);
            Assert.Equal(0, compositeStream.Position);
            Assert.Equal(0, compositeStream.Read(new byte[0], 0, 10));
        }
Ejemplo n.º 3
0
        public void CopyIntoStream()
        {
            byte[] buf             = new byte[TotalLength];
            var    memStream       = new MemoryStream(buf);
            var    compositeStream = new CompositeReadStream(TypicalStreams());

            compositeStream.CopyTo(memStream);
            Assert.Equal(TotalLength, compositeStream.Position);
            Assert.Equal(0, compositeStream.Remaining());
            Assert.Equal(TotalLength, compositeStream.Length);
            Assert.Equal(TotalLength, memStream.Position);
            Assert.Equal(0, memStream.Remaining());
            Assert.Equal(TotalLength, memStream.Length);
            for (int i = 0; i < buf.Length; i++)
            {
                Assert.Equal(i, buf[i]);
            }
        }