-
-
Notifications
You must be signed in to change notification settings - Fork 10
Description
I've recreated the Microsoft.Extensions.FileProviders.PhysicalFileProvider and use IFileSystem instead of System.IO to mock my service.
To ensure my classes work exactly like the PhysicalFileProvider I also copied the tests. One of the tests fails using the MockFileSystem, but not using the real FileSystem.
Test: UsePollingFileWatcher_UseActivePolling_HasChanged_SymbolicLink_TargetChanged for linkWasBroken is true.
The test with linkWasBroken is false only succeed because it reads file1Path instead of file2Path and file1Path is created, so it's a false positive.
This happens because in the (Custom|Physical)PollingFileChangeToken the (I)FileInfo is cached and only refreshed using the method Refresh().
Afaik this happens because the mocked FileInfo is detached from the storage and thus not updated.
Actual Behavior: detached FileInfo is not updated
Expected Behavior: detached FileInfo is reattached and updated
Possible Solution: Inside IFileInfo.Refresh() check the file system if the file is there and copy the infos