Conversation
|
@fgreinacher this partly implicitly reverts a change that you made here. In #899, we noticed that the behaviour of |
siprbaum
left a comment
There was a problem hiding this comment.
There are several aspects not checked or which needs to be changed, see the inline comments
tests/System.IO.Abstractions.TestingHelpers.Tests/MockFileSystemTests.cs
Outdated
Show resolved
Hide resolved
Test is renamed from MockFileInfo_Exists_ShouldReturnCachedData to MockFileInfo_Exists_LazyLoadsData, and now checks that the lazy-loading in MockFileInfo works correctly. Co-authored-by: Peter Baumann <peter.baumann@gmail.com>
`Refresh()` needs to be called in the Arrange phase, so that the data is not simply lazy-loaded in the assertion case. Explicitly loading MockFileData by calling `Refres()` enforces lazy-loading to be done. Co-authored-by: Peter Baumann <peter.baumann@gmail.com>
siprbaum
left a comment
There was a problem hiding this comment.
Only some minor changes, leaving some breadcrumbs for the next reader of the test methods.
tests/System.IO.Abstractions.TestingHelpers.Tests/MockFileInfoTests.cs
Outdated
Show resolved
Hide resolved
tests/System.IO.Abstractions.TestingHelpers.Tests/MockFileInfoTests.cs
Outdated
Show resolved
Hide resolved
tests/System.IO.Abstractions.TestingHelpers.Tests/MockFileInfoTests.cs
Outdated
Show resolved
Hide resolved
tests/System.IO.Abstractions.TestingHelpers.Tests/MockFileInfoTests.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Peter Baumann <peter.baumann@gmail.com>
|
Thinking aloud, now that I have a little more time for this PR: With this change, we would actually regress in regards to the Can't we fix this regression by simply calling We don't have any tests for the "initalize FileInfo when going through these methods", that is why this change in behavior is not caught by the tests, but propably need them. Willing to go the extra mile? |
If we're speaking .NET 5's
Sooo … the changed behaviour caused by this PR would be a regression to the current
Therefore, we possibly don't need this? |
You need to follow the reading of this method, a few lines below, the To my understanding, this does initialize the cache, following the calls into FileSystemInfo.Init |
|




This moves the initialization of
cachedMockFileDatato the first time that it is actually used. Apparently, this is more closely to how it works in .NET 6.Closes #899