Example #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);
     }
 }
Example #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);
     }
 }
Example #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);
     }
 }
Example #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);
            }
        }
Example #5
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));
     }
 }
Example #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);
     }
 }
Example #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
         AssertExtensions.Throws <ArgumentOutOfRangeException>("value", () => fs.Position = -1);
         // dispose checking happens first
         fs.Dispose();
         Assert.Throws <ObjectDisposedException>(() => fs.Position = 1);
     }
 }
Example #8
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));
     }
 }