Ejemplo n.º 1
0
        public void ByteArrayRead(int dataIndex, BufferType bufferType, int offset, int length, ReadResult expectedResult)
        {
            var cs = new ConcatStream();

            cs.Append(ReadingSourceData[dataIndex]);

            ConcatStreamReadTest(cs, bufferType, offset, length, expectedResult);
        }
Ejemplo n.º 2
0
        public void SystemIOAppendEquality()
        {
            var data = new System.IO.MemoryStream();

            var cs     = new ConcatStream();
            var stream = cs.Append(data);

            Assert.That(cs, Is.EqualTo(stream));
        }
Ejemplo n.º 3
0
        public void ByteArrayAppendEquality()
        {
            var data = new byte[0];

            var cs     = new ConcatStream();
            var stream = cs.Append(data);

            Assert.That(cs, Is.EqualTo(stream));
        }
Ejemplo n.º 4
0
        public void ByteArrayGetPosition()
        {
            var data = new byte[10];

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.Position, Is.Zero);
        }
Ejemplo n.º 5
0
        public void ByteArrayCanSeek()
        {
            var data = new byte[0];

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.CanSeek, Is.True);
        }
Ejemplo n.º 6
0
        public void ByteArrayLength()
        {
            var data = new byte[10];

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.Length, Is.EqualTo(10));
        }
Ejemplo n.º 7
0
        public void ByteArrayEmptyLength()
        {
            var data = new byte[0];

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.Length, Is.Zero);
        }
Ejemplo n.º 8
0
        public void SystemIOGetPosition()
        {
            var data = new System.IO.MemoryStream(new byte[10]);

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.Position, Is.Zero);
            Assert.That(data.Position, Is.Zero);
        }
Ejemplo n.º 9
0
        public void SystemIOStreamNull()
        {
            System.IO.Stream data = null;

            var cs = new ConcatStream();

            Assert.Throws <System.ArgumentNullException>(() =>
            {
                cs.Append(data);
            });
        }
Ejemplo n.º 10
0
        public void ByteArrayNull()
        {
            byte[] data = null;

            var cs = new ConcatStream();

            Assert.Throws <System.ArgumentNullException>(() =>
            {
                cs.Append(data);
            });
        }
Ejemplo n.º 11
0
        public void SystemIOStreamReadable()
        {
            var data = Substitute.For <System.IO.Stream>();

            data.CanSeek.Returns(true);
            data.CanRead.Returns(true);
            data.Position.Returns(0);
            data.Length.Returns(StreamSourceDefaultLength);

            var cs = new ConcatStream();

            cs.Append(data);
        }
Ejemplo n.º 12
0
        public void SystemIOCanSeekFalse()
        {
            var data = Substitute.For <System.IO.Stream>();

            data.CanSeek.Returns(false);
            data.CanRead.Returns(true);
            data.Position.Returns(0);
            data.Length.Returns(StreamSourceDefaultLength);

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.CanSeek, Is.False);
        }
Ejemplo n.º 13
0
        public void SystemIOStreamNotReadable()
        {
            var data = Substitute.For <System.IO.Stream>();

            data.CanSeek.Returns(true);
            data.CanRead.Returns(false);
            data.Position.Returns(0);
            data.Length.Returns(StreamSourceDefaultLength);

            var cs = new ConcatStream();

            Assert.Throws <System.ArgumentException>(() =>
            {
                cs.Append(data);
            });
        }
Ejemplo n.º 14
0
        public void SystemIOSetPositionInvalid()
        {
            var data = new System.IO.MemoryStream(new byte[10]);

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.Throws <System.ArgumentOutOfRangeException>(() =>
            {
                cs.Position = -1;
            });
            Assert.Throws <System.ArgumentOutOfRangeException>(() =>
            {
                cs.Position = 11;
            });
        }
Ejemplo n.º 15
0
        public void SystemIOReadPassthrough()
        {
            // As calls are simply passed through to the stream, it's Stream dependent. So just make sure the stream was effected

            var data = new System.IO.MemoryStream(new byte[10]);

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.Position, Is.Zero);
            Assert.That(data.Position, Is.Zero);

            var buffer = new byte[5];
            var read   = cs.Read(buffer, 0, 3);

            Assert.That(read, Is.EqualTo(3));
            Assert.That(cs.Position, Is.EqualTo(3));
            Assert.That(data.Position, Is.EqualTo(3));
        }