Exemplo n.º 1
0
 private void WriteOut(HashedStream inStr, HashedStream outStr)
 {
     Random rand = new Random();
     using(inStr)
     using(outStr)
     {
         Assert.True(inStr.CanRead);
         Assert.True(outStr.CanWrite);
         if(inStr.CanTimeout)
             Assert.NotEqual(0, inStr.ReadTimeout);
         if(outStr.CanTimeout)
             Assert.NotEqual(0, outStr.WriteTimeout);
         for(;;)
         {
             var buffer = new byte[rand.Next(1, 20000)];
             int read = inStr.Read(buffer, 0, buffer.Length);
             if(read == 0)
                 return;
             outStr.Write(buffer, 0, read);
             int by = inStr.ReadByte();
             if(by == -1)
                 return;
             outStr.WriteByte((byte)by);
         }
     }
 }