Repository navigation
MockFileSystem created file don't exist #822
Description
Activity
- addedstate: needs discussionIssues that need further discussionIssues that need further discussiontype: bugIssues that describe misbehaving functionalityIssues that describe misbehaving functionality
on Mar 11, 2022 @fgreinacher there is difference in output for FileSystem and MockFileSystem.
public static void Main(string[] args) { IFileSystem realFileSystem = new FileSystem(); IFileSystem mockFileSystem = new MockFileSystem(); Console.WriteLine($"Real file exist: {TestFileSystem(realFileSystem)}"); Console.WriteLine($"Fake file exist: {TestFileSystem(mockFileSystem)}"); Console.ReadLine(); } private static bool TestFileSystem(IFileSystem fileSystem) { IFileInfo fileInfo = null; try { fileInfo = fileSystem.FileInfo.FromFileName("testFile.txt"); using (Stream fs = fileInfo.Create()) fs.WriteByte(0); return fileInfo.Exists; } finally { if (fileInfo != null && fileInfo.Exists) fileInfo.Delete(); } }
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.
- FileSystem:
C:\Users\Andrzej Ochodek\source\repos\FileSystemAbstractionTest\FileSystemAbstractionTest\bin\Debug\testFile.txt- MockFileSystem:
C:\testFile.txtAre there any updates about this bug?
Are there any updates about this bug?
Sorry, I lost track of this one.
Starts from version 16.0.8 FileSystem return True and MockFileSystem return False.
In latest version 16.1.23 result is same.Do I understand correctly that everything is working as expected in 16.1.23?
Additional to that, there is difference in paths for FileSystem and MockFileSystem.
That's expected/by-design, because the MockFileSystem is initialized with the root directory (
/on Unix,C:\on Windows).Do I understand correctly that everything is working as expected in 16.1.23?
Unfortunately no. Real file system returns true and mock returns false.
That's expected/by-design, because the MockFileSystem is initialized with the root directory (
/on Unix,C:\on Windows).Ok.
- added a commit that references this issue
on Mar 22, 2022 I created a pull request to fix it, see #828
Reacted by Florian GreinacherThis is addressed in release v16.1.24.
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
Version 16.0.7 return True
Version 16.0.8 return False
Expected behavior
Property Exist should return True