Ejemplo n.º 1
0
        public void TestWriteHexStream()
        {
            using (Stream mem = new MemoryStream())
            {
                using (Stream io = new HexStream(new NonClosingStream(mem), CryptoStreamMode.Write))
                    io.Write(HexEncoding.DecodeBytes(AllHex), 0, AllHex.Length / 2);

                Assert.AreEqual(AllHex.Length, mem.Position);
                mem.Position = 0;
                string test = new StreamReader(mem).ReadToEnd();
                Assert.AreEqual(AllHex, test);
            }
        }
Ejemplo n.º 2
0
 public void TestReadHexStream()
 {
     using (Stream io = new HexStream(new MemoryStream(Encoding.ASCII.GetBytes(AllHex)), CryptoStreamMode.Read))
     {
         byte[] results = IOStream.ReadAllBytes(io);
         Assert.AreEqual(AllHex.Length / 2, results.Length);
         for (int i = 0; i < 256; i++)
             Assert.AreEqual(i, results[i]);
     }
     using (Stream io = new HexStream(new MemoryStream(Encoding.ASCII.GetBytes(AllHex + " ")), CryptoStreamMode.Read))
     {
         byte[] results = IOStream.ReadAllBytes(io);
         Assert.AreEqual(AllHex.Length / 2, results.Length);
         for (int i = 0; i < 256; i++)
             Assert.AreEqual(i, results[i]);
     }
 }