Skip to content

Commit

Permalink
Linux test fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cb-martinsmith committed Aug 21, 2024
1 parent 26773a0 commit dce44b2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 7 additions & 1 deletion tests/DNX.Extensions.Tests/IO/DirectoryInfoTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using DNX.Extensions.Linq;
using FluentAssertions;
using Xunit;
using Xunit.Abstractions;

// ReSharper disable StringLiteralTypo

Expand All @@ -10,9 +11,12 @@ namespace DNX.Extensions.Tests.IO
public class DirectoryInfoExtensionsTests : IDisposable
{
private readonly DirectoryInfo _directoryInfo;
private readonly ITestOutputHelper _outputHelper;

public DirectoryInfoExtensionsTests()
public DirectoryInfoExtensionsTests(ITestOutputHelper outputHelper)
{
_outputHelper = outputHelper;

var directoryPath = Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString());
_directoryInfo = new DirectoryInfo(directoryPath);
_directoryInfo.Create();
Expand Down Expand Up @@ -222,6 +226,8 @@ public void FindDirectories_for_multiple_patterns_with_recursion_finds_expected_
[MemberData(nameof(GetRelativePath_Data))]
public void GetRelativePath_can_extract_relative_path_correctly(string dirName, string relativeToDirName, string expected)
{
_outputHelper.WriteLine($"{Environment.OSVersion.Platform} - Checking DirName: {dirName} -> {relativeToDirName}");

var dirInfo = dirName == null ? null : new DirectoryInfo(dirName);
var relativeToDirInfo = relativeToDirName == null ? null : new DirectoryInfo(relativeToDirName);

Expand Down
10 changes: 7 additions & 3 deletions tests/DNX.Extensions.Tests/IO/FileInfoExtensionsTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ private static string DriveRoot2
[MemberData(nameof(GetRelativeFileName_Data))]
public void GetRelativeFileName_can_extract_relative_filename_correctly(string fileName, string dirName, string expected)
{
outputHelper.WriteLine($"Checking FileName: {fileName} -> {dirName}");
outputHelper.WriteLine($"{Environment.OSVersion.Platform} - Checking FileName: {fileName} -> {dirName}");

var fileInfo = new FileInfo(fileName);
var dirInfo = new DirectoryInfo(dirName);
Expand All @@ -46,7 +46,7 @@ public void GetRelativeFileName_can_extract_relative_filename_correctly(string f
[MemberData(nameof(GetRelativeFilePath_Data))]
public void GetRelativeFilePath_can_extract_relative_path_correctly(string fileName, string dirName, string expected)
{
outputHelper.WriteLine($"Checking FileName: {fileName} -> {dirName}");
outputHelper.WriteLine($"{Environment.OSVersion.Platform} - Checking FileName: {fileName} -> {dirName}");

var fileInfo = new FileInfo(fileName);
var dirInfo = new DirectoryInfo(dirName);
Expand Down Expand Up @@ -129,7 +129,11 @@ public static TheoryData<string, string, string> GetRelativeFileName_Data()
{ Path.Combine(DriveRoot1, "Temp", "abcdefg", "dir3", "file1.tf"), Path.Combine(DriveRoot1, "Temp", "abcdefg"), Path.Combine("dir3", "file1.tf") },
{ Path.Combine(DriveRoot1, "Temp", "abcdefg", "dir3", "file1.tf"), Path.Combine(DriveRoot1, "Temp", "abcdefg", "dir3"), "file1.tf" },
{ Path.Combine(DriveRoot1, "Temp", "abcdefg", "dir3", "file1.tf"), Path.Combine(DriveRoot1, "Temp", "abcdefg", "dir3"), "file1.tf" },
{ Path.Combine(DriveRoot1, "Temp", "folder1", "file.txt"), Path.Combine(DriveRoot2, "folder2"), Path.Combine(DriveRoot1, "Temp", "folder1", "file.txt") },
{ Path.Combine(DriveRoot1, "Temp", "folder1", "file.txt"), Path.Combine(DriveRoot2, "folder2"),
Configuration.EnvironmentConfig.IsLinuxStyleFileSystem
? Path.Combine("..", "..", DriveRoot1, "Temp", "folder1", "file.txt")
: Path.Combine(DriveRoot1, "Temp", "folder1", "file.txt")
},
{ Path.Combine(DriveRoot1, "Temp", "folder1", "file.txt"), Path.Combine(DriveRoot1, "Temp", "folder2"), Path.Combine("..", "folder1", "file.txt") },
};
}
Expand Down

0 comments on commit dce44b2

Please sign in to comment.