4f6231fa40
The drain gate counted SyncListenPort; a port with no ApiKey shares nothing (fail-closed passive endpoint), and an ApiKey-only passive node shares its queue but was never gated. Claude-Session: https://claude.ai/code/session_01Ef2ozxS7QPanGT8uoATbTe
33 lines
1.4 KiB
C#
33 lines
1.4 KiB
C#
using Microsoft.Extensions.Configuration;
|
|
using Shouldly;
|
|
using Xunit;
|
|
|
|
namespace ZB.MOM.WW.OtOpcUa.Runtime.Tests.Historian;
|
|
|
|
/// <summary>#603: the single "is this node's LocalDb replicated" predicate shared by table registration and the alarm drain gate.</summary>
|
|
public sealed class LocalDbReplicationPolicyTests
|
|
{
|
|
private static IConfiguration Config(params (string Key, string? Value)[] pairs) =>
|
|
new ConfigurationBuilder()
|
|
.AddInMemoryCollection(pairs.Select(p => new KeyValuePair<string, string?>(p.Key, p.Value)))
|
|
.Build();
|
|
|
|
/// <summary>PeerAddress OR ApiKey counts; the listen port alone and blank values do not.</summary>
|
|
[Theory]
|
|
[InlineData("LocalDb:Replication:PeerAddress", "http://peer:9001", true)]
|
|
[InlineData("LocalDb:Replication:ApiKey", "k", true)]
|
|
[InlineData("LocalDb:SyncListenPort", "9001", false)]
|
|
[InlineData("LocalDb:Replication:ApiKey", " ", false)]
|
|
public void IsConfigured_follows_the_PeerAddress_or_ApiKey_rule(string key, string value, bool expected)
|
|
{
|
|
LocalDbReplicationPolicy.IsConfigured(Config((key, value))).ShouldBe(expected);
|
|
}
|
|
|
|
/// <summary>No replication keys at all is an unpaired node.</summary>
|
|
[Fact]
|
|
public void IsConfigured_is_false_for_an_empty_configuration()
|
|
{
|
|
LocalDbReplicationPolicy.IsConfigured(Config()).ShouldBeFalse();
|
|
}
|
|
}
|