using DodoSSH.Client.Shell.ViewModels;
using DodoSSH.Client.Transfer;
namespace DodoSSH.Client.App.Tests;
/// What the local pane's root chips are called.
///
/// A chip carries a name and never a path — the path is the chip's command parameter, where its length costs
/// nothing. The derivation used to be TrimEnd(separator), which is a name only for a Windows drive:
/// on Unix it made the / chip an empty pill and the home chip the whole home path, and a home
/// directory deep enough pushed the pane header's own buttons out of the window — CI's per-job HOME is what
/// finally said so. These pin the derivation with fixed strings, so the question no longer depends on how
/// long a path any particular machine keeps its profile under.
///
public sealed class RootChipNameTests
{
[Fact]
public void TheUnixRootIsASlash_NotAnEmptyPill() =>
TransfersViewModel.RootChipName("/").ShouldBe("/");
///
/// The one substitution rather than a shortening: every shell already means "my home directory" by
/// ~, and the machine's real home path — however deep — stays on the chip's command alone.
///
[Fact]
public void TheHomeChipIsATilde_HoweverDeepHomeSits() =>
TransfersViewModel.RootChipName(LocalDirectory.Home).ShouldBe("~");
[Fact]
public void AMountNamesItselfByItsLastSegment() =>
TransfersViewModel.RootChipName("/media/usb0").ShouldBe("usb0");
///
/// Windows only, because the input only exists there — LocalDirectory.Roots() produces drive
/// roots on no other platform, and Path.GetFileName reads C:\ differently on Unix.
///
[Fact]
public void AWindowsDriveKeepsItsTwoCharacterName()
{
if (!OperatingSystem.IsWindows())
{
return;
}
TransfersViewModel.RootChipName(@"C:\").ShouldBe("C:");
}
}