コード例 #1
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));
     }
 }
コード例 #2
0
ファイル: Seek.cs プロジェクト: noahfalk/corefx
 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));
     }
 }