diff --git a/dotnet/src/ZB.MOM.NatsNet.Server/Config/NatsJsonConverters.cs b/dotnet/src/ZB.MOM.NatsNet.Server/Config/NatsJsonConverters.cs index 5bc453a..ccf4fc3 100644 --- a/dotnet/src/ZB.MOM.NatsNet.Server/Config/NatsJsonConverters.cs +++ b/dotnet/src/ZB.MOM.NatsNet.Server/Config/NatsJsonConverters.cs @@ -152,6 +152,8 @@ public sealed class StorageSizeJsonConverter : JsonConverter public static long Parse(string s) { + // Mirrors Go getStorageSize: empty string returns 0 with no error. + if (string.IsNullOrWhiteSpace(s)) return 0; if (long.TryParse(s, out var n)) return n; var m = Pattern.Match(s.Trim()); if (!m.Success) throw new FormatException($"Invalid storage size: \"{s}\""); diff --git a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ServerOptionsTests.cs b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ServerOptionsTests.cs index 85dd93a..f69c188 100644 --- a/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ServerOptionsTests.cs +++ b/dotnet/tests/ZB.MOM.NatsNet.Server.Tests/ServerOptionsTests.cs @@ -3,6 +3,7 @@ using Shouldly; using ZB.MOM.NatsNet.Server; +using ZB.MOM.NatsNet.Server.Config; namespace ZB.MOM.NatsNet.Server.Tests; @@ -330,4 +331,54 @@ public class ServerOptionsTests var r2 = ServerOptions.MergeOptions(null, flagOpts); r2.Port.ShouldBe(5678); } + + /// + /// Mirrors TestListenMonitoringDefault — when Host is set without HTTPHost, + /// SetBaselineOptions should copy Host to HTTPHost. + /// + [Fact] // T:2524 + public void ListenMonitoringDefault_ShouldSetHttpHostToHost() + { + var opts = new ServerOptions { Host = "10.0.1.22" }; + opts.SetBaselineOptions(); + + opts.Host.ShouldBe("10.0.1.22"); + opts.HttpHost.ShouldBe("10.0.1.22"); + opts.Port.ShouldBe(ServerConstants.DefaultPort); + } + + /// + /// Mirrors TestGetStorageSize — StorageSizeJsonConverter.Parse converts K/M/G/T suffixes + /// and returns 0 for empty input; invalid suffixes throw. + /// + [Fact] // T:2576 + public void GetStorageSize_ShouldParseSuffixes() + { + StorageSizeJsonConverter.Parse("1K").ShouldBe(1024L); + StorageSizeJsonConverter.Parse("1M").ShouldBe(1048576L); + StorageSizeJsonConverter.Parse("1G").ShouldBe(1073741824L); + StorageSizeJsonConverter.Parse("1T").ShouldBe(1099511627776L); + StorageSizeJsonConverter.Parse("").ShouldBe(0L); + + Should.Throw(() => StorageSizeJsonConverter.Parse("1L")); + Should.Throw(() => StorageSizeJsonConverter.Parse("TT")); + } + + /// + /// Mirrors TestClusterNameAndGatewayNameConflict — when Cluster.Name != Gateway.Name, + /// ValidateOptions should return ErrClusterNameConfigConflict. + /// + [Fact] // T:2571 + public void ClusterNameAndGatewayNameConflict_ShouldReturnConflictError() + { + var opts = new ServerOptions + { + Cluster = new ClusterOpts { Name = "A", Port = -1 }, + Gateway = new GatewayOpts { Name = "B", Port = -1 }, + }; + + var err = NatsServer.ValidateOptions(opts); + err.ShouldNotBeNull(); + err.ShouldBe(ServerErrors.ErrClusterNameConfigConflict); + } } diff --git a/porting.db b/porting.db index c6654d1..9d457ab 100644 Binary files a/porting.db and b/porting.db differ diff --git a/reports/current.md b/reports/current.md index 23f5f2e..3fbc5cf 100644 --- a/reports/current.md +++ b/reports/current.md @@ -1,6 +1,6 @@ # NATS .NET Porting Status Report -Generated: 2026-02-26 23:53:55 UTC +Generated: 2026-02-27 00:00:19 UTC ## Modules (12 total) @@ -21,10 +21,11 @@ Generated: 2026-02-26 23:53:55 UTC | Status | Count | |--------|-------| -| complete | 205 | +| complete | 208 | +| deferred | 74 | | n_a | 187 | | not_started | 2527 | -| stub | 224 | +| stub | 147 | | verified | 114 | ## Library Mappings (36 total) @@ -36,4 +37,4 @@ Generated: 2026-02-26 23:53:55 UTC ## Overall Progress -**4190/6942 items complete (60.4%)** +**4193/6942 items complete (60.4%)** diff --git a/reports/report_8b63a6f.md b/reports/report_8b63a6f.md new file mode 100644 index 0000000..3fbc5cf --- /dev/null +++ b/reports/report_8b63a6f.md @@ -0,0 +1,40 @@ +# NATS .NET Porting Status Report + +Generated: 2026-02-27 00:00:19 UTC + +## Modules (12 total) + +| Status | Count | +|--------|-------| +| not_started | 1 | +| verified | 11 | + +## Features (3673 total) + +| Status | Count | +|--------|-------| +| complete | 3368 | +| n_a | 26 | +| verified | 279 | + +## Unit Tests (3257 total) + +| Status | Count | +|--------|-------| +| complete | 208 | +| deferred | 74 | +| n_a | 187 | +| not_started | 2527 | +| stub | 147 | +| verified | 114 | + +## Library Mappings (36 total) + +| Status | Count | +|--------|-------| +| mapped | 36 | + + +## Overall Progress + +**4193/6942 items complete (60.4%)**