test(batch19): port accounts core mapped tests

This commit is contained in:
Joseph Doherty
2026-02-28 20:28:13 -05:00
parent e53b4aa17a
commit 8d00012ba8
5 changed files with 190 additions and 0 deletions

View File

@@ -6,6 +6,41 @@ namespace ZB.MOM.NatsNet.Server.Tests.ImplBacklog;
public sealed class MessageTracerTests
{
[Fact] // T:2359
public void MsgTraceParseAccountDestWithSampling_ShouldSucceed()
{
var cases = new[]
{
(Name: "trace sampling no dest", Value: (object)new Dictionary<string, object?> { ["sampling"] = 50 }, Want: 0),
(Name: "trace dest only", Value: (object)new Dictionary<string, object?> { ["dest"] = "foo" }, Want: 100),
(Name: "trace dest with number only", Value: (object)new Dictionary<string, object?> { ["dest"] = "foo", ["sampling"] = 20 }, Want: 20),
(Name: "trace dest with percentage", Value: (object)new Dictionary<string, object?> { ["dest"] = "foo", ["sampling"] = "50%" }, Want: 50),
};
foreach (var testCase in cases)
{
var options = new ServerOptions();
var errors = new List<Exception>();
var warnings = new List<Exception>();
var accounts = new Dictionary<string, object?>
{
["A"] = new Dictionary<string, object?>
{
["msg_trace"] = testCase.Value,
},
};
var parseError = ServerOptions.ParseAccounts(accounts, options, errors, warnings);
parseError.ShouldBeNull(testCase.Name);
errors.ShouldBeEmpty(testCase.Name);
options.Accounts.Count.ShouldBe(1, testCase.Name);
var (_, sampling) = options.Accounts[0].GetTraceDestAndSampling();
sampling.ShouldBe(testCase.Want, testCase.Name);
}
}
[Fact] // T:2331
public void MsgTraceBasic_ShouldSucceed()
{