Updates file system unit tests to account for macOS platform

This commit is contained in:
BinaryAlley committed 2024-11-06 19:47:26 +02:00
1 parent 09928047d0
commit 4d5416ae3f
11 files changed
+142 -142

No files matched your search

@@ -32,7 +32,7 @@ public class GetDirectoriesEndpointTests : IClassFixture<LuminaApiFactory>
PropertyNameCaseInsensitive = true,
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
};
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
/// <summary>
/// Initializes a new instance of the <see cref="GetDirectoriesEndpointTests"/> class.
@@ -103,8 +103,8 @@ public class GetDirectoriesEndpointTests : IClassFixture<LuminaApiFactory>
DirectoryResponse firstDirectory = directories!.First();
firstDirectory.Name.Should().Be((s_isLinux ? "." : string.Empty) + "NestedDirectory_2");
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isLinux ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar));
firstDirectory.Name.Should().Be((s_isUnix ? "." : string.Empty) + "NestedDirectory_2");
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar));
directories!.Count.Should().Be(1); // only directories
}
finally
@@ -33,7 +33,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
PropertyNameCaseInsensitive = true,
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
};
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);;
/// <summary>
/// Initializes a new instance of the <see cref="GetDirectoryTreeEndpointTests"/> class.
@@ -69,7 +69,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
treeNodes!.Should().NotBeEmpty();
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
if (s_isLinux) // on UNIX, the leading slash is considered "the drive", the root location - add it!
if (s_isUnix) // on UNIX, the leading slash is considered "the drive", the root location - add it!
pathSegments = ["/", .. pathSegments];
// recursively validate the tree structure
void ValidateNode(FileSystemTreeNodeResponse node, int depth)
@@ -140,7 +140,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
treeNodes!.Should().NotBeEmpty();
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
if (s_isLinux) // on UNIX, the leading slash is considered "the drive", the root location - add it!
if (s_isUnix) // on UNIX, the leading slash is considered "the drive", the root location - add it!
pathSegments = ["/", .. pathSegments];
// recursively validate the tree structure
@@ -173,7 +173,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
else if (childNode.ItemType is FileSystemItemType.File)
{
childNode.Children.Should().BeEmpty(); // files should not have children
childNode.Name.Should().BeOneOf((s_isLinux ? "." : string.Empty) + "TestFile_1.txt", "TestFile_2.txt");
childNode.Name.Should().BeOneOf((s_isUnix ? "." : string.Empty) + "TestFile_1.txt", "TestFile_2.txt");
}
}
}
@@ -215,7 +215,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
treeNodes.Should().AllSatisfy(node => node.ItemType.Should().BeOneOf(FileSystemItemType.Directory, FileSystemItemType.Root));
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
if (s_isLinux) // on UNIX, the leading slash is considered "the drive", the root location - add it!
if (s_isUnix) // on UNIX, the leading slash is considered "the drive", the root location - add it!
pathSegments = ["/", .. pathSegments];
// recursively validate the tree structure
@@ -278,7 +278,7 @@ public class GetDirectoryTreeEndpointTests : IClassFixture<LuminaApiFactory>
treeNodes.Should().AllSatisfy(node => node.ItemType.Should().BeOneOf(FileSystemItemType.Directory, FileSystemItemType.Root));
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
if (s_isLinux) // on UNIX, the leading slash is considered "the drive", the root location - add it!
if (s_isUnix) // on UNIX, the leading slash is considered "the drive", the root location - add it!
pathSegments = ["/", .. pathSegments];
// recursively validate the tree structure
@@ -33,7 +33,7 @@ public class GetTreeDirectoriesEndpointTests : IClassFixture<LuminaApiFactory>
PropertyNameCaseInsensitive = true,
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
};
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
/// <summary>
/// Initializes a new instance of the <see cref="GetTreeDirectoriesEndpointTests"/> class.
@@ -144,8 +144,8 @@ public class GetTreeDirectoriesEndpointTests : IClassFixture<LuminaApiFactory>
FileSystemTreeNodeResponse firstNode = treeNodes!.First();
firstNode.Name.Should().Be((s_isLinux ? "." : string.Empty) + "NestedDirectory_2");
firstNode.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isLinux ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar));
firstNode.Name.Should().Be((s_isUnix ? "." : string.Empty) + "NestedDirectory_2");
firstNode.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "NestedDirectory_2" + System.IO.Path.DirectorySeparatorChar));
firstNode.ItemType.Should().Be(FileSystemItemType.Directory);
treeNodes.Should().AllSatisfy(n => n.ItemType.Should().Be(FileSystemItemType.Directory));
treeNodes!.Count.Should().Be(1); // only directories
@@ -29,7 +29,7 @@ public class GetDrivesEndpointTests : IClassFixture<LuminaApiFactory>
PropertyNameCaseInsensitive = true,
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
};
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
/// <summary>
/// Initializes a new instance of the <see cref="GetDrivesEndpointTests"/> class.
@@ -57,8 +57,8 @@ public class GetDrivesEndpointTests : IClassFixture<LuminaApiFactory>
drives.Should().NotBeEmpty();
FileSystemTreeNodeResponse firstDrive = drives!.First();
firstDrive.Name.Should().Be(s_isLinux ? "/" : "C:\\");
firstDrive.Path.Should().Be(s_isLinux ? "/" : "C:\\");
firstDrive.Name.Should().Be(s_isUnix ? "/" : "C:\\");
firstDrive.Path.Should().Be(s_isUnix ? "/" : "C:\\");
firstDrive.ItemType.Should().Be(FileSystemItemType.Root);
drives!.Count.Should().BeGreaterThanOrEqualTo(1);
}
@@ -32,7 +32,7 @@ public class GetFilesEndpointTests : IClassFixture<LuminaApiFactory>
PropertyNameCaseInsensitive = true,
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
};
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
/// <summary>
/// Initializes a new instance of the <see cref="GetFilesEndpointTests"/> class.
@@ -139,8 +139,8 @@ public class GetFilesEndpointTests : IClassFixture<LuminaApiFactory>
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
FileResponse firstDirectory = files!.First();
firstDirectory.Name.Should().Be((s_isLinux ? "." : string.Empty) + "TestFile_1.txt");
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isLinux ? "." : string.Empty) + "TestFile_1.txt"));
firstDirectory.Name.Should().Be((s_isUnix ? "." : string.Empty) + "TestFile_1.txt");
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "TestFile_1.txt"));
FileResponse secondDirectory = files!.Last();
secondDirectory.Name.Should().Be("TestFile_2.txt");
secondDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, "TestFile_2.txt"));
@@ -32,7 +32,7 @@ public class GetTreeFilesEndpointTests : IClassFixture<LuminaApiFactory>
PropertyNameCaseInsensitive = true,
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
};
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
/// <summary>
/// Initializes a new instance of the <see cref="GetTreeFilesEndpointTests"/> class.
@@ -140,8 +140,8 @@ public class GetTreeFilesEndpointTests : IClassFixture<LuminaApiFactory>
string[] pathSegments = testPath.Split(System.IO.Path.DirectorySeparatorChar, StringSplitOptions.RemoveEmptyEntries);
FileSystemTreeNodeResponse firstDirectory = files!.First();
firstDirectory.Name.Should().Be((s_isLinux ? "." : string.Empty) + "TestFile_1.txt");
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isLinux ? "." : string.Empty) + "TestFile_1.txt"));
firstDirectory.Name.Should().Be((s_isUnix ? "." : string.Empty) + "TestFile_1.txt");
firstDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, (s_isUnix ? "." : string.Empty) + "TestFile_1.txt"));
FileSystemTreeNodeResponse secondDirectory = files!.Last();
secondDirectory.Name.Should().Be("TestFile_2.txt");
secondDirectory.Path.Should().Be(System.IO.Path.Combine(testPath, "TestFile_2.txt"));
@@ -31,7 +31,7 @@ public class GetPathParentEndpointTests : IClassFixture<LuminaApiFactory>
PropertyNameCaseInsensitive = true,
Converters = { new JsonStringEnumConverter(JsonNamingPolicy.CamelCase) }
};
private static readonly bool s_isLinux = RuntimeInformation.IsOSPlatform(OSPlatform.Linux);
private static readonly bool s_isUnix = RuntimeInformation.IsOSPlatform(OSPlatform.Linux) || RuntimeInformation.IsOSPlatform(OSPlatform.OSX);
/// <summary>
/// Initializes a new instance of the <see cref="GetPathParentEndpointTests"/> class.
@@ -63,7 +63,7 @@ public class GetPathParentEndpointTests : IClassFixture<LuminaApiFactory>
string path = System.IO.Path.GetDirectoryName(testPath)!;
while (!string.IsNullOrEmpty(path))
{
string segment = s_isLinux && path == System.IO.Path.DirectorySeparatorChar.ToString() ? path : System.IO.Path.GetFileName(path);
string segment = s_isUnix && path == System.IO.Path.DirectorySeparatorChar.ToString() ? path : System.IO.Path.GetFileName(path);
if (string.IsNullOrEmpty(segment))
{
hierarchy.Add(System.IO.Path.GetPathRoot(path)!.TrimEnd(System.IO.Path.DirectorySeparatorChar));