using NATS.Server.JetStream.Storage;

namespace NATS.Server.Tests;

public class MemStoreTests
{
    [Fact]
    public async Task MemStore_supports_append_load_and_purge()
    {
        var store = new MemStore();
        var seq1 = await store.AppendAsync("a", "one"u8.ToArray(), default);
        var seq2 = await store.AppendAsync("a", "two"u8.ToArray(), default);

        seq2.ShouldBe(seq1 + 1);
        (await store.LoadAsync(seq2, default))!.Payload.Span.SequenceEqual("two"u8).ShouldBeTrue();

        await store.PurgeAsync(default);
        (await store.GetStateAsync(default)).Messages.ShouldBe((ulong)0);
    }
}
