-
Notifications
You must be signed in to change notification settings - Fork 267
Closed
Description
when having a mocked file in a mockfilesystem, and readfing from it mutates the LastWriteTime of the mocked file.
Here is an XUnit fact which can be used as a regression test to verify the problem, and the solution.
[Fact]
public void ReadingFromAFileDoesNotOverwriteIt() {
// Arrange
var fs = new MockFileSystem();
var filename = @"C:\TestData\test.txt";
var file = new MockFileData(@"This is just a test file
with test contents, which are not modified!");
var lastmod = new DateTime(2012, 03, 21);
file.LastWriteTime = lastmod;
fs.AddFile(filename, file);
// Act
using (var reader = fs.File.OpenText(filename)) {
var firstline = reader.ReadLine();
}
// Assert
Assert.Equal(lastmod, fs.FileInfo.FromFileName(filename).LastWriteTime);
}
Metadata
Metadata
Assignees
Labels
No labels