using ClaudeDo.Worker.Usage.TokenTracker;

namespace ClaudeDo.Worker.Tests.Usage.TokenTracker;

public sealed class SessionHashTests
{
    [Theory]
    [InlineData("77470328-94f7-49d3-b378-a562d1501b5f", "b24babcbf2b615730459773f")]
    [InlineData("20ebc1bc-3e6a-4c09-a4b3-19472dffa841", "3e2a08fe8f2b941817fb554f")]
    [InlineData("559e7ebb-7215-4112-9faf-be86bece9613", "03c30f4bc0bfe82c3fbb17c1")]
    public void ForClaudeSession_MatchesTokenTrackerHash(string sessionId, string expected)
    {
        Assert.Equal(expected, SessionHash.ForClaudeSession(sessionId));
    }

    [Fact]
    public void ForClaudeSession_IsLowercaseHexOf24Chars()
    {
        var hash = SessionHash.ForClaudeSession("any-session-id");

        Assert.Equal(24, hash!.Length);
        Assert.All(hash, c => Assert.Contains(c, "0123456789abcdef"));
    }

    [Theory]
    [InlineData(null)]
    [InlineData("")]
    [InlineData("   ")]
    public void ForClaudeSession_BlankId_ReturnsNull(string? sessionId)
    {
        Assert.Null(SessionHash.ForClaudeSession(sessionId));
    }
}
