using System.Text.Json;
using NATS.Server.Monitoring;

namespace NATS.Server.Tests;

public class MonitorModelTests
{
    [Fact]
    public void Varz_serializes_with_go_field_names()
    {
        var varz = new Varz
        {
            Id = "TESTID", Name = "test-server", Version = "0.1.0",
            Host = "0.0.0.0", Port = 4222, InMsgs = 100, OutMsgs = 200,
        };
        var json = JsonSerializer.Serialize(varz);
        json.ShouldContain("\"server_id\":");
        json.ShouldContain("\"server_name\":");
        json.ShouldContain("\"in_msgs\":");
        json.ShouldContain("\"out_msgs\":");
        json.ShouldNotContain("\"InMsgs\"");
    }

    [Fact]
    public void Connz_serializes_with_go_field_names()
    {
        var connz = new Connz
        {
            Id = "TESTID", Now = DateTime.UtcNow, NumConns = 1, Total = 1, Limit = 1024,
            Conns = [new ConnInfo { Cid = 1, Ip = "127.0.0.1", Port = 5555,
                InMsgs = 10, Uptime = "1s", Idle = "0s",
                Start = DateTime.UtcNow, LastActivity = DateTime.UtcNow }],
        };
        var json = JsonSerializer.Serialize(connz);
        json.ShouldContain("\"server_id\":");
        json.ShouldContain("\"num_connections\":");
        json.ShouldContain("\"in_msgs\":");
        json.ShouldContain("\"pending_bytes\":");
    }

    [Fact]
    public void Varz_includes_nested_config_stubs()
    {
        var varz = new Varz { Id = "X", Name = "X", Version = "X", Host = "X" };
        var json = JsonSerializer.Serialize(varz);
        json.ShouldContain("\"cluster\":");
        json.ShouldContain("\"gateway\":");
        json.ShouldContain("\"leaf\":");
        json.ShouldContain("\"jetstream\":");
    }
}
