-
Notifications
You must be signed in to change notification settings - Fork 256
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set Creation, LastAccess and LastWrite time for files (#875)
Implements #872 Adjust `CreationTime`, `LastAccessTime` and `LastWriteTime` when interacting with files in the `MockFileSystem`. Provides a means to mock the used DateTime by calling e.g. ```csharp var fixedTime = new DateTime(2022, 01, 01); var fileSystem = new MockFileSystem().MockTime(() => fixedTime); // All times will now be set to the fixedTime. ``` Implementes the following logic in MockFile: *All these cases are covered by unit tests in MockFileAdjustTimesTest* - When creating files CreationTime, LastAccessTime and LastWriteTime are set to the current time - When changing files (`WriteAllText`, `WriteAllBytes`, `AppendAllText`, `OpenWrite`, `Open`) LastAccessTime and LastWriteTime are set to the current time CreationTime is left unchanged - When reading files (`ReadAllText`, `ReadAllLines`, `ReadAllBytes`, `OpenRead`) LastAccessTime is set to the current time CreationTime and LastWriteTime are left unchanged - When setting attributes or ACLs (`SetAttributes`, `SetAccessControl`) LastAccessTime is set to the current time CreationTime and LastWriteTime are left unchanged - When moving files (`Move`) LastAccessTime is set to the current time CreationTime and LastWriteTime are left unchanged - When copying files (`Copy`) CreationTime and LastAccessTime of the copied file in the destination directory is set to the current time LastWriteTime and all times of the source file are left unchanged
- Loading branch information
Showing
18 changed files
with
703 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.