Exemplo n.º 1
0
 private async Task WriteOutAsync(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 = await inStr.ReadAsync(buffer, 0, buffer.Length);
             if (read == 0)
                 return;
             await outStr.WriteAsync(buffer, 0, read);
             int by = inStr.ReadByte();
             if (by == -1)
                 return;
             outStr.WriteByte((byte)by);
         }
     }
 }