Пример #1
0
        public void GetLengthThrowsForUnseekableFileStream()
        {
            string fileName = GetTestFilePath();

            using (FileStream fs = new UnseekableFileStream(fileName, FileMode.Create))
            {
                Assert.Throws <NotSupportedException>(() => _ = fs.Length);
            }
        }
Пример #2
0
 public void GetPositionUnseekableThrows()
 {
     using (FileStream fs = new UnseekableFileStream(GetTestFilePath(), FileMode.Create))
     {
         Assert.Throws<NotSupportedException>(() => fs.Position);
         // dispose checking happens first
         fs.Dispose();
         Assert.Throws<ObjectDisposedException>(() => fs.Position);
     }
 }
Пример #3
0
 public void GetPositionUnseekableThrows()
 {
     using (FileStream fs = new UnseekableFileStream(GetTestFilePath(), FileMode.Create))
     {
         Assert.Throws <NotSupportedException>(() => fs.Position);
         // dispose checking happens first
         fs.Dispose();
         Assert.Throws <ObjectDisposedException>(() => fs.Position);
     }
 }
Пример #4
0
 public void GetLengthUnseekableThrows()
 {
     string fileName = GetTestFilePath();
     using (FileStream fs = new UnseekableFileStream(fileName, FileMode.Create))
     {
         Assert.Throws<NotSupportedException>(() => fs.Length);
         // dispose checking happens first
         fs.Dispose();
         Assert.Throws<ObjectDisposedException>(() => fs.Length);
     }
 }
Пример #5
0
        public void GetLengthUnseekableThrows()
        {
            string fileName = GetTestFilePath();

            using (FileStream fs = new UnseekableFileStream(fileName, FileMode.Create))
            {
                Assert.Throws <NotSupportedException>(() => fs.Length);
                // dispose checking happens first
                fs.Dispose();
                Assert.Throws <ObjectDisposedException>(() => fs.Length);
            }
        }
Пример #6
0
 public void SeekUnseekableThrows()
 {
     using (FileStream fs = new UnseekableFileStream(GetTestFilePath(), FileMode.Create))
     {
         Assert.Throws <NotSupportedException>(() => fs.Seek(1, SeekOrigin.Begin));
         // no fast path
         Assert.Throws <NotSupportedException>(() => fs.Seek(fs.Position, SeekOrigin.Begin));
         // parameter checking happens first
         Assert.Throws <ArgumentException>("origin", () => fs.Seek(0, ~SeekOrigin.Begin));
         // dispose checking happens first
         fs.Dispose();
         Assert.Throws <ObjectDisposedException>(() => fs.Seek(fs.Position, SeekOrigin.Begin));
     }
 }
Пример #7
0
 public void SetPositionUnseekableThrows()
 {
     using (FileStream fs = new UnseekableFileStream(GetTestFilePath(), FileMode.Create))
     {
         Assert.Throws<NotSupportedException>(() => fs.Position = 1);
         // no fast path
         Assert.Throws<NotSupportedException>(() => fs.Position = fs.Position);
         // parameter checking happens first
         Assert.Throws<ArgumentOutOfRangeException>("value", () => fs.Position = -1);
         // dispose checking happens first
         fs.Dispose();
         Assert.Throws<ObjectDisposedException>(() => fs.Position = 1);
     }
 }
Пример #8
0
 public void SetPositionUnseekableThrows()
 {
     using (FileStream fs = new UnseekableFileStream(GetTestFilePath(), FileMode.Create))
     {
         Assert.Throws <NotSupportedException>(() => fs.Position = 1);
         // no fast path
         Assert.Throws <NotSupportedException>(() => fs.Position = fs.Position);
         // parameter checking happens first
         AssertExtensions.Throws <ArgumentOutOfRangeException>("value", () => fs.Position = -1);
         // dispose checking happens first
         fs.Dispose();
         Assert.Throws <ObjectDisposedException>(() => fs.Position = 1);
     }
 }
Пример #9
0
 public void SeekUnseekableThrows()
 {
     using (FileStream fs = new UnseekableFileStream(GetTestFilePath(), FileMode.Create))
     {
         Assert.Throws<NotSupportedException>(() => fs.Seek(1, SeekOrigin.Begin));
         // no fast path
         Assert.Throws<NotSupportedException>(() => fs.Seek(fs.Position, SeekOrigin.Begin));
         // parameter checking happens first
         Assert.Throws<ArgumentException>("origin", () => fs.Seek(0, ~SeekOrigin.Begin));
         // dispose checking happens first
         fs.Dispose();
         Assert.Throws<ObjectDisposedException>(() => fs.Seek(fs.Position, SeekOrigin.Begin));
     }
 }