Example #1
0
        public void ReadsBlocks(byte[] value, byte[] encoding)
        {
            var stream = new MemoryStream(encoding);

            using (stream)
            {
                Assert.Equal(value, Codec.ReadBlocks(stream, s => (byte)s.ReadByte()));
                Assert.Equal(encoding.Length, stream.Position);
            }
        }
Example #2
0
        public void ReadsBlocks(byte[] value, byte[] encoding)
        {
            var input   = Expression.Parameter(typeof(Stream));
            var advance = Expression.Call(input, typeof(Stream).GetMethod(nameof(Stream.ReadByte)));
            var read    = (Action <Stream>)Expression.Lambda(Codec.ReadBlocks(input, advance), new[] { input }).Compile();

            using (var stream = new MemoryStream(encoding))
            {
                read(stream);
                Assert.Equal(encoding.Length, stream.Position);
            }
        }