Пример #1
0
 public void Read()
 {
     MemoryStream ms = new MemoryStream();
     ms.Write(HELLO_BYTES, 0, HELLO_BYTES.Length);
     ms.Seek(0, SeekOrigin.Begin);
     ZlibStream z = new ZlibStream(ms);
     byte[] buf = new byte[1024];
     int len = z.Read(buf, 0, buf.Length);
     Assert.IsTrue(len > 0);
     string str = ENC.GetString(buf, 0, len);
     Assert.AreEqual(HELLO_STR, str);
 }
Пример #2
0
 public void Write()
 {
     byte[] buf = ENC.GetBytes(HELLO_STR);
     MemoryStream ms = new MemoryStream();
     ZlibStream z = new ZlibStream(ms, 4);
     z.Write(buf, 0, buf.Length);
     ms.Seek(0, SeekOrigin.Begin);
     byte[] res = ms.ToArray();
     Assert.AreEqual(HELLO_BYTES.Length, res.Length);
     int count = 0;
     foreach (byte b in res)
     {
         Assert.AreEqual(HELLO_BYTES[count++], b);
     }
 }