using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;

namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Types.Enums;

/// <summary>
/// Asserts the exact member sets of the Audit Log (#23) enums.
/// Lock-in tests; any addition/removal/rename is a deliberate design change
/// that must come with a corresponding update to alog.md §4.
/// </summary>
public class AuditEnumTests
{
    [Fact]
    public void AuditChannel_HasExactlyExpectedMembers()
    {
        var expected = new[] { "ApiOutbound", "DbOutbound", "Notification", "ApiInbound", "SecuredWrite", "Cluster" };
        var actual = Enum.GetValues(typeof(AuditChannel))
            .Cast<AuditChannel>()
            .Select(x => x.ToString())
            .ToArray();

        Assert.Equal(expected.Length, actual.Length);
        Assert.Equal(expected, actual);
    }

    [Fact]
    public void AuditKind_HasExactlySeventeenExpectedMembers()
    {
        var expected = new[]
        {
            "ApiCall", "ApiCallCached", "DbWrite", "DbWriteCached",
            "NotifySend", "NotifyDeliver", "InboundRequest", "InboundAuthFailure",
            "CachedSubmit", "CachedResolve",
            "SecuredWriteSubmit", "SecuredWriteApprove", "SecuredWriteReject", "SecuredWriteExecute",
            "SecuredWriteExpire",
            "ReconciliationAbandoned",
            "ManualFailover",
        };
        var actual = Enum.GetValues(typeof(AuditKind))
            .Cast<AuditKind>()
            .Select(x => x.ToString())
            .ToArray();

        Assert.Equal(17, actual.Length);
        Assert.Equal(expected, actual);
    }

    [Fact]
    public void AuditStatus_HasExactlyEightExpectedMembers()
    {
        var expected = new[]
        {
            "Submitted", "Forwarded", "Attempted", "Delivered",
            "Failed", "Parked", "Discarded", "Skipped",
        };
        var actual = Enum.GetValues(typeof(AuditStatus))
            .Cast<AuditStatus>()
            .Select(x => x.ToString())
            .ToArray();

        Assert.Equal(8, actual.Length);
        Assert.Equal(expected, actual);
    }

    [Fact]
    public void AuditForwardState_HasExactlyExpectedMembers()
    {
        var expected = new[] { "Pending", "Forwarded", "Reconciled" };
        var actual = Enum.GetValues(typeof(AuditForwardState))
            .Cast<AuditForwardState>()
            .Select(x => x.ToString())
            .ToArray();

        Assert.Equal(expected.Length, actual.Length);
        Assert.Equal(expected, actual);
    }
}
