Exemplo n.º 1
0
        public void PrepareStreamForRead2b()
        {
            using (var testStream = GetStandardStream())
                using (var foStream = new ForwardOnlyStream(testStream))
                {
                    var wrapper = GetStandardWrapper(foStream);

                    int readCount = wrapper.TestingPrepareStreamForRead(1, 55);

                    Assert.AreEqual(1, readCount);
                    Assert.AreEqual(55, testStream.Position);
                }
        }
Exemplo n.º 2
0
        public void ReadStream3a()
        {
            using (var testStream = GetStandardStream())
                using (var foStream = new ForwardOnlyStream(testStream))
                {
                    var wrapper = GetStandardWrapper(foStream);
                    testStream.Position = testStream.Length - 9;
                    wrapper.TestingReadStream(0, 10, testStream.Position);

                    Assert.AreEqual(testStream.Length, testStream.Position);
                    Assert.AreEqual(9, wrapper.TestingBufferEndIndex);
                    Assert.That(wrapper.TestingBuffer.Take(9).SequenceEqual(new byte[] { 7, 252, 7, 253, 7, 254, 7, 255, 7 }));
                }
        }
        public void CalculateRead0()
        {
            using (var testStream = GetStandardStream())
            using (var foStream = new ForwardOnlyStream(testStream))
            {
                var wrapper = GetStandardWrapper(foStream);

                int startIdx, endIdx, readStart, readCount, moveCount;
                long readOffset;

                startIdx = -10;
                endIdx = -1;

                Assert.Throws<InvalidOperationException>(() => wrapper.TestingCalculateRead(ref startIdx, ref endIdx, out readStart, out readCount, out moveCount, out readOffset));
            }
        }
Exemplo n.º 4
0
        public void CalculateRead0()
        {
            using (var testStream = GetStandardStream())
                using (var foStream = new ForwardOnlyStream(testStream))
                {
                    var wrapper = GetStandardWrapper(foStream);

                    int  startIdx, endIdx, readStart, readCount, moveCount;
                    long readOffset;

                    startIdx = -10;
                    endIdx   = -1;

                    Assert.Throws <InvalidOperationException>(() => wrapper.TestingCalculateRead(ref startIdx, ref endIdx, out readStart, out readCount, out moveCount, out readOffset));
                }
        }
        public void ReadStream3a()
        {
            using (var testStream = GetStandardStream())
            using (var foStream = new ForwardOnlyStream(testStream))
            {
                var wrapper = GetStandardWrapper(foStream);
                testStream.Position = testStream.Length - 9;
                wrapper.TestingReadStream(0, 10, testStream.Position);

                Assert.AreEqual(testStream.Length, testStream.Position);
                Assert.AreEqual(9, wrapper.TestingBufferEndIndex);
                Assert.That(wrapper.TestingBuffer.Take(9).SequenceEqual(new byte[] { 7, 252, 7, 253, 7, 254, 7, 255, 7 }));
            }
        }
        public void PrepareStreamForRead2c()
        {
            using (var testStream = GetStandardStream())
            using (var foStream = new ForwardOnlyStream(testStream))
            {
                var wrapper = GetStandardWrapper(foStream);
                testStream.Position = 50;

                int readCount = wrapper.TestingPrepareStreamForRead(1, 0);

                Assert.AreEqual(0, readCount);
                Assert.AreEqual(50, testStream.Position);
            }
        }