namespace NATS.Server.Tests;

public class JetStreamAckRedeliveryTests
{
    [Fact]
    public async Task Unacked_message_is_redelivered_after_ack_wait()
    {
        await using var fixture = await JetStreamApiFixture.StartWithAckExplicitConsumerAsync(ackWaitMs: 50);
        await fixture.PublishAndGetAckAsync("orders.created", "1");

        var first = await fixture.FetchAsync("ORDERS", "PULL", batch: 1);
        var second = await fixture.FetchAfterDelayAsync("ORDERS", "PULL", delayMs: 75, batch: 1);

        second.Messages.Single().Sequence.ShouldBe(first.Messages.Single().Sequence);
        second.Messages.Single().Redelivered.ShouldBeTrue();
    }
}
