Commit b2cca2c
committed
fix: MockFileInfo.Exists no longer returns stale cached data
In 5216e0d ("fix: make Mock{File,Directory}Info cache file attributes
(TestableIO#791)", 2022-01-09) a cache of the MockFileData was introduced, to mimic
the behaviour that a FileInfo object will not read the data from disk
but instead also remembers its internal state, which can be updated by
calling its `Refresh` method. This internal (or cached state) is
invalidated when calling the methods `Create`, `Delete` and `MoveTo`
methods, as can be seen by the `Invalidate` calls in
https://github.com/dotnet/runtime/blob/8766a1cf1ed6c3b69cef50154139699b72fb52c5/src/libraries/System.Private.CoreLib/src/System/IO/FileInfo.cs
In the PR TestableIO#791 it was overlooked to also invalidate the cached data
in these methods. This commit fixes it by invalidating the cached data
only for `Create`, `CreateText` and `Delete`.
The two `MoveTo` variants are not changed as I could not manage to find
any behaviour which is broken without that invalidation.
Most likely reason is that the MockFileData is updated to represent the
destination file ofter the move, so invalidating is not needed.
Fixes TestableIO#8221 parent 74ef961 commit b2cca2c
File tree
2 files changed
+50
-2
lines changed- src/System.IO.Abstractions.TestingHelpers
- tests/System.IO.Abstractions.TestingHelpers.Tests
2 files changed
+50
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
| 31 | + | |
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| |||
221 | 222 | | |
222 | 223 | | |
223 | 224 | | |
224 | | - | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
225 | 228 | | |
226 | 229 | | |
227 | 230 | | |
228 | 231 | | |
229 | 232 | | |
230 | | - | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
231 | 236 | | |
232 | 237 | | |
233 | 238 | | |
| |||
Lines changed: 43 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
750 | 750 | | |
751 | 751 | | |
752 | 752 | | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
| 763 | + | |
| 764 | + | |
| 765 | + | |
| 766 | + | |
| 767 | + | |
| 768 | + | |
| 769 | + | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
753 | 796 | | |
754 | 797 | | |
755 | 798 | | |
| |||
0 commit comments