**Describe the bug** From version 16.0.8 of **System.IO.Abstractions.TestingHelpers** when I create new file in **MockFileSystem** property **Exist** return false. **To Reproduce** ```cs IFileSystem fileSystem = new MockFileSystem(); IFileInfo fileInfo = fileSystem.FileInfo.FromFileName("testFile.txt"); using (Stream fs = fileInfo.Create()) { fs.WriteByte(0); } Console.WriteLine($"File exist: {fileInfo.Exists}"); ``` Version 16.0.7 return **True** Version 16.0.8 return **False** **Expected behavior** Property Exist should return **True**
Activity
fgreinacher commentedon Mar 11, 2022
@milten89 Thanks for taking the time to report this!
The behavior of
MockFileInfohas changed in #791 to mirror the behavior of the real file system (see #661).Could you please check how your code behaves with the real file system?
milten89 commentedon Mar 15, 2022
@fgreinacher there is difference in output for FileSystem and MockFileSystem.
Starts from version 16.0.8 FileSystem return True and MockFileSystem return False.
In latest version 16.1.23 result is same.
Additional to that, there is difference in paths for FileSystem and MockFileSystem.
milten89 commentedon Mar 22, 2022
Are there any updates about this bug?
fgreinacher commentedon Mar 22, 2022
Sorry, I lost track of this one.
Do I understand correctly that everything is working as expected in 16.1.23?
That's expected/by-design, because the MockFileSystem is initialized with the root directory (
/on Unix,C:\on Windows).milten89 commentedon Mar 22, 2022
Unfortunately no. Real file system returns true and mock returns false.
Ok.
fix: MockFileInfo.Exists no longer returns stale cached data
siprbaum commentedon Mar 22, 2022
I created a pull request to fix it, see #828
github-actions commentedon Mar 23, 2022
This is addressed in release v16.1.24.