Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
4 changes: 3 additions & 1 deletion src/System.IO.Abstractions.TestingHelpers/MockFileSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,9 @@ public void MoveDirectory(string sourcePath, string destPath)
foreach (var path in affectedPaths)
{
var newPath = StringOperations.Replace(path, sourcePath, destPath);
files[newPath] = files[path];
var entry = files[path];
entry.Path = newPath;
files[newPath] = entry;
files.Remove(path);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Text;
Expand Down Expand Up @@ -250,6 +249,20 @@ public void MockFileSystem_AddFilesFromEmbeddedResource_ShouldAddAllTheFiles()
Assert.Contains(XFS.Path(@"C:\SecondTestFile.txt"), fileSystem.AllFiles.ToList());
}

[Test]
public void MockFileSystem_MoveDirectoryAndFile_ShouldMoveCorrectly()
{
var fileSystem = new MockFileSystem();
fileSystem.AddFile(XFS.Path(@"C:\source\project.txt"), string.Empty);
fileSystem.AddFile(XFS.Path(@"C:\source\subdir\other.txt"), string.Empty);

fileSystem.Directory.Move(XFS.Path(@"C:\source"), XFS.Path(@"C:\target"));
fileSystem.File.Move(XFS.Path(@"C:\target\project.txt"), XFS.Path(@"C:\target\proj.txt"));

var expected = new[] { XFS.Path(@"C:\target\proj.txt"), XFS.Path(@"C:\target\subdir\other.txt") };
CollectionAssert.AreEquivalent(expected, fileSystem.AllFiles);
}

[Test]
public void MockFileSystem_RemoveFile_RemovesFiles()
{
Expand Down