Uh oh!
There was an error while loading. Please reload this page.
fix: Refresh FileInfo & DirectoryInfo after adding to MockFileSystem - #984
Conversation
Modify the `IFileInfo` and `IDirectoryInfo` overloads of `AddFile()`, `AddEmptyFile()`, or `AddDirectory()` in `MockFileSystem`, to call `Refresh()` on those objects after the paths they refer to are created.
47cfa07 to
d3e823cComparercdailey
commented
May 10, 2023
Latest push has no changes; just rebased to pull in latest on |
…19.2.26 (#306) [](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [TestableIO.System.IO.Abstractions](https://togithub.com/TestableIO/System.IO.Abstractions) | nuget | patch | `19.2.22` -> `19.2.26` | --- ### Release Notes <details> <summary>TestableIO/System.IO.Abstractions</summary> ### [`v19.2.26`](https://togithub.com/TestableIO/System.IO.Abstractions/releases/tag/v19.2.26) ##### What's Changed - fix: Refresh FileInfo & DirectoryInfo after adding to MockFileSystem by [@​rcdailey](https://togithub.com/rcdailey) in [https://github.com/TestableIO/System.IO.Abstractions/pull/984](https://togithub.com/TestableIO/System.IO.Abstractions/pull/984) **Full Changelog**: TestableIO/System.IO.Abstractions@v19.2.25...v19.2.26 ### [`v19.2.25`](https://togithub.com/TestableIO/System.IO.Abstractions/releases/tag/v19.2.25) #### What's Changed - chore(deps): update dependency githubactionstestlogger to v2.1.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/986](https://togithub.com/TestableIO/System.IO.Abstractions/pull/986) - chore(deps): update dependency nerdbank.gitversioning to v3.6.132 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/987](https://togithub.com/TestableIO/System.IO.Abstractions/pull/987) - feat: Add Flush(bool) to FileSystemStream. by [@​gregington](https://togithub.com/gregington) in [https://github.com/TestableIO/System.IO.Abstractions/pull/985](https://togithub.com/TestableIO/System.IO.Abstractions/pull/985) **Full Changelog**: TestableIO/System.IO.Abstractions@v19.2.22...v19.2.25 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/Testably/Testably.Abstractions). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43OS4xIiwidXBkYXRlZEluVmVyIjoiMzUuNzkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
…19.2.26 (#306) [](https://renovatebot.com) This PR contains the following updates: | Package | Type | Update | Change | |---|---|---|---| | [TestableIO.System.IO.Abstractions](https://togithub.com/TestableIO/System.IO.Abstractions) | nuget | patch | `19.2.22` -> `19.2.26` | --- ### Release Notes <details> <summary>TestableIO/System.IO.Abstractions</summary> ### [`v19.2.26`](https://togithub.com/TestableIO/System.IO.Abstractions/releases/tag/v19.2.26) ##### What's Changed - fix: Refresh FileInfo & DirectoryInfo after adding to MockFileSystem by [@​rcdailey](https://togithub.com/rcdailey) in [https://github.com/TestableIO/System.IO.Abstractions/pull/984](https://togithub.com/TestableIO/System.IO.Abstractions/pull/984) **Full Changelog**: TestableIO/System.IO.Abstractions@v19.2.25...v19.2.26 ### [`v19.2.25`](https://togithub.com/TestableIO/System.IO.Abstractions/releases/tag/v19.2.25) #### What's Changed - chore(deps): update dependency githubactionstestlogger to v2.1.0 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/986](https://togithub.com/TestableIO/System.IO.Abstractions/pull/986) - chore(deps): update dependency nerdbank.gitversioning to v3.6.132 by [@​renovate](https://togithub.com/renovate) in [https://github.com/TestableIO/System.IO.Abstractions/pull/987](https://togithub.com/TestableIO/System.IO.Abstractions/pull/987) - feat: Add Flush(bool) to FileSystemStream. by [@​gregington](https://togithub.com/gregington) in [https://github.com/TestableIO/System.IO.Abstractions/pull/985](https://togithub.com/TestableIO/System.IO.Abstractions/pull/985) **Full Changelog**: TestableIO/System.IO.Abstractions@v19.2.22...v19.2.25 </details> --- ### Configuration 📅 **Schedule**: Branch creation - At any time (no schedule defined), Automerge - At any time (no schedule defined). 🚦 **Automerge**: Disabled by config. Please merge this manually once you are satisfied. ♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the rebase/retry checkbox. 🔕 **Ignore**: Close this PR and you won't be reminded about this update again. --- - [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check this box --- This PR has been generated by [Mend Renovate](https://www.mend.io/free-developer-tools/renovate/). View repository job log [here](https://app.renovatebot.com/dashboard#github/Testably/Testably.Abstractions). <!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzNS43OS4xIiwidXBkYXRlZEluVmVyIjoiMzUuNzkuMSIsInRhcmdldEJyYW5jaCI6Im1haW4ifQ==--> Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
This is addressed in release v19.2.26. |
rcdailey
commented
May 20, 2023
@fgreinacher Thanks for merging this, I really appreciate it! One thing I'm noticing, is that this doesn't cover all use cases. For example, if there are other Do you have any insight here you can share? This is somewhat a pain point I only experience in unit tests, having to manually refresh file info objects. Thanks for any feedback you can share. |
vbreuss
commented
May 21, 2023
@rcdailey :
The following test is successful on the real file system on all platforms: [Fact]publicvoidCreate_ShouldRefreshExistsCacheForCurrentItem_ExceptOnNetFramework(){stringpath="file-path-to-check",IFileInfo sut1 =FileSystem.FileInfo.New(path);IFileInfosut2=FileSystem.FileInfo.New(path);IFileInfosut3=FileSystem.FileInfo.New(path);sut1.Exists.Should().BeFalse();sut2.Exists.Should().BeFalse();// Do not call Exists for `sut3`usingFileSystemStreamstream=sut1.Create();if(Test.IsNetFramework){sut1.Exists.Should().BeFalse();sut2.Exists.Should().BeFalse();sut3.Exists.Should().BeFalse();}else{sut1.Exists.Should().BeTrue();sut2.Exists.Should().BeFalse();sut3.Exists.Should().BeTrue();}FileSystem.File.Exists(path).Should().BeTrue();}For reference see Testably/Testably.Abstractions#313 |
Modify the
IFileInfoandIDirectoryInfooverloads ofAddFile(),AddEmptyFile(), orAddDirectory()inMockFileSystem, to callRefresh()on those objects after the paths they refer to are created.