Esempio n. 1
0
 public void ZeroBatchingWorks()
 {
     var ms = new MemoryStream();
     var sw = new StreamWriter(ms);
     var aw = new BatchAsyncWriter(ms, NoExceptionExpected, 0);
     var aMessage = "A message";
     aw.WriteAsync(aMessage);
     aw.Finished().Wait();
     Assert.AreEqual(0, aw.Remaining);
     aw.Flush();
     var result = Encoding.UTF8.GetString(ms.ToArray());
     Assert.AreEqual(aMessage, result);
 }  
Esempio n. 2
0
 public void PartialBatchWorks()
 {
     var ms = new MemoryStream();
     var aMessage = "A message";
     var batchSize = aMessage.Length * -2;
     var aw = new BatchAsyncWriter(ms, NoExceptionExpected, batchSize);
     foreach(char c in aMessage) {
         aw.WriteAsync(c.ToString());
     }
     aw.Finished().Wait();
     Assert.AreEqual(0, aw.Remaining);
     aw.Flush();
     var result = Encoding.UTF8.GetString(ms.ToArray());
     Assert.AreEqual(aMessage, result);
 }