-
Notifications
You must be signed in to change notification settings - Fork 266
Closed
Labels
area: testinghelpersIssues that address the testing helpersIssues that address the testing helpersstate: ready to pickIssues that are ready for being worked onIssues that are ready for being worked ontype: enhancementIssues that propose new functionalityIssues that propose new functionality
Description
Is your feature request related to a problem? Please describe.
I want to test a functionality that relies on the "GetLastWriteTimeUtc" method to detect when a file was last changed.
This property in MockFileSystem only returns a fixed value "2010-02-03 20:00:00"
Describe the solution you'd like
MockFileSystem should set the creation, last access and last write times and return the correct values.
Ideally you would also provide an optional callback or property to set, so that I can even mock the time that is stored.
Describe alternatives you've considered
None, as the times are not even tracked anywhere internally.
Additional context
I would like e.g. the following unit test to pass:
[Theory]
[WithAutoData]
public void GetCreationTimeUtc_ShouldBeSet(string file)
{
var now = DateTime.UtcNow;
var sut = new MockFileSystem();
sut.File.WriteAllText("foo.txt", "xyz");
var result = sut.File.GetCreationTimeUtc("foo.txt");
result.Kind.Should().Be(DateTimeKind.Utc);
result.Should().BeOnOrAfter(now);
}skrysm
Metadata
Metadata
Assignees
Labels
area: testinghelpersIssues that address the testing helpersIssues that address the testing helpersstate: ready to pickIssues that are ready for being worked onIssues that are ready for being worked ontype: enhancementIssues that propose new functionalityIssues that propose new functionality