TestableIO / System.IO.Abstractions

Just like System.Web.Abstractions, but for System.IO. Yay for testable IO access!
http://www.nuget.org/packages/System.IO.Abstractions
MIT License
1.52k stars 256 forks source link

not existing MockFileInfo Attributes #829

Closed jgasiorowski closed 2 years ago

jgasiorowski commented 2 years ago

I am not sure if that is a bug because I don't know how much this library aims to simulate behaviours of real file system so I wanted to ask about attibutes. In microsoft docs it is said that if file does not exist then attributes is set to (FileAttributes)(-1). FileNotFoundException or DirectoryNotFoundException can only be thrown when setting the value.

But this library is throwing FileNotFoundException on reading attributes instead of returning -1 value.

Steps to reproduce the behavior:

  1. Mock FileSystem with TestHelpers
  2. use fs.FileInfo.FromFileName(@"x:\not-existing\path")
  3. Try to check Attributes property

Expected behavior Value -1 should be returned

fgreinacher commented 2 years ago

Thanks for reporting this! We generally try to mirror the behavior of the real filesystem as long as everything stays maintainable.