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

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

/// <summary>
/// C1 canonical field builder tests: BuildAction and BuildCategory.
/// </summary>
public class AuditFieldBuildersTests
{
    // ---------------------------------------------------------------------------
    // BuildAction: "{channel}.{kind}"
    // ---------------------------------------------------------------------------

    [Theory]
    [InlineData(AuditChannel.ApiOutbound,  AuditKind.ApiCall,            "ApiOutbound.ApiCall")]
    [InlineData(AuditChannel.ApiOutbound,  AuditKind.ApiCallCached,      "ApiOutbound.ApiCallCached")]
    [InlineData(AuditChannel.DbOutbound,   AuditKind.DbWrite,            "DbOutbound.DbWrite")]
    [InlineData(AuditChannel.DbOutbound,   AuditKind.DbWriteCached,      "DbOutbound.DbWriteCached")]
    [InlineData(AuditChannel.Notification, AuditKind.NotifySend,         "Notification.NotifySend")]
    [InlineData(AuditChannel.Notification, AuditKind.NotifyDeliver,      "Notification.NotifyDeliver")]
    [InlineData(AuditChannel.ApiInbound,   AuditKind.InboundRequest,     "ApiInbound.InboundRequest")]
    [InlineData(AuditChannel.ApiInbound,   AuditKind.InboundAuthFailure, "ApiInbound.InboundAuthFailure")]
    [InlineData(AuditChannel.ApiOutbound,  AuditKind.CachedSubmit,       "ApiOutbound.CachedSubmit")]
    [InlineData(AuditChannel.ApiOutbound,  AuditKind.CachedResolve,      "ApiOutbound.CachedResolve")]
    public void BuildAction_ReturnsChannelDotKind(AuditChannel channel, AuditKind kind, string expected)
    {
        Assert.Equal(expected, AuditFieldBuilders.BuildAction(channel, kind));
    }

    // ---------------------------------------------------------------------------
    // BuildCategory: channel.ToString()
    // ---------------------------------------------------------------------------

    [Theory]
    [InlineData(AuditChannel.ApiOutbound,  "ApiOutbound")]
    [InlineData(AuditChannel.DbOutbound,   "DbOutbound")]
    [InlineData(AuditChannel.Notification, "Notification")]
    [InlineData(AuditChannel.ApiInbound,   "ApiInbound")]
    public void BuildCategory_ReturnsChannelName(AuditChannel channel, string expected)
    {
        Assert.Equal(expected, AuditFieldBuilders.BuildCategory(channel));
    }
}
