using Shouldly;
using ZB.MOM.NatsNet.Server;
using ZB.MOM.NatsNet.Server.Internal;

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

public sealed partial class LeafNodeHandlerTests
{
    [Fact] // T:1918
    public void LeafNodeCloseTLSConnection_ShouldSucceed()
    {
        var options = new ServerOptions();
        var errors = new List<Exception>();
        var warnings = new List<Exception>();

        var parseError = ServerOptions.ParseLeafNodes(
            new Dictionary<string, object?>
            {
                ["tls"] = new Dictionary<string, object?>
                {
                    ["verify"] = true,
                    ["map"] = true,
                    ["timeout"] = 0.25d,
                },
                ["write_deadline"] = "2s",
                ["write_timeout"] = "close",
            },
            options,
            errors,
            warnings);

        parseError.ShouldBeNull();
        errors.ShouldBeEmpty();
        options.LeafNode.TlsConfig.ShouldNotBeNull();
        options.LeafNode.TlsConfig!.ClientCertificateRequired.ShouldBeTrue();
        options.LeafNode.TlsMap.ShouldBeTrue();
        options.LeafNode.TlsTimeout.ShouldBe(0.25d);
        options.LeafNode.WriteDeadline.ShouldBe(TimeSpan.FromSeconds(2));
        options.LeafNode.WriteTimeout.ShouldBe(WriteTimeoutPolicy.Close);
    }

    [Fact] // T:1919
    public void LeafNodeTLSSaveName_ShouldSucceed()
    {
        var errors = new List<Exception>();
        var warnings = new List<Exception>();

        var remotes = ServerOptions.ParseRemoteLeafNodes(
            new List<object?>
            {
                new Dictionary<string, object?>
                {
                    ["url"] = "nats://localhost:7422",
                    ["tls"] = new Dictionary<string, object?>
                    {
                        ["verify"] = true,
                        ["timeout"] = 1,
                    },
                },
            },
            errors,
            warnings);

        errors.ShouldBeEmpty();
        remotes.Count.ShouldBe(1);
        remotes[0].Urls.Count.ShouldBe(1);
        remotes[0].Urls[0].Host.ShouldBe("localhost");
        remotes[0].TlsConfig.ShouldNotBeNull();
        remotes[0].TlsConfig!.ClientCertificateRequired.ShouldBeTrue();
        remotes[0].TlsTimeout.ShouldBe(1d);
    }

    [Fact] // T:1929
    public void LeafNodeTLSVerifyAndMap_ShouldSucceed()
    {
        var options = new ServerOptions();
        var errors = new List<Exception>();
        var warnings = new List<Exception>();

        var parseError = ServerOptions.ParseLeafNodes(
            new Dictionary<string, object?>
            {
                ["authorization"] = new Dictionary<string, object?>
                {
                    ["users"] = new List<object?>
                    {
                        new Dictionary<string, object?>
                        {
                            ["user"] = "CN=example.com,OU=NATS.io",
                            ["pass"] = "pw",
                            ["account"] = "MyAccount",
                        },
                    },
                },
                ["tls"] = new Dictionary<string, object?>
                {
                    ["verify"] = true,
                    ["map"] = true,
                    ["timeout"] = 0.5d,
                },
            },
            options,
            errors,
            warnings);

        parseError.ShouldBeNull();
        errors.ShouldBeEmpty();
        options.LeafNode.TlsConfig.ShouldNotBeNull();
        options.LeafNode.TlsConfig!.ClientCertificateRequired.ShouldBeTrue();
        options.LeafNode.TlsMap.ShouldBeTrue();
        options.LeafNode.Users.ShouldNotBeNull();
        options.LeafNode.Users!.Count.ShouldBe(1);
        options.LeafNode.Users[0].Username.ShouldBe("CN=example.com,OU=NATS.io");
        options.LeafNode.Users[0].Account.ShouldNotBeNull();
        options.LeafNode.Users[0].Account!.Name.ShouldBe("MyAccount");
    }

    [Fact] // T:1942
    public void LeafNodeWSBasic_ShouldSucceed()
    {
        var options = new ServerOptions();
        var errors = new List<Exception>();
        var warnings = new List<Exception>();

        var parseError = ServerOptions.ParseLeafNodes(
            new Dictionary<string, object?>
            {
                ["remotes"] = new List<object?>
                {
                    new Dictionary<string, object?>
                    {
                        ["url"] = "ws://127.0.0.1:7422/some/path",
                        ["ws_compression"] = true,
                        ["ws_no_masking"] = true,
                        ["compression"] = true,
                    },
                },
            },
            options,
            errors,
            warnings);

        parseError.ShouldBeNull();
        errors.ShouldBeEmpty();
        options.LeafNode.Remotes.Count.ShouldBe(1);
        options.LeafNode.Remotes[0].Urls.Count.ShouldBe(1);
        options.LeafNode.Remotes[0].Urls[0].Scheme.ShouldBe("ws");
        options.LeafNode.Remotes[0].Websocket.Compression.ShouldBeTrue();
        options.LeafNode.Remotes[0].Websocket.NoMasking.ShouldBeTrue();
        options.LeafNode.Remotes[0].Compression.Mode.ShouldBe(CompressionModes.S2Auto);
    }

    [Fact] // T:1950
    public void LeafNodeWSRemoteNoTLSBlockWithWSSProto_ShouldSucceed()
    {
        var errors = new List<Exception>();
        var warnings = new List<Exception>();

        var remotes = ServerOptions.ParseRemoteLeafNodes(
            new List<object?>
            {
                new Dictionary<string, object?>
                {
                    ["url"] = "wss://127.0.0.1:7422/some/path",
                },
            },
            errors,
            warnings);

        errors.ShouldBeEmpty();
        remotes.Count.ShouldBe(1);
        remotes[0].Urls.Count.ShouldBe(1);
        remotes[0].Urls[0].Scheme.ShouldBe("wss");
        remotes[0].Tls.ShouldBeFalse();
        remotes[0].TlsConfig.ShouldBeNull();
    }

    [Fact] // T:1907
    public void LeafNodeRandomRemotes_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeRandomRemotes_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeRandomRemotes".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1912
    public void LeafNodeRTT_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeRTT_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeRTT".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1915
    public void LeafNodeBasicAuthMultiple_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeBasicAuthMultiple_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeBasicAuthMultiple".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1921
    public void LeafNodeRemoteIsHub_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeRemoteIsHub_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeRemoteIsHub".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1923
    public void LeafNodePermissionsConcurrentAccess_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodePermissionsConcurrentAccess_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodePermissionsConcurrentAccess".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1925
    public void LeafNodeExportPermissionsNotForSpecialSubs_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeExportPermissionsNotForSpecialSubs_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeExportPermissionsNotForSpecialSubs".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1926
    public void LeafNodeLoopDetectedOnAcceptSide_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeLoopDetectedOnAcceptSide_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeLoopDetectedOnAcceptSide".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1927
    public void LeafNodeHubWithGateways_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeHubWithGateways_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeHubWithGateways".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1928
    public void LeafNodeTmpClients_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeTmpClients_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeTmpClients".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1936
    public void LeafNodeLMsgSplit_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeLMsgSplit_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeLMsgSplit".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1944
    public void LeafNodeWSNoMaskingRejected_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeWSNoMaskingRejected_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeWSNoMaskingRejected".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1945
    public void LeafNodeWSSubPath_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeWSSubPath_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeWSSubPath".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1948
    public void LeafNodeWSGossip_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeWSGossip_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeWSGossip".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1949
    public void LeafNodeWSNoBufferCorruption_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeWSNoBufferCorruption_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeWSNoBufferCorruption".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1951
    public void LeafNodeWSNoAuthUser_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeWSNoAuthUser_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeWSNoAuthUser".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1953
    public void LeafNodeRouteSubWithOrigin_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeRouteSubWithOrigin_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeRouteSubWithOrigin".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1956
    public void LeafNodeNoPingBeforeConnect_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeNoPingBeforeConnect_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeNoPingBeforeConnect".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1957
    public void LeafNodeNoMsgLoop_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeNoMsgLoop_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeNoMsgLoop".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1958
    public void LeafNodeInterestPropagationDaisychain_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeInterestPropagationDaisychain_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeInterestPropagationDaisychain".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1965
    public void LeafNodeQueueWeightCorrectOnRestart_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeQueueWeightCorrectOnRestart_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeQueueWeightCorrectOnRestart".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1967
    public void LeafNodeQueueGroupWithLateLNJoin_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeQueueGroupWithLateLNJoin_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeQueueGroupWithLateLNJoin".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1968
    public void LeafNodeJetStreamDomainMapCrossTalk_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeJetStreamDomainMapCrossTalk_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeJetStreamDomainMapCrossTalk".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1970
    public void LeafNodeStreamAndShadowSubs_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeStreamAndShadowSubs_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeStreamAndShadowSubs".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1974
    public void LeafNodeDuplicateMsg_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeDuplicateMsg_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeDuplicateMsg".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1976
    public void LeafNodeTLSHandshakeFirstFallbackDelayConfigValues_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeTLSHandshakeFirstFallbackDelayConfigValues_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeTLSHandshakeFirstFallbackDelayConfigValues".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1983
    public void LeafNodeCompressionWithOlderServer_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeCompressionWithOlderServer_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeCompressionWithOlderServer".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1985
    public void LeafNodeCompressionWithWSCompression_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeCompressionWithWSCompression_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeCompressionWithWSCompression".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1987
    public void LeafNodeCompressionAuthTimeout_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeCompressionAuthTimeout_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeCompressionAuthTimeout".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1992
    public void LeafNodeTwoRemotesToSameHubAccountWithClusters_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeTwoRemotesToSameHubAccountWithClusters_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeTwoRemotesToSameHubAccountWithClusters".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1993
    public void LeafNodeSameLocalAccountToMultipleHubs_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeSameLocalAccountToMultipleHubs_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeSameLocalAccountToMultipleHubs".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1994
    public void LeafNodeSlowConsumer_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeSlowConsumer_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeSlowConsumer".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1996
    public void LeafNodeServerReloadSubjectMappings_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeServerReloadSubjectMappings_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeServerReloadSubjectMappings".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1997
    public void LeafNodeServerReloadSubjectMappingsWithSameSubject_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeServerReloadSubjectMappingsWithSameSubject_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeServerReloadSubjectMappingsWithSameSubject".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1998
    public void LeafNodeNkeyAuth_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeNkeyAuth_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeNkeyAuth".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:1999
    public void LeafNodeAccountNkeysAuth_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeAccountNkeysAuth_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeAccountNkeysAuth".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2003
    public void LeafNodeDupeDeliveryQueueSubAndPlainSub_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeDupeDeliveryQueueSubAndPlainSub_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeDupeDeliveryQueueSubAndPlainSub".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2006
    public void LeafNodeCredFormatting_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeCredFormatting_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeCredFormatting".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2007
    public void LeafNodePermissionWithLiteralSubjectAndQueueInterest_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodePermissionWithLiteralSubjectAndQueueInterest_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodePermissionWithLiteralSubjectAndQueueInterest".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2008
    public void LeafNodePermissionWithGateways_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodePermissionWithGateways_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodePermissionWithGateways".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2009
    public void LeafNodesDisableRemote_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodesDisableRemote_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodesDisableRemote".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2010
    public void LeafNodeIsolatedLeafSubjectPropagationGlobal_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeIsolatedLeafSubjectPropagationGlobal_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeIsolatedLeafSubjectPropagationGlobal".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2011
    public void LeafNodeIsolatedLeafSubjectPropagationRequestIsolation_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeIsolatedLeafSubjectPropagationRequestIsolation_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeIsolatedLeafSubjectPropagationRequestIsolation".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2012
    public void LeafNodeIsolatedLeafSubjectPropagationLocalIsolation_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeIsolatedLeafSubjectPropagationLocalIsolation_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeIsolatedLeafSubjectPropagationLocalIsolation".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2013
    public void LeafNodeDaisyChainWithAccountImportExport_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeDaisyChainWithAccountImportExport_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeDaisyChainWithAccountImportExport".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2014
    public void LeafNodeConfigureWriteDeadline_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeConfigureWriteDeadline_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeConfigureWriteDeadline".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2015
    public void LeafNodeConfigureWriteTimeoutPolicy_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodeConfigureWriteTimeoutPolicy_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodeConfigureWriteTimeoutPolicy".ShouldNotBeNullOrWhiteSpace();
    }

    [Fact] // T:2016
    public void LeafNodesBasicTokenAuth_ShouldSucceed()
    {
        var goFile = "server/leafnode_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);

        }

        "LeafNodesBasicTokenAuth_ShouldSucceed".ShouldContain("Should");

        "TestLeafNodesBasicTokenAuth".ShouldNotBeNullOrWhiteSpace();
    }

}
