using JobTrackerApi.Models;
using Xunit;

namespace JobTrackerApi.Tests;

public sealed class AccountPlansTests
{
    [Theory]
    [InlineData("active", true)]
    [InlineData("trialing", true)]
    [InlineData("past_due", false)]
    [InlineData("canceled", false)]
    [InlineData(null, false)]
    public void Premium_subscription_status_requires_current_access(string? status, bool expected)
    {
        Assert.Equal(expected, AccountPlans.IsPremiumSubscriptionStatus(status));
    }

    [Fact]
    public void Premium_role_receives_higher_cost_capabilities()
    {
        var free = AccountPlans.ForRoles(Array.Empty<string>());
        var premium = AccountPlans.ForRoles(new[] { "Premium" });

        Assert.False(free.Ai);
        Assert.Equal("free", AccountPlans.Name(free));
        Assert.Equal(0, free.MonthlyAiCalls);
        Assert.Equal(0, free.MonthlyAiTokens);
        Assert.True(premium.Ai);
        Assert.Equal("pro", AccountPlans.Name(premium));
        Assert.True(premium.MonthlyAiCalls > free.MonthlyAiCalls);
        Assert.True(premium.MonthlyAiTokens > free.MonthlyAiTokens);
        Assert.True(premium.StorageBytes > free.StorageBytes);
    }

    [Fact]
    public void Admin_role_receives_pro_capabilities()
    {
        Assert.True(AccountPlans.ForRoles(new[] { "Admin" }).Ai);
    }
}
