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
8 changes: 4 additions & 4 deletions FileSystem/PathIOLinux.cs
Original file line number Diff line number Diff line change
Expand Up @@ -200,13 +200,13 @@ private static string SeparatorWrapper(Func<string, string> pathMethod, string p

var unixResult = pathMethod(convertedToUnix);

if (returnWithRoot)
if (returnWithRoot && unixResult != null)
{
finalResult = removedWindowsRoot[0] + ":" + unixResult.Replace(LinuxSeparator, WindowsSeparator);
}
else
{
finalResult = unixResult.Replace(LinuxSeparator, WindowsSeparator);
finalResult = unixResult?.Replace(LinuxSeparator, WindowsSeparator);
}
}
else
Expand All @@ -215,12 +215,12 @@ private static string SeparatorWrapper(Func<string, string> pathMethod, string p
{
var convertedToUnix = path.Replace(WindowsSeparator, LinuxSeparator);
var unixResult = pathMethod(convertedToUnix);
finalResult = unixResult.Replace(LinuxSeparator, WindowsSeparator);
finalResult = unixResult?.Replace(LinuxSeparator, WindowsSeparator);
}
else
{
finalResult = pathMethod(path);
finalResult = finalResult.Replace(WindowsSeparator, LinuxSeparator);
finalResult = finalResult?.Replace(WindowsSeparator, LinuxSeparator);
}
}

Expand Down
19 changes: 6 additions & 13 deletions FileSystemTests/PathIOLinuxTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,10 +97,8 @@ public void GetFullPathTest_NoSubFolder_Windows()
PathIOLinux linux = new PathIOLinux();
var result = linux.GetFullPath(pathToTest);

Assert.IsTrue(result.Contains(":"), "Does not have the drive letter root");
bool forNet472 = result.EndsWith("FileSystemTests/bin/Debug/net472/Skyline.DataMiner.CICD.FileSystem.dll");
bool for6 = result.EndsWith("FileSystemTests/bin/Debug/net6.0/Skyline.DataMiner.CICD.FileSystem.dll");
Assert.IsTrue(for6 || forNet472, "Does not have the full path: " + result);
result.Should().NotBeNullOrWhiteSpace();
result.Should().ContainAll(":", "FileSystemTests/bin/Debug/net", "/Skyline.DataMiner.CICD.FileSystem.dll");
}

[TestMethod]
Expand All @@ -111,11 +109,8 @@ public void GetFullPathTest_WithSubFolder_Linux()
PathIOLinux linux = new PathIOLinux();
var result = linux.GetFullPath(pathToTest);

Assert.IsTrue(result.Contains(":"), "Does not have the drive letter root");

bool forNet472 = result.EndsWith("FileSystemTests/bin/Debug/net472/SubFolderTest/TestFile.xml");
bool for6 = result.EndsWith("FileSystemTests/bin/Debug/net6.0/SubFolderTest/TestFile.xml");
Assert.IsTrue(for6 || forNet472, "Does not have the full path." + result);
result.Should().NotBeNullOrWhiteSpace();
result.Should().ContainAll(":", "FileSystemTests/bin/Debug/net", "/SubFolderTest/TestFile.xml");
}

[TestMethod]
Expand All @@ -126,10 +121,8 @@ public void GetFullPathTest_WithSubFolder_Windows()
PathIOLinux linux = new PathIOLinux();
var result = linux.GetFullPath(pathToTest);

Assert.IsTrue(result.Contains(":"), "Does not have the drive letter root");
bool forNet472 = result.EndsWith("FileSystemTests\\bin\\Debug\\net472\\SubFolderTest\\TestFile.xml");
bool for6 = result.EndsWith("FileSystemTests\\bin\\Debug\\net6.0\\SubFolderTest\\TestFile.xml");
Assert.IsTrue(for6 || forNet472, "Does not have the full path." + result);
result.Should().NotBeNullOrWhiteSpace();
result.Should().ContainAll(":", "FileSystemTests\\bin\\Debug\\net", "\\SubFolderTest\\TestFile.xml");
}

[TestMethod]
Expand Down