Beispiel #1
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);
     }
 }
Beispiel #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);
     }
 }
Beispiel #3
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);
     }
 }
Beispiel #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);
            }
        }
Beispiel #5
0
 public void SetLengthUnseekableThrows()
 {
     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));
     }
 }
Beispiel #6
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);
     }
 }
Beispiel #7
0
 public void SetLengthUnseekableThrows()
 {
     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));
     }
 }
Beispiel #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
         Assert.Throws <ArgumentOutOfRangeException>("value", () => fs.Position = -1);
         // dispose checking happens first
         fs.Dispose();
         Assert.Throws <ObjectDisposedException>(() => fs.Position = 1);
     }
 }