コード例 #1
0
        public void SetLength()
        {
            var stream = new FastMemoryWriter();

            stream.Write("JonnoJJonnoJJonnoJJonnoJ");

            var newLength = 10;

            stream.SetLength(newLength);

            Assert.Equal(newLength, stream.Length);
            Assert.Equal(newLength, stream.Position);
        }
コード例 #2
0
ファイル: FastReaderTest.cs プロジェクト: byme8/faststream
        public void ReadWrongByteArray()
        {
            var bytes  = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, };
            var memory = new FastMemoryWriter();

            memory.WriteByteArray(bytes);
            memory.SetLength(9);
            memory.Seek(0, SeekOrigin.Begin);

            var reader = new FastReader(memory);

            Assert.Throws <EndOfStreamException>(() => reader.ReadByteArray());
        }