using ClaudeDo.Worker.Usage.TokenTracker;

namespace ClaudeDo.Worker.Tests.Usage.TokenTracker;

public sealed class TokenTrackerArgsTests
{
    [Fact]
    public void Export_UsesIsoDatesAndDisablesGitAttribution()
    {
        var args = TokenTrackerArgs.Export(new DateOnly(2026, 5, 26), new DateOnly(2026, 8, 24));

        Assert.Equal(
            new[] { "sessions", "--from", "2026-05-26", "--to", "2026-08-24", "--no-git", "--format", "json" },
            args);
    }

    [Fact]
    public void Export_IsCultureInvariant()
    {
        var previous = Thread.CurrentThread.CurrentCulture;
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo("de-DE");
        try
        {
            var args = TokenTrackerArgs.Export(new DateOnly(2026, 1, 2), new DateOnly(2026, 1, 3));
            Assert.Equal("2026-01-02", args[2]);
            Assert.Equal("2026-01-03", args[4]);
        }
        finally { Thread.CurrentThread.CurrentCulture = previous; }
    }

    [Fact]
    public void Version_AsksTheCliForItsVersion()
    {
        Assert.Equal(new[] { "-v" }, TokenTrackerArgs.Version());
    }

    [Fact]
    public void Install_InstallsTheCliPackageGlobally()
    {
        Assert.Equal(new[] { "i", "-g", "tokentracker-cli" }, TokenTrackerArgs.Install());
    }

    [Fact]
    public void Serve_PinsThePortAndOptsOutOfBrowserAndCloudSync()
    {
        Assert.Equal(
            new[] { "serve", "--port", "7681", "--no-open", "--no-sync" },
            TokenTrackerArgs.Serve(7681));
    }
}
