コード例 #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);
        }
コード例 #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));
        }
コード例 #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));
        }
コード例 #4
0
        public void ByteArrayGetPosition()
        {
            var data = new byte[10];

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.Position, Is.Zero);
        }
コード例 #5
0
        public void ByteArrayCanSeek()
        {
            var data = new byte[0];

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.CanSeek, Is.True);
        }
コード例 #6
0
        public void ByteArrayLength()
        {
            var data = new byte[10];

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.Length, Is.EqualTo(10));
        }
コード例 #7
0
        public void ByteArrayEmptyLength()
        {
            var data = new byte[0];

            var cs = new ConcatStream();

            cs.Append(data);

            Assert.That(cs.Length, Is.Zero);
        }
コード例 #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);
        }
コード例 #9
0
        public void SystemIOStreamNull()
        {
            System.IO.Stream data = null;

            var cs = new ConcatStream();

            Assert.Throws <System.ArgumentNullException>(() =>
            {
                cs.Append(data);
            });
        }
コード例 #10
0
        public void ByteArrayNull()
        {
            byte[] data = null;

            var cs = new ConcatStream();

            Assert.Throws <System.ArgumentNullException>(() =>
            {
                cs.Append(data);
            });
        }
コード例 #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);
        }
コード例 #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);
        }
コード例 #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);
            });
        }
コード例 #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;
            });
        }
コード例 #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));
        }