public void TestDynamicContentStream([Values(true, false)] bool buffered)
 {
     for (int chunkSize = 1; chunkSize <= 1024; chunkSize++)
     {
         using (var dynamicContentStream = new DynamicContentStream(dynamicContent(), buffered))
         using (var writeToMemory = new MemoryStream())
         {
             var buf = new byte[chunkSize];
             while (true)
             {
                 var bytesRead = dynamicContentStream.Read(buf, 0, chunkSize);
                 if (bytesRead == 0)
                     break;
                 writeToMemory.Write(buf, 0, bytesRead);
             }
             writeToMemory.Close();
             var bytes = writeToMemory.ToArray();
             Assert.AreEqual(dynamicContent().JoinString(), bytes.FromUtf8());
         }
     }
 }
Exemplo n.º 2
0
 public void TestDynamicContentStream([Values(true, false)] bool buffered)
 {
     for (int chunkSize = 1; chunkSize <= 1024; chunkSize++)
     {
         using (var dynamicContentStream = new DynamicContentStream(dynamicContent(), buffered))
             using (var writeToMemory = new MemoryStream())
             {
                 var buf = new byte[chunkSize];
                 while (true)
                 {
                     var bytesRead = dynamicContentStream.Read(buf, 0, chunkSize);
                     if (bytesRead == 0)
                     {
                         break;
                     }
                     writeToMemory.Write(buf, 0, bytesRead);
                 }
                 writeToMemory.Close();
                 var bytes = writeToMemory.ToArray();
                 Assert.AreEqual(dynamicContent().JoinString(), bytes.FromUtf8());
             }
     }
 }