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.51k stars 254 forks source link

Allow selection of os dependent FS semantics #1091

Closed markusschaber closed 7 months ago

markusschaber commented 7 months ago

Is your feature request related to a problem? Please describe. Our CI pipeline currently is Linux only, but we also want to unit test our code which handles windows paths. On the other hand, our dev machines are mostly windows, so it's hard to test/debug Linux specific path handling.

Describe the solution you'd like An option when constructing the MockFileSystem to choose to emulate Window/Linux/MacOS behaviour (the default would be determined from the current platform, as it is now.)

Describe alternatives you've considered I tried the Testably.Abstractions Mock File System, they also don't support choosing of the semantics to emulate.

Additional context

vbreuss commented 7 months ago

Discussion with some arguments started in https://github.com/Testably/Testably.Abstractions/issues/460.

markusschaber commented 7 months ago

Yeah, sorry for distracting you.

I found that the Testably mock file system might be the better way to go, as the TestableIO TestHelpers implementation has lots of small problems and bugs where it shows different behavior than the "real" File System (e. G. IDirectoryInfo.Exists returns true when the path points to a file, etc.) - we have some hundred unit tests which fail or show otherwise strange behavior when running against System.IO.Abstractions.TestingHelpers.MockFileSystem while they work fine against the real System.IO.Abstractions.FileSystem, both on Windows and Linux.

I'm waiting for one of our internal dependencies to update their System.IO.Abstractions to a current release, which allows me to also upgrade, and thus use Testably. (Currently, I get strange errors when I update my code as some types have moved assemblies between System.IO.Abstractions 16.x and TestableIO 20.x.)

Feel free to close the issue on this project. Thank you very much.

Edit: Our tests have been with System.IO.Abstractions version 16.x, which had been pulled in due to a 3rd dependency which has not been updated. It looks like some of the problems have already been fixed with System.IO.Abstractions 20.x. My snarky remark above should not be considered a rant about the quality of this project. :-(

vbreuss commented 7 months ago

Will be implemented in https://github.com/Testably/Testably.Abstractions/issues/460.