using NATS.Server.JetStream.Consumers;

namespace NATS.Server.Tests;

public class JetStreamConsumerRuntimeParityTests
{
    [Fact]
    public async Task Consumer_runtime_honors_ack_all_redelivery_and_max_deliver_limits()
    {
        var ack = new AckProcessor();
        ack.Register(1, ackWaitMs: 1);
        await Task.Delay(5);
        ack.TryGetExpired(out var seq, out var deliveries).ShouldBeTrue();
        seq.ShouldBe((ulong)1);
        deliveries.ShouldBe(1);

        ack.ScheduleRedelivery(seq, delayMs: 1);
        await Task.Delay(5);
        ack.TryGetExpired(out _, out deliveries).ShouldBeTrue();
        deliveries.ShouldBe(2);

        ack.AckAll(1);
        ack.HasPending.ShouldBeFalse();
    }
}
