Exemplo n.º 1
0
 public async Task MoveStreamAsync()
 {
     using (var hashOut = new HashedStream(new MemoryStream()))
     using (var tw = new StreamWriter(hashOut))
     {
         string asciiOnlyString = "Something or other";
         await tw.WriteAsync(asciiOnlyString);
         await tw.FlushAsync();
         Assert.Equal(asciiOnlyString.Length, hashOut.Length);
         Assert.Equal(asciiOnlyString.Length, hashOut.Position);
         Assert.True(hashOut.CanSeek);
         hashOut.Seek(0, SeekOrigin.Begin);
         Assert.True(hashOut.WasMoved);
     }
     using (var hashOut = new HashedStream(new MemoryStream()))
     using (var tw = new StreamWriter(hashOut))
     {
         await tw.WriteAsync("Something or other");
         hashOut.SetLength(0);
         Assert.True(hashOut.WasMoved);
     }
     using (var hashOut = new HashedStream(new MemoryStream()))
     using (var tw = new StreamWriter(hashOut))
     {
         await tw.WriteAsync("Something or other");
         Assert.True(hashOut.CanSeek);
         hashOut.Position = 0;
         Assert.True(hashOut.WasMoved);
     }
 }