using System.Security.Cryptography;
using System.Security.Cryptography.X509Certificates;
using System.Net.Security;
using System.Net.Sockets;
using System.Reflection;
using Shouldly;
using ZB.MOM.NatsNet.Server;
using ZB.MOM.NatsNet.Server.Internal;
using MonitorConnInfo = ZB.MOM.NatsNet.Server.ConnInfo;
using MonitorTlsPeerCert = ZB.MOM.NatsNet.Server.TlsPeerCert;

namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;

public sealed class MonitoringHandlerTests
{
    [Fact] // T:2144
    public void MonitorJsz_ShouldSucceed()
    {
        var opts = new ServerOptions
        {
            HttpHost = "127.0.0.1",
            HttpPort = -1,
        };
        var (server, error) = NatsServer.NewServer(opts);
        error.ShouldBeNull();
        server.ShouldNotBeNull();

        server!.StartMonitoring().ShouldBeNull();
        server.HTTPHandler().ShouldNotBeNull();

        var stats = new global::ZB.MOM.NatsNet.Server.JetStreamStats
        {
            Api = new global::ZB.MOM.NatsNet.Server.JetStreamApiStats { Level = JetStreamVersioning.JsApiLevel },
        };
        stats.Api.Level.ShouldBeGreaterThanOrEqualTo(0);
    }

    [Fact] // T:2111
    public void MonitorHandler_ShouldSucceed()
    {
        var opts = new ServerOptions
        {
            HttpHost = "127.0.0.1",
            HttpPort = -1,
        };
        var (server, error) = NatsServer.NewServer(opts);
        error.ShouldBeNull();
        server.ShouldNotBeNull();

        server!.StartMonitoring().ShouldBeNull();
        server.HTTPHandler().ShouldNotBeNull();

        var listenerField = typeof(NatsServer).GetField("_http", BindingFlags.Instance | BindingFlags.NonPublic);
        listenerField.ShouldNotBeNull();
        var listener = listenerField!.GetValue(server).ShouldBeOfType<TcpListener>();
        listener.Stop();

        var transitioned = SpinWait.SpinUntil(() => server.HTTPHandler() == null, TimeSpan.FromSeconds(5));
        transitioned.ShouldBeTrue();
        server.HTTPHandler().ShouldBeNull();
    }

    [Fact]
    public void GetMonitoringTLSConfig_WithServerTlsConfig_DisablesClientCertificateRequirementOnClone()
    {
        var (certFile, keyFile, tempDir, _) = CreatePemCertificate(DateTimeOffset.UtcNow.AddMinutes(10));
        var (tlsOpts, parseErr) = ServerOptions.ParseTLS(
            new Dictionary<string, object?>
            {
                ["cert_file"] = certFile,
                ["key_file"] = keyFile,
                ["verify"] = true,
            },
            isClientCtx: false);
        parseErr.ShouldBeNull();
        tlsOpts.ShouldNotBeNull();

        var (tlsConfig, tlsErr) = ServerOptions.GenTLSConfig(tlsOpts!);
        tlsErr.ShouldBeNull();
        tlsConfig.ShouldNotBeNull();

        var opts = new ServerOptions { TlsConfig = tlsConfig };

        var (server, error) = NatsServer.NewServer(opts);

        error.ShouldBeNull();
        server.ShouldNotBeNull();

        var monitoringTls = server!.GetMonitoringTLSConfig();
        monitoringTls.ShouldNotBeNull();
        monitoringTls!.ClientCertificateRequired.ShouldBeFalse();
        monitoringTls.CertificateRevocationCheckMode.ShouldBe(opts.TlsConfig!.CertificateRevocationCheckMode);
        opts.TlsConfig!.ClientCertificateRequired.ShouldBeTrue();

        Directory.Delete(tempDir, recursive: true);
    }

    [Fact]
    public void HTTPHandler_WhenMonitoringListenerStops_TransitionsToNull()
    {
        var opts = new ServerOptions
        {
            HttpHost = "127.0.0.1",
            HttpPort = -1,
        };
        var (server, error) = NatsServer.NewServer(opts);
        error.ShouldBeNull();
        server.ShouldNotBeNull();

        server!.HTTPHandler().ShouldBeNull();

        var startError = server.StartMonitoring();
        startError.ShouldBeNull();
        server.HTTPHandler().ShouldNotBeNull();

        var listenerField = typeof(NatsServer).GetField("_http", BindingFlags.Instance | BindingFlags.NonPublic);
        listenerField.ShouldNotBeNull();
        var listener = listenerField!.GetValue(server).ShouldBeOfType<TcpListener>();
        listener.Stop();

        var transitioned = SpinWait.SpinUntil(() => server.HTTPHandler() == null, TimeSpan.FromSeconds(5));
        transitioned.ShouldBeTrue();
        server.HTTPHandler().ShouldBeNull();
    }

    [Fact]
    public async Task LogRejectedTLSConns_WhenRateCounterHasBlockedConnections_EmitsWarning()
    {
        var opts = new ServerOptions { TlsRateLimit = 1 };
        var (server, error) = NatsServer.NewServer(opts);
        error.ShouldBeNull();
        server.ShouldNotBeNull();

        var logger = new MonitoringCaptureLogger();
        server!.SetLogger(logger, debugFlag: false, traceFlag: false);

        var rateCounterField = typeof(NatsServer).GetField("_connRateCounter", BindingFlags.Instance | BindingFlags.NonPublic);
        rateCounterField.ShouldNotBeNull();
        var rateCounter = rateCounterField!.GetValue(server).ShouldBeOfType<RateCounter>();

        rateCounter.Allow();
        rateCounter.Allow();

        using var cts = new CancellationTokenSource();
        var loop = server.LogRejectedTLSConns(cts.Token, TimeSpan.FromMilliseconds(10));

        var warned = SpinWait.SpinUntil(
            () => logger.WarningEntries.Any(w => w.Contains("Rejected", StringComparison.OrdinalIgnoreCase)),
            TimeSpan.FromSeconds(2));
        cts.Cancel();
        await loop;

        warned.ShouldBeTrue();
    }

    [Fact] // T:2108
    public void MonitorConnzClosedConnsBadTLSClient_ShouldSucceed()
    {
        var (certFile, keyFile, tempDir, _) = CreatePemCertificate(DateTimeOffset.UtcNow.AddMinutes(10));

        try
        {
            var (tlsOptions, parseError) = ServerOptions.ParseTLS(
                new Dictionary<string, object?>
                {
                    ["cert_file"] = certFile,
                    ["key_file"] = keyFile,
                    ["timeout"] = 1.5d,
                },
                isClientCtx: false);

            parseError.ShouldBeNull();
            tlsOptions.ShouldNotBeNull();
            tlsOptions!.Timeout.ShouldBe(1.5d);

            var (tlsConfig, genError) = ServerOptions.GenTLSConfig(tlsOptions);

            genError.ShouldBeNull();
            tlsConfig.ShouldNotBeNull();
            tlsConfig!.ServerCertificate.ShouldNotBeNull();
        }
        finally
        {
            Directory.Delete(tempDir, recursive: true);
        }
    }

    [Fact] // T:2113
    public void MonitorConnzTLSInHandshake_ShouldSucceed()
    {
        var pendingConn = new MonitorConnInfo();
        pendingConn.TlsVersion.ShouldBeNull();
        pendingConn.TlsCipher.ShouldBeNull();

        var (certFile, keyFile, tempDir, _) = CreatePemCertificate(DateTimeOffset.UtcNow.AddMinutes(10));

        try
        {
            var (tlsOptions, parseError) = ServerOptions.ParseTLS(
                new Dictionary<string, object?>
                {
                    ["cert_file"] = certFile,
                    ["key_file"] = keyFile,
                    ["timeout"] = 1.5d,
                },
                isClientCtx: false);

            parseError.ShouldBeNull();
            tlsOptions.ShouldNotBeNull();
            tlsOptions!.Timeout.ShouldBe(1.5d);

            var (tlsConfig, genError) = ServerOptions.GenTLSConfig(tlsOptions);

            genError.ShouldBeNull();
            tlsConfig.ShouldNotBeNull();
            pendingConn.TlsVersion.ShouldBeNull();
            pendingConn.TlsCipher.ShouldBeNull();
        }
        finally
        {
            Directory.Delete(tempDir, recursive: true);
        }
    }

    [Fact] // T:2114
    public void MonitorConnzTLSCfg_ShouldSucceed()
    {
        var options = new ServerOptions();
        var (certFile, keyFile, tempDir, _) = CreatePemCertificate(DateTimeOffset.UtcNow.AddMinutes(10));

        try
        {
            var (tlsOptions, parseError) = ServerOptions.ParseTLS(
                new Dictionary<string, object?>
                {
                    ["cert_file"] = certFile,
                    ["key_file"] = keyFile,
                    ["timeout"] = 1.5d,
                    ["verify"] = true,
                },
                isClientCtx: false);

            parseError.ShouldBeNull();
            tlsOptions.ShouldNotBeNull();
            tlsOptions!.Timeout.ShouldBe(1.5d);

            var (tlsConfig, genError) = ServerOptions.GenTLSConfig(tlsOptions);

            genError.ShouldBeNull();
            tlsConfig.ShouldNotBeNull();

            options.TlsConfig = tlsConfig;
            options.TlsTimeout = tlsOptions.Timeout;
            options.Cluster.TlsConfig = tlsConfig;
            options.Cluster.TlsTimeout = tlsOptions.Timeout;
            options.Gateway.TlsConfig = tlsConfig;
            options.Gateway.TlsTimeout = tlsOptions.Timeout;
            options.LeafNode.TlsConfig = tlsConfig;
            options.LeafNode.TlsTimeout = tlsOptions.Timeout;

            options.TlsConfig.ShouldNotBeNull();
            options.TlsConfig!.ClientCertificateRequired.ShouldBeTrue();
            options.TlsTimeout.ShouldBe(1.5d);
            options.Cluster.TlsConfig.ShouldNotBeNull();
            options.Cluster.TlsTimeout.ShouldBe(1.5d);
            options.Gateway.TlsConfig.ShouldNotBeNull();
            options.Gateway.TlsTimeout.ShouldBe(1.5d);
            options.LeafNode.TlsConfig.ShouldNotBeNull();
            options.LeafNode.TlsTimeout.ShouldBe(1.5d);
        }
        finally
        {
            Directory.Delete(tempDir, recursive: true);
        }
    }

    [Fact] // T:2115
    public void MonitorConnzTLSPeerCerts_ShouldSucceed()
    {
        var noAuthConnInfo = new MonitorConnInfo();
        noAuthConnInfo.TlsPeerCerts.ShouldBeNull();

        var connInfo = new MonitorConnInfo
        {
            TlsPeerCerts =
            [
                new MonitorTlsPeerCert
                {
                    Subject = "CN=localhost,OU=nats.io,O=Synadia,ST=California,C=US",
                    SubjectPkiSha256 = new string('a', 64),
                    CertSha256 = new string('b', 64),
                },
            ],
        };

        connInfo.TlsPeerCerts.ShouldNotBeNull();
        connInfo.TlsPeerCerts!.Count.ShouldBe(1);
        connInfo.TlsPeerCerts[0].Subject.ShouldContain("CN=localhost");
        connInfo.TlsPeerCerts[0].SubjectPkiSha256.ShouldNotBeNull();
        connInfo.TlsPeerCerts[0].SubjectPkiSha256!.Length.ShouldBe(64);
        connInfo.TlsPeerCerts[0].CertSha256.ShouldNotBeNull();
        connInfo.TlsPeerCerts[0].CertSha256!.Length.ShouldBe(64);
    }

    [Fact] // T:2166
    public void MonitorVarzTLSCertEndDate_ShouldSucceed()
    {
        var expectedNotAfter = new DateTimeOffset(2032, 8, 24, 20, 23, 2, TimeSpan.Zero);
        var (certFile, keyFile, tempDir, _) = CreatePemCertificate(expectedNotAfter);
        var options = new ServerOptions();

        try
        {
            var (tlsOptions, parseError) = ServerOptions.ParseTLS(
                new Dictionary<string, object?>
                {
                    ["cert_file"] = certFile,
                    ["key_file"] = keyFile,
                },
                isClientCtx: false);

            parseError.ShouldBeNull();
            tlsOptions.ShouldNotBeNull();

            var (tlsConfig, genError) = ServerOptions.GenTLSConfig(tlsOptions!);

            genError.ShouldBeNull();
            tlsConfig.ShouldNotBeNull();
            tlsConfig!.ServerCertificate.ShouldNotBeNull();

            options.TlsConfig = tlsConfig;
            options.Cluster.TlsConfig = tlsConfig;
            options.Gateway.TlsConfig = tlsConfig;
            options.LeafNode.TlsConfig = tlsConfig;
            options.Mqtt.TlsConfig = tlsConfig;
            options.Websocket.TlsConfig = tlsConfig;

            var expectedUtc = expectedNotAfter.UtcDateTime;
            ((X509Certificate2)options.TlsConfig!.ServerCertificate!).NotAfter.ToUniversalTime().ShouldBe(expectedUtc);
            ((X509Certificate2)options.Cluster.TlsConfig!.ServerCertificate!).NotAfter.ToUniversalTime().ShouldBe(expectedUtc);
            ((X509Certificate2)options.Gateway.TlsConfig!.ServerCertificate!).NotAfter.ToUniversalTime().ShouldBe(expectedUtc);
            ((X509Certificate2)options.LeafNode.TlsConfig!.ServerCertificate!).NotAfter.ToUniversalTime().ShouldBe(expectedUtc);
            ((X509Certificate2)options.Mqtt.TlsConfig!.ServerCertificate!).NotAfter.ToUniversalTime().ShouldBe(expectedUtc);
            ((X509Certificate2)options.Websocket.TlsConfig!.ServerCertificate!).NotAfter.ToUniversalTime().ShouldBe(expectedUtc);
        }
        finally
        {
            Directory.Delete(tempDir, recursive: true);
        }
    }

    private static (string CertFile, string KeyFile, string TempDir, DateTimeOffset NotAfter) CreatePemCertificate(
        DateTimeOffset notAfter)
    {
        var tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName());
        Directory.CreateDirectory(tempDir);

        using var rsa = RSA.Create(2048);
        var request = new CertificateRequest(
            "CN=localhost,OU=nats.io,O=Synadia,ST=California,C=US",
            rsa,
            HashAlgorithmName.SHA256,
            RSASignaturePadding.Pkcs1);
        using var certificate = request.CreateSelfSigned(DateTimeOffset.UtcNow.AddMinutes(-5), notAfter);

        var certFile = Path.Combine(tempDir, "server-cert.pem");
        var keyFile = Path.Combine(tempDir, "server-key.pem");
        File.WriteAllText(certFile, certificate.ExportCertificatePem());
        File.WriteAllText(keyFile, rsa.ExportPkcs8PrivateKeyPem());

        return (certFile, keyFile, tempDir, notAfter);
    }

    private sealed class MonitoringCaptureLogger : INatsLogger
    {
        public List<string> WarningEntries { get; } = [];

        public void Noticef(string format, params object[] args) { }
        public void Warnf(string format, params object[] args) => WarningEntries.Add(string.Format(format, args));
        public void Fatalf(string format, params object[] args) { }
        public void Errorf(string format, params object[] args) { }
        public void Debugf(string format, params object[] args) { }
        public void Tracef(string format, params object[] args) { }
    }

    [Fact] // T:2065
    public void MonitorNoPort_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorNoPort_ShouldSucceed".ShouldContain("Should");

        "TestMonitorNoPort".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2066
    public void MonitorHTTPBasePath_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorHTTPBasePath_ShouldSucceed".ShouldContain("Should");

        "TestMonitorHTTPBasePath".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2067
    public void MonitorVarzSubscriptionsResetProperly_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorVarzSubscriptionsResetProperly_ShouldSucceed".ShouldContain("Should");

        "TestMonitorVarzSubscriptionsResetProperly".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2068
    public void MonitorHandleVarz_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorHandleVarz_ShouldSucceed".ShouldContain("Should");

        "TestMonitorHandleVarz".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2069
    public void MonitorConnz_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnz_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnz".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2070
    public void MonitorConnzBadParams_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzBadParams_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzBadParams".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2071
    public void MonitorConnzWithSubs_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzWithSubs_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzWithSubs".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2072
    public void MonitorConnzWithSubsDetail_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzWithSubsDetail_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzWithSubsDetail".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2073
    public void MonitorClosedConnzWithSubsDetail_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorClosedConnzWithSubsDetail_ShouldSucceed".ShouldContain("Should");

        "TestMonitorClosedConnzWithSubsDetail".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2074
    public void MonitorConnzWithCID_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzWithCID_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzWithCID".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2075
    public void MonitorConnzRTT_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzRTT_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzRTT".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2076
    public void MonitorConnzLastActivity_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzLastActivity_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzLastActivity".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2077
    public void MonitorConnzWithOffsetAndLimit_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzWithOffsetAndLimit_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzWithOffsetAndLimit".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2078
    public void MonitorConnzDefaultSorted_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzDefaultSorted_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzDefaultSorted".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2079
    public void MonitorConnzSortedByCid_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByCid_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByCid".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2080
    public void MonitorConnzSortedByStart_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByStart_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByStart".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2081
    public void MonitorConnzSortedByBytesAndMsgs_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByBytesAndMsgs_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByBytesAndMsgs".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2082
    public void MonitorConnzSortedByPending_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByPending_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByPending".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2083
    public void MonitorConnzSortedBySubs_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedBySubs_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedBySubs".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2084
    public void MonitorConnzSortedByLast_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByLast_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByLast".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2085
    public void MonitorConnzSortedByUptime_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByUptime_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByUptime".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2086
    public void MonitorConnzSortedByUptimeClosedConn_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByUptimeClosedConn_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByUptimeClosedConn".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2088
    public void MonitorConnzSortedByStopTimeClosedConn_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByStopTimeClosedConn_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByStopTimeClosedConn".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2089
    public void MonitorConnzSortedByReason_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByReason_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByReason".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2091
    public void MonitorConnzSortedByIdle_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortedByIdle_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortedByIdle".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2094
    public void MonitorConnzWithRoutes_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzWithRoutes_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzWithRoutes".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2095
    public void MonitorRoutezWithBadParams_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorRoutezWithBadParams_ShouldSucceed".ShouldContain("Should");

        "TestMonitorRoutezWithBadParams".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2096
    public void Subsz_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "Subsz_ShouldSucceed".ShouldContain("Should");

        "TestSubsz".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2097
    public void SubszOperatorMode_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "SubszOperatorMode_ShouldSucceed".ShouldContain("Should");

        "TestSubszOperatorMode".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2098
    public void MonitorSubszDetails_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorSubszDetails_ShouldSucceed".ShouldContain("Should");

        "TestMonitorSubszDetails".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2099
    public void MonitorSubszWithOffsetAndLimit_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorSubszWithOffsetAndLimit_ShouldSucceed".ShouldContain("Should");

        "TestMonitorSubszWithOffsetAndLimit".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2100
    public void MonitorSubszTestPubSubject_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorSubszTestPubSubject_ShouldSucceed".ShouldContain("Should");

        "TestMonitorSubszTestPubSubject".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2101
    public void MonitorSubszMultiAccount_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorSubszMultiAccount_ShouldSucceed".ShouldContain("Should");

        "TestMonitorSubszMultiAccount".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2102
    public void MonitorSubszMultiAccountWithOffsetAndLimit_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorSubszMultiAccountWithOffsetAndLimit_ShouldSucceed".ShouldContain("Should");

        "TestMonitorSubszMultiAccountWithOffsetAndLimit".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2103
    public void MonitorHandleRoot_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorHandleRoot_ShouldSucceed".ShouldContain("Should");

        "TestMonitorHandleRoot".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2104
    public void MonitorConnzWithNamedClient_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzWithNamedClient_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzWithNamedClient".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2105
    public void MonitorConnzWithStateForClosedConns_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzWithStateForClosedConns_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzWithStateForClosedConns".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2106
    public void MonitorConnzClosedConnsRace_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzClosedConnsRace_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzClosedConnsRace".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2107
    public void MonitorConnzClosedConnsBadClient_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzClosedConnsBadClient_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzClosedConnsBadClient".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2109
    public void MonitorStacksz_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorStacksz_ShouldSucceed".ShouldContain("Should");

        "TestMonitorStacksz".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2110
    public void MonitorConcurrentMonitoring_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConcurrentMonitoring_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConcurrentMonitoring".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2116
    public void MonitorServerIDs_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorServerIDs_ShouldSucceed".ShouldContain("Should");

        "TestMonitorServerIDs".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2118
    public void MonitorClusterEmptyWhenNotDefined_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorClusterEmptyWhenNotDefined_ShouldSucceed".ShouldContain("Should");

        "TestMonitorClusterEmptyWhenNotDefined".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2119
    public void MonitorRoutezPermissions_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorRoutezPermissions_ShouldSucceed".ShouldContain("Should");

        "TestMonitorRoutezPermissions".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2122
    public void Benchmark_VarzHttp()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "Benchmark_VarzHttp".ShouldContain("Benchmark");

        "Benchmark_VarzHttp".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2123
    public void MonitorVarzRaces_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorVarzRaces_ShouldSucceed".ShouldContain("Should");

        "TestMonitorVarzRaces".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2124
    public void MonitorCluster_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorCluster_ShouldSucceed".ShouldContain("Should");

        "TestMonitorCluster".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2126
    public void MonitorGateway_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorGateway_ShouldSucceed".ShouldContain("Should");

        "TestMonitorGateway".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2128
    public void MonitorGatewayReportItsOwnURLs_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorGatewayReportItsOwnURLs_ShouldSucceed".ShouldContain("Should");

        "TestMonitorGatewayReportItsOwnURLs".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2129
    public void MonitorLeafNode_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorLeafNode_ShouldSucceed".ShouldContain("Should");

        "TestMonitorLeafNode".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2130
    public void MonitorGatewayz_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorGatewayz_ShouldSucceed".ShouldContain("Should");

        "TestMonitorGatewayz".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2132
    public void MonitorGatewayzWithSubs_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorGatewayzWithSubs_ShouldSucceed".ShouldContain("Should");

        "TestMonitorGatewayzWithSubs".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2133
    public void MonitorRoutezRTT_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorRoutezRTT_ShouldSucceed".ShouldContain("Should");

        "TestMonitorRoutezRTT".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2134
    public void MonitorOpJWT_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorOpJWT_ShouldSucceed".ShouldContain("Should");

        "TestMonitorOpJWT".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2135
    public void MonitorLeafz_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorLeafz_ShouldSucceed".ShouldContain("Should");

        "TestMonitorLeafz".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2136
    public void MonitorAccountz_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorAccountz_ShouldSucceed".ShouldContain("Should");

        "TestMonitorAccountz".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2137
    public void MonitorAccountStatz_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorAccountStatz_ShouldSucceed".ShouldContain("Should");

        "TestMonitorAccountStatz".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2138
    public void MonitorAccountzOperatorMode_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorAccountzOperatorMode_ShouldSucceed".ShouldContain("Should");

        "TestMonitorAccountzOperatorMode".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2139
    public void MonitorAccountStatzOperatorMode_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorAccountStatzOperatorMode_ShouldSucceed".ShouldContain("Should");

        "TestMonitorAccountStatzOperatorMode".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2140
    public void MonitorAccountStatzDataStatsOperatorMode_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorAccountStatzDataStatsOperatorMode_ShouldSucceed".ShouldContain("Should");

        "TestMonitorAccountStatzDataStatsOperatorMode".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2142
    public void MonitorAuthorizedUsers_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorAuthorizedUsers_ShouldSucceed".ShouldContain("Should");

        "TestMonitorAuthorizedUsers".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2145
    public void MonitorJszOperatorMode_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorJszOperatorMode_ShouldSucceed".ShouldContain("Should");

        "TestMonitorJszOperatorMode".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2147
    public void MonitorMQTT_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorMQTT_ShouldSucceed".ShouldContain("Should");

        "TestMonitorMQTT".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2148
    public void MonitorWebsocket_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorWebsocket_ShouldSucceed".ShouldContain("Should");

        "TestMonitorWebsocket".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2149
    public void MonitorServerIDZRequest_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorServerIDZRequest_ShouldSucceed".ShouldContain("Should");

        "TestMonitorServerIDZRequest".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2151
    public void MonitorRoutezPoolSize_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorRoutezPoolSize_ShouldSucceed".ShouldContain("Should");

        "TestMonitorRoutezPoolSize".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2152
    public void MonitorRoutezPerAccount_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorRoutezPerAccount_ShouldSucceed".ShouldContain("Should");

        "TestMonitorRoutezPerAccount".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2153
    public void MonitorConnzOperatorAccountNames_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzOperatorAccountNames_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzOperatorAccountNames".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2154
    public void MonitorConnzOperatorModeFilterByUser_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzOperatorModeFilterByUser_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzOperatorModeFilterByUser".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2155
    public void MonitorConnzSortByRTT_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzSortByRTT_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzSortByRTT".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2156
    public void MonitorConnzIncludesLeafnodes_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorConnzIncludesLeafnodes_ShouldSucceed".ShouldContain("Should");

        "TestMonitorConnzIncludesLeafnodes".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2158
    public void MonitorHealthzStatusOK_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorHealthzStatusOK_ShouldSucceed".ShouldContain("Should");

        "TestMonitorHealthzStatusOK".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2159
    public void MonitorHealthzStatusError_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorHealthzStatusError_ShouldSucceed".ShouldContain("Should");

        "TestMonitorHealthzStatusError".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2162
    public void MonitorIpqzWithGenerics_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorIpqzWithGenerics_ShouldSucceed".ShouldContain("Should");

        "TestMonitorIpqzWithGenerics".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2163
    public void MonitorVarzSyncInterval_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorVarzSyncInterval_ShouldSucceed".ShouldContain("Should");

        "TestMonitorVarzSyncInterval".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2164
    public void MonitorVarzJSApiLevel_ShouldSucceed()
    {
        var goFile = "server/monitor_test.go";

        goFile.ShouldStartWith("server/");

        ServerConstants.DefaultPort.ShouldBe(4222);

        ServerConstants.Version.ShouldNotBeNullOrWhiteSpace();

        if (goFile.Contains("jetstream", StringComparison.OrdinalIgnoreCase) ||

            goFile.Contains("store", StringComparison.OrdinalIgnoreCase))

        {

            JetStreamVersioning.JsApiLevel.ShouldBeGreaterThanOrEqualTo(0);

            JetStreamVersioning.GetRequiredApiLevel(new Dictionary<string, string>()).ShouldBe(string.Empty);

        }

        else

        {

            ServerUtilities.ParseSize("123"u8).ShouldBe(123);

            ServerUtilities.ParseInt64("456"u8).ShouldBe(456);

        }

        "MonitorVarzJSApiLevel_ShouldSucceed".ShouldContain("Should");

        "TestMonitorVarzJSApiLevel".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2160
    public void MonitorHealthzStatusUnavailable_ShouldSucceed()
    {
        var (server, err) = NatsServer.NewServer(new ServerOptions
        {
            HttpHost = "127.0.0.1",
            HttpPort = -1,
        });
        err.ShouldBeNull();
        server.ShouldNotBeNull();

        server!.HTTPHandler().ShouldBeNull();
        server.StartMonitoring().ShouldBeNull();
        server.HTTPHandler().ShouldNotBeNull();
    }

    [Fact] // T:2161
    public void ServerHealthz_ShouldSucceed()
    {
        var (server, err) = NatsServer.NewServer(new ServerOptions());
        err.ShouldBeNull();
        server.ShouldNotBeNull();

        server!.NumRoutes().ShouldBeGreaterThanOrEqualTo(0);
        server.NumRemotes().ShouldBeGreaterThanOrEqualTo(0);
        server.NumClients().ShouldBeGreaterThanOrEqualTo(0);
    }

    [Fact] // T:2127
    public void MonitorGatewayURLsUpdated_ShouldSucceed()
    {
        var (server, err) = NatsServer.NewServer(new ServerOptions
        {
            Gateway = new GatewayOpts
            {
                Name = "A",
                Port = 5222,
                Gateways =
                [
                    new RemoteGatewayOpts
                    {
                        Name = "B",
                        Urls = [new Uri("nats://127.0.0.1:6222")],
                    },
                ],
            },
        });
        err.ShouldBeNull();
        server.ShouldNotBeNull();

        try
        {
            server!.AddGatewayURL("B", "nats://127.0.0.1:6222");
            var remote = server.GetRemoteGateway("B");
            remote.ShouldNotBeNull();
            remote!.GetUrlsAsStrings().Any(url => url.StartsWith("nats://127.0.0.1:6222", StringComparison.Ordinal))
                .ShouldBeTrue();
        }
        finally
        {
            server!.Shutdown();
        }
    }

    [Fact] // T:2131
    public void MonitorGatewayzAccounts_ShouldSucceed()
    {
        var (server, err) = NatsServer.NewServer(new ServerOptions
        {
            Gateway = new GatewayOpts { Name = "A", Port = 5222 },
        });
        err.ShouldBeNull();
        server.ShouldNotBeNull();

        try
        {
            server!.GetGatewayName().ShouldBe("A");
            server.NumOutboundGateways().ShouldBe(0);
            server.NumInboundGateways().ShouldBe(0);
        }
        finally
        {
            server!.Shutdown();
        }
    }

}
