using Shouldly; using ZB.MOM.NatsNet.Server; namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog; public sealed partial class RouteHandlerTests { [Fact] // T:2854 public void RouteCompressionAuto_ShouldSucceed() { var errors = new List(); var warnings = new List(); var options = new ServerOptions(); var parseError = ServerOptions.ParseCluster( new Dictionary { ["name"] = "local", ["compression"] = new Dictionary { ["mode"] = CompressionModes.S2Auto, ["rtt_thresholds"] = new List { "100ms", "200ms", "300ms" }, }, }, options, errors, warnings); parseError.ShouldBeNull(); errors.ShouldBeEmpty(); options.Cluster.Compression.Mode.ShouldBe(CompressionModes.S2Auto); options.Cluster.Compression.RttThresholds.Count.ShouldBe(3); options.Cluster.Compression.RttThresholds[0].ShouldBe(TimeSpan.FromMilliseconds(100)); options.Cluster.Compression.RttThresholds[1].ShouldBe(TimeSpan.FromMilliseconds(200)); options.Cluster.Compression.RttThresholds[2].ShouldBe(TimeSpan.FromMilliseconds(300)); options = new ServerOptions(); errors.Clear(); warnings.Clear(); parseError = ServerOptions.ParseCluster( new Dictionary { ["compression"] = new Dictionary { ["mode"] = CompressionModes.S2Auto, ["rtt_thresholds"] = new List { "0ms", "100ms", "0ms", "300ms" }, }, }, options, errors, warnings); parseError.ShouldBeNull(); errors.ShouldBeEmpty(); options.Cluster.Compression.RttThresholds.Count.ShouldBe(4); options.Cluster.Compression.RttThresholds[0].ShouldBe(TimeSpan.Zero); options.Cluster.Compression.RttThresholds[1].ShouldBe(TimeSpan.FromMilliseconds(100)); options.Cluster.Compression.RttThresholds[2].ShouldBe(TimeSpan.Zero); options.Cluster.Compression.RttThresholds[3].ShouldBe(TimeSpan.FromMilliseconds(300)); options = new ServerOptions(); errors.Clear(); warnings.Clear(); parseError = ServerOptions.ParseCluster( new Dictionary { ["compression"] = false, }, options, errors, warnings); parseError.ShouldBeNull(); errors.ShouldBeEmpty(); options.Cluster.Compression.Mode.ShouldBe(CompressionModes.Off); } }