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
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public override string GetFullPath(string path)
// unc paths need at least two segments, the others need one segment
var isUnixRooted = mockFileDataAccessor.StringOperations.StartsWith(
mockFileDataAccessor.Directory.GetCurrentDirectory(),
string.Format(CultureInfo.InvariantCulture, "{0}", DirectorySeparatorChar));
"/");

var minPathSegments = isUnc
? 2
Expand Down Expand Up @@ -121,7 +121,7 @@ public override string GetFullPath(string path)

if (isUnixRooted && !isUnc)
{
fullPath = DirectorySeparatorChar + fullPath;
fullPath = "/" + fullPath;
}
else if (isUnixRooted)
{
Expand Down Expand Up @@ -156,4 +156,4 @@ public override string GetTempFileName()
/// <inheritdoc />
public override string GetTempPath() => defaultTempDirectory;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,28 @@ public void MockDirectoryInfo_GetFiles_ShouldWorkWithUNCPath()
Assert.AreEqual(fileName, files[0].FullName);
}

[Test]
[WindowsOnly(WindowsSpecifics.UNCPaths)]
public void MockDirectoryInfo_GetFiles_ShouldWorkWithUNCPath_WhenCurrentDirectoryIsUnc()
{
var fileName = XFS.Path(@"\\unc\folder\file.txt");
var directoryName = XFS.Path(@"\\unc\folder");
// Arrange
var fileSystem = new MockFileSystem(new Dictionary<string, MockFileData>
{
{fileName, ""}
});

fileSystem.Directory.SetCurrentDirectory(directoryName);

var directoryInfo = new MockDirectoryInfo(fileSystem, directoryName);

// Act
var files = directoryInfo.GetFiles();

// Assert
Assert.AreEqual(fileName, files[0].FullName);
}

[Test]
public void MockDirectoryInfo_FullName_ShouldReturnFullNameWithoutIncludingTrailingPathDelimiter()
Expand Down