Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Incorrect LastAccessTime & LastWriteTime for directory #839

Open
CzBuCHi opened this issue Apr 29, 2022 · 2 comments
Open

Incorrect LastAccessTime & LastWriteTime for directory #839

CzBuCHi opened this issue Apr 29, 2022 · 2 comments
Labels
area: testinghelpers Issues that address the testing helpers state: ready to pick Issues that are ready for being worked on type: bug Issues that describe misbehaving functionality

Comments

@CzBuCHi
Copy link

CzBuCHi commented Apr 29, 2022

Describe the bug
Mock file system is not storing LastAccessTime & LastWriteTime properties for directories

To Reproduce

var fileSystem = new MockFileSystem();
var info = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\\Parent\\Dir");
info.Create();
info.LastWriteTime = new DateTime(2001, 2, 3);

var c= fileSystem.DirectoryInfo.FromDirectoryName("C:\\Parent");
foreach (var info in parent.EnumerateDirectories()) {
   var thisShouldBeTrue = info.LastAccessTime  == new DateTime(2001, 2, 3);
}

Expected behavior
variable thisShouldBeTrue should be true.

Additional context
class MockFileSystem should have method AddDirectory(string path, MockDirectoryInfo mock) so i can set directory attributes same way as in method AddFile. MockDirectoryInfo is derived from MockFileInfo but with no content (only default ctor) and with attribute FileAttributes.Directory.

@CzBuCHi CzBuCHi added state: needs discussion Issues that need further discussion type: bug Issues that describe misbehaving functionality labels Apr 29, 2022
@fgreinacher
Copy link
Contributor

Sounds useful, maybe @siprbaum you also have an opinion here 😀

@fgreinacher fgreinacher added state: ready to pick Issues that are ready for being worked on area: testinghelpers Issues that address the testing helpers and removed state: needs discussion Issues that need further discussion labels May 6, 2022
@siprbaum
Copy link
Contributor

siprbaum commented May 6, 2022

First, let me adress thispart:

Additional context class MockFileSystem should have method AddDirectory(string path, MockDirectoryInfo mock) so i can set directory attributes same way as in method AddFile. MockDirectoryInfo is derived from MockFileInfo but with no content (only default ctor) and with attribute FileAttributes.Directory.

I think you meant MockDirectoryInfo -> MockDirectoryData and MockFileInfo -> MockFileData.
Adding a method

AddDirectory(string path, MockDirectoryData mock)
                          ^^^^ ...Data not ...Info

could be useful, I believe.

Concerning the automatic LastAccessTime update when enumerating the directroy:

var fileSystem = new MockFileSystem();
var info = fileSystem.DirectoryInfo.FromDirectoryName(@"C:\\Parent\\Dir");
info.Create();
info.LastWriteTime = new DateTime(2001, 2, 3);

var c= fileSystem.DirectoryInfo.FromDirectoryName("C:\\Parent");
foreach (var info in parent.EnumerateDirectories()) {
   var thisShouldBeTrue = info.LastAccessTime  == new DateTime(2001, 2, 3);
}

Expected behavior variable thisShouldBeTrue should be true.

Isn't this also depending on the underlying OS, e.g Linux vs Windows if and when the xxxTimes are updated?
But I have to admit I haven't looked to deeply into it.

So at least this second part sounds more controversial than the first part to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: testinghelpers Issues that address the testing helpers state: ready to pick Issues that are ready for being worked on type: bug Issues that describe misbehaving functionality
Projects
None yet
Development

No branches or pull requests

3 participants