public void SendTest() { var encoder = new ZlibEncoder(); byte[] raw1 = null; byte[] raw2 = null; using (MemoryStream output = new MemoryStream()) { var contents = Encoding.ASCII.GetBytes("hello, world "); // Individual rectangles are compressed using the _same_ zlib stream. Let's send two // rectangles to make sure this is the case. encoder.Send(output, new VncPixelFormat(), new VncRectangle(), contents); raw1 = output.ToArray(); output.SetLength(0); encoder.Send(output, new VncPixelFormat(), new VncRectangle(), contents); raw2 = output.ToArray(); } byte[] expected1 = new byte[] { 0x00, 0x00, 0x00, 0x17, 0x78, 0x9c, 0xca, 0x48, 0xcd, 0xc9, 0xc9, 0xd7, 0x51, 0x28, 0xcf, 0x2f, 0xca, 0x49, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }; byte[] expected2 = new byte[] { 0x00, 0x00, 0x00, 0x15, 0xca, 0x48, 0xcd, 0xc9, 0xc9, 0xd7, 0x51, 0x28, 0xcf, 0x2f, 0xca, 0x49, 0x51, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0xff, 0xff }; Assert.Equal(expected1, raw1); Assert.Equal(expected2, raw2); }