using Shouldly; using ZB.MOM.NatsNet.Server; namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog; public sealed class ConfigReloaderTests { [Fact] // T:2766 public void ConfigReloadBoolFlags_ShouldSucceed() { var options = new ServerOptions(); var errors = new List(); var warnings = new List(); ServerOptions.ParseCluster( new Dictionary { ["no_advertise"] = true, ["connect_backoff"] = true, }, options, errors, warnings); errors.ShouldBeEmpty(); options.Cluster.NoAdvertise.ShouldBeTrue(); options.Cluster.ConnectBackoff.ShouldBeTrue(); options.InConfig.TryGetValue("Cluster.NoAdvertise", out var explicitValue).ShouldBeTrue(); explicitValue.ShouldBeTrue(); } [Fact] public void ParseCluster_WithUnknownFieldAndStrictMode_ReturnsError() { ServerOptions.NoErrOnUnknownFields(false); var options = new ServerOptions(); var errors = new List(); ServerOptions.ParseCluster( new Dictionary { ["unknown_cluster_field"] = true, }, options, errors, warnings: null); errors.Count.ShouldBe(1); errors[0].Message.ShouldContain("unknown field"); } [Fact] public void ParseCluster_WithUnknownFieldAndRelaxedMode_IgnoresUnknownField() { ServerOptions.NoErrOnUnknownFields(true); try { var options = new ServerOptions(); var errors = new List(); ServerOptions.ParseCluster( new Dictionary { ["unknown_cluster_field"] = true, }, options, errors, warnings: null); errors.ShouldBeEmpty(); } finally { ServerOptions.NoErrOnUnknownFields(false); } } }