namespace NATS.Server.Tests;

public class NatsOptionsTests
{
    [Fact]
    public void Defaults_are_correct()
    {
        var opts = new NatsOptions();
        opts.MaxSubs.ShouldBe(0);
        opts.MaxSubTokens.ShouldBe(0);
        opts.Debug.ShouldBe(false);
        opts.Trace.ShouldBe(false);
        opts.LogFile.ShouldBeNull();
        opts.LogSizeLimit.ShouldBe(0L);
        opts.Tags.ShouldBeNull();
    }

    [Fact]
    public void New_fields_have_correct_defaults()
    {
        var opts = new NatsOptions();
        opts.ClientAdvertise.ShouldBeNull();
        opts.TraceVerbose.ShouldBeFalse();
        opts.MaxTracedMsgLen.ShouldBe(0);
        opts.DisableSublistCache.ShouldBeFalse();
        opts.ConnectErrorReports.ShouldBe(3600);
        opts.ReconnectErrorReports.ShouldBe(1);
        opts.NoHeaderSupport.ShouldBeFalse();
        opts.MaxClosedClients.ShouldBe(10_000);
        opts.NoSystemAccount.ShouldBeFalse();
        opts.SystemAccount.ShouldBeNull();
    }
}

public class LogOverrideTests
{
    [Fact]
    public void LogOverrides_defaults_to_null()
    {
        var options = new NatsOptions();
        options.LogOverrides.ShouldBeNull();
    }

    [Fact]
    public void LogOverrides_can_be_set()
    {
        var options = new NatsOptions
        {
            LogOverrides = new() { ["NATS.Server.Protocol"] = "Trace" }
        };
        options.LogOverrides.ShouldNotBeNull();
        options.LogOverrides["NATS.Server.Protocol"].ShouldBe("Trace");
    }
}
