#nullable enable

using MBN_STOCK_WEBVIEW.DbWriteSmoke;

namespace MBN_STOCK_WEBVIEW.DbWriteSmoke.Tests;

public sealed class SmokeRunIdentityTests
{
    [Fact]
    public void Create_ProducesCollisionResistantSafeBoundedPrefix()
    {
        var identity = SmokeRunIdentity.Create(
            DateTimeOffset.Parse("2026-07-15T10:11:12+09:00"),
            Guid.Parse("01234567-89ab-cdef-0123-456789abcdef"));

        var value = identity.For("G_PROFIT");

        Assert.Equal(
            "MBW2607150123456789O",
            value);
        Assert.Equal(20, value.Length);
        Assert.Matches("^[A-Z0-9]+$", value);
    }

    [Fact]
    public void Create_RejectsEmptyNonceAndUnsafeSuffix()
    {
        Assert.Throws<ArgumentException>(() =>
            SmokeRunIdentity.Create(DateTimeOffset.UtcNow, Guid.Empty));
        var identity = SmokeRunIdentity.Create(DateTimeOffset.UtcNow, Guid.NewGuid());
        Assert.Throws<ArgumentException>(() => identity.For("bad-value"));
    }
}
