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)); } }
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)); } }