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

namespace NATS.Server.Monitoring.Tests.Monitoring;

public class MonitoringHealthAndSortParityBatch1Tests
{
    [Fact]
    public void SortOpt_IsValid_matches_defined_values()
    {
        foreach (var value in Enum.GetValues<SortOpt>())
            value.IsValid().ShouldBeTrue();

        ((SortOpt)999).IsValid().ShouldBeFalse();
    }

    [Fact]
    public void HealthStatus_ok_serializes_with_go_shape_fields()
    {
        var json = JsonSerializer.Serialize(HealthStatus.Ok());

        json.ShouldContain("\"status\":\"ok\"");
        json.ShouldContain("\"status_code\":200");
        json.ShouldContain("\"errors\":[]");
    }

    [Fact]
    public void HealthzError_serializes_enum_as_string()
    {
        var json = JsonSerializer.Serialize(new HealthzError
        {
            Type = HealthzErrorType.JetStream,
            Error = "jetstream unavailable",
        });

        json.ShouldContain("\"type\":\"JetStream\"");
        json.ShouldContain("\"error\":\"jetstream unavailable\"");
    }
}
