public void ReadsFixedLengthByteArrays(int length, byte[] encoding) { var stream = new MemoryStream(encoding); using (stream) { Assert.Equal(length, Codec.Read(stream, length).Length); Assert.Equal(length, stream.Position); } }
public void ReadsFixedLengthByteArrays(int length, byte[] encoding) { var input = Expression.Parameter(typeof(Stream)); var read = (Func <Stream, byte[]>)Expression.Lambda(Codec.Read(input, Expression.Constant(length)), new[] { input }).Compile(); using (var stream = new MemoryStream(encoding)) { Assert.Equal(length, read(stream).Length); Assert.Equal(length, stream.Position); } }