Created
May 26, 2017 20:53
-
-
Save nayato/87859c9306d12277d27eefb98315c4d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
internal class Program | |
{ | |
private static void Main(string[] args) | |
{ | |
var s = new Mock<Stream>(); | |
s.SetupGet(x => x.CanWrite).Returns(true); | |
s.Setup(x => x.Write(It.IsAny<byte[]>(), It.IsAny<int>(), It.IsAny<int>())) | |
.Callback((byte[] buf, int ofs, int cnt) => Console.WriteLine( | |
$"under : len: {cnt} content:" + Environment.NewLine + ByteBufferUtil.PrettyHexDump(Unpooled | |
.WrappedBuffer(buf, ofs, cnt).Slice(0, Math.Min(cnt, 10))))); | |
var cs = new GZipStream(s.Object, CompressionMode.Compress, false); | |
var bs = Encoding.UTF8.GetBytes("Hello, World"); | |
cs.Write(bs, 0, bs.Length); | |
var rnd = new Random(Environment.TickCount); | |
bs = new byte[80 * 1024]; | |
rnd.NextBytes(bs); | |
cs.Write(bs, 0, bs.Length); | |
Console.WriteLine("closing now"); | |
cs.Close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment