Skip to content
Draft
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions src/System.IO.Abstractions.TestingHelpers/MockFileInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class MockFileInfo : FileInfoBase
private readonly string originalPath;
private MockFileData cachedMockFileData;
private MockFile mockFile;
private bool refreshOnNextRead;
private bool refreshOnNextRead = true;

/// <inheritdoc />
public MockFileInfo(IMockFileDataAccessor mockFileSystem, string path) : base(mockFileSystem?.FileSystem)
Expand All @@ -21,7 +21,6 @@ public MockFileInfo(IMockFileDataAccessor mockFileSystem, string path) : base(mo
this.originalPath = path ?? throw new ArgumentNullException(nameof(path));
this.path = mockFileSystem.Path.GetFullPath(path);
this.mockFile = new MockFile(mockFileSystem);
Refresh();
}

/// <inheritdoc />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -793,21 +793,6 @@ public void MockFileInfo_Replace_ShouldThrowIfDestinationFileDoesNotExist()
Assert.Throws<FileNotFoundException>(() => fileInfo.Replace(path2, null));
}

[Test]
public void MockFileInfo_Exists_ShouldReturnCachedData()
{
// Arrange
var fileSystem = new MockFileSystem();
var path1 = XFS.Path(@"c:\temp\file1.txt");
var fileInfo = fileSystem.FileInfo.FromFileName(path1);

// Act
fileSystem.AddFile(path1, new MockFileData("1"));

// Assert
Assert.IsFalse(fileInfo.Exists);
}

[Test]
public void MockFileInfo_Exists_ShouldUpdateCachedDataOnRefresh()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,21 @@ public void MockFileSystem_AddFile_ShouldMatchCapitalization_PartialMatch_Furthe
Assert.Contains(XFS.Path(@"C:\LOUD\SUBLOUD\new\SUBDirectory"), fileSystem.AllDirectories.ToList());
}

[Test]
public void MockFileSystem_AddFile_ShouldMarkFileAsExisting()
{
// Arrange
var fileSystem = new MockFileSystem();
var path1 = XFS.Path(@"c:\temp\file1.txt");
var fileInfo = fileSystem.FileInfo.FromFileName(path1);

// Act
fileSystem.AddFile(path1, new MockFileData("1"));

// Assert
Assert.IsTrue(fileInfo.Exists);
}

[Test]
public void MockFileSystem_AddFileFromEmbeddedResource_ShouldAddTheFile()
{
Expand Down