using System.Collections.Generic;
using System.IO;
using ZB.MOM.WW.MxGateway.Worker.Bootstrap;

namespace ZB.MOM.WW.MxGateway.Worker.Tests.Bootstrap;

public sealed class WorkerConsoleLoggerTests
{
    /// <summary>Verifies that console logger redacts nonce in structured output.</summary>
    [Fact]
    public void Information_RedactsNonceInStructuredOutput()
    {
        StringWriter writer = new();
        WorkerConsoleLogger logger = new(writer);

        logger.Information("WorkerBootstrapSucceeded", new Dictionary<string, object?>
        {
            ["session_id"] = "session-1",
            ["nonce"] = "nonce-secret",
        });

        string output = writer.ToString();

        Assert.Contains("event=WorkerBootstrapSucceeded", output);
        Assert.Contains("session_id=session-1", output);
        Assert.Contains("nonce=[redacted]", output);
        Assert.DoesNotContain("nonce-secret", output);
    }
}
