public void TestRead()
        {
            Size limitedSize = new Size(2);

            using (FileStream fileStream = readFileInfo.OpenRead())
                using (LimitedStream limitedStream = new LimitedStream(fileStream, limitedSize))
                {
                    Assert.AreNotEqual(limitedSize.Bytes, fileStream.Length);
                    Assert.AreEqual(limitedSize.Bytes, limitedStream.ReadToEnd().LongLength);
                    Assert.AreEqual(0, limitedStream.ReadToEnd().LongLength);
                }
        }
Exemple #2
0
 public static byte[] ReadMax(this Stream stream, Size limit, Size?estimatedSize = null)
 {
     using (LimitedStream limitedStream = new LimitedStream(stream, limit, leaveOpen: true))
     {
         return(limitedStream.ReadToEnd(estimatedSize));
     }
 }