using Shouldly;
using ZB.MOM.NatsNet.Server;

namespace ZB.MOM.NatsNet.Server.Tests.Accounts;

public sealed class AccountStreamRestoreTests
{
    [Fact]
    public void RestoreStream_EmptySnapshot_ReturnsError()
    {
        var account = new Account { Name = "A" };
        var config = new StreamConfig { Name = "S", Storage = StorageType.MemoryStorage };

        var (stream, error) = account.RestoreStream(config, new MemoryStream());

        stream.ShouldBeNull();
        error.ShouldNotBeNull();
    }

    [Fact]
    public void RestoreStream_WithSnapshotData_AddsStream()
    {
        var account = new Account { Name = "A" };
        var config = new StreamConfig { Name = "S", Storage = StorageType.MemoryStorage };
        using var snapshot = new MemoryStream([1, 2, 3]);

        var (stream, error) = account.RestoreStream(config, snapshot);

        error.ShouldBeNull();
        stream.ShouldNotBeNull();
        stream!.Name.ShouldBe("S");
    }
}
