Example #1
0
        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());
        }
Example #2
0
        public void ReadByteArray()
        {
            var bytes  = new byte[] { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, };
            var memory = new FastMemoryWriter();

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

            var reader = new FastReader(memory);
            var result = reader.ReadByteArray();

            Assert.True(result.SequenceEqual(bytes));
        }