using NATS.Server.Auth;

namespace NATS.Server.Auth.Tests;

public class AccountStatsTests
{
    [Fact]
    public void Account_tracks_inbound_stats()
    {
        var account = new Account("test");
        account.IncrementInbound(1, 100);
        account.IncrementInbound(1, 200);
        account.InMsgs.ShouldBe(2);
        account.InBytes.ShouldBe(300);
    }

    [Fact]
    public void Account_tracks_outbound_stats()
    {
        var account = new Account("test");
        account.IncrementOutbound(1, 50);
        account.IncrementOutbound(1, 75);
        account.OutMsgs.ShouldBe(2);
        account.OutBytes.ShouldBe(125);
    }

    [Fact]
    public void Account_stats_start_at_zero()
    {
        var account = new Account("test");
        account.InMsgs.ShouldBe(0);
        account.OutMsgs.ShouldBe(0);
        account.InBytes.ShouldBe(0);
        account.OutBytes.ShouldBe(0);
    }

    [Fact]
    public void Account_stats_are_independent()
    {
        var account = new Account("test");
        account.IncrementInbound(5, 500);
        account.IncrementOutbound(3, 300);
        account.InMsgs.ShouldBe(5);
        account.OutMsgs.ShouldBe(3);
        account.InBytes.ShouldBe(500);
        account.OutBytes.ShouldBe(300);
    }
}
