mirror of
https://github.com/rmcrackan/Libation.git
synced 2026-06-25 07:59:41 -04:00
fix unit tests for windows-only logic
This commit is contained in:
@@ -64,10 +64,11 @@ public static class DiskSpaceHelper
|
||||
|
||||
/// <summary>
|
||||
/// Strips the Win32 extended-length prefix so <see cref="DriveInfo"/> and path APIs see a normal root.
|
||||
/// No-op on non-Windows platforms (Libation only uses the prefix there).
|
||||
/// </summary>
|
||||
public static string NormalizePathForDriveQuery(string path)
|
||||
{
|
||||
if (!path.StartsWith(WinLongPathPrefix, StringComparison.Ordinal))
|
||||
if (!OperatingSystem.IsWindows() || !path.StartsWith(WinLongPathPrefix, StringComparison.Ordinal))
|
||||
return path;
|
||||
|
||||
var stripped = path[WinLongPathPrefix.Length..];
|
||||
|
||||
@@ -33,18 +33,29 @@ public class DiskSpaceHelperTests
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void NormalizePathForDriveQuery_strips_extended_prefix()
|
||||
[OSCondition(OperatingSystems.Windows)]
|
||||
public void Windows_NormalizePathForDriveQuery_strips_extended_prefix()
|
||||
{
|
||||
Assert.AreEqual(@"C:\Audiobooks\Books", DiskSpaceHelper.NormalizePathForDriveQuery(@"\\?\C:\Audiobooks\Books"));
|
||||
Assert.AreEqual(@"\\server\share\Books", DiskSpaceHelper.NormalizePathForDriveQuery(@"\\?\UNC\server\share\Books"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetPathRootForDiskSpaceCheck_strips_extended_prefix()
|
||||
[OSCondition(OperatingSystems.Windows)]
|
||||
public void Windows_GetPathRootForDiskSpaceCheck_strips_extended_prefix()
|
||||
{
|
||||
Assert.AreEqual(@"C:\", DiskSpaceHelper.GetPathRootForDiskSpaceCheck(@"\\?\C:\Audiobooks\Books"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetPathRootForDiskSpaceCheck_unix_absolute_path()
|
||||
{
|
||||
if (OperatingSystem.IsWindows())
|
||||
Assert.Inconclusive("Skipped because OS is Windows.");
|
||||
|
||||
Assert.AreEqual("/", DiskSpaceHelper.GetPathRootForDiskSpaceCheck("/home/user/Libation/Books"));
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void GetRequiredBytesForDriveUsage_uses_batch_for_books_only()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user