Add probe/stale tag monitoring tests
Cover the full probe staleness detection path that was previously untested: stale probe forces reconnect, data changes prevent false staleness, no-probe config skips staleness check, probe tag subscribed on connect and protected from unsubscribe. 5 new tests, 184 total passing. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -101,5 +101,37 @@ namespace ZB.MOM.WW.LmxOpcUa.Tests.MxAccess
|
||||
_proxy.SimulateDataChangeByAddress("TestTag.Attr", "value", 192);
|
||||
callbackInvoked.ShouldBe(true);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ProbeTag_SubscribedOnConnect()
|
||||
{
|
||||
var proxy = new FakeMxProxy();
|
||||
var config = new MxAccessConfiguration { ProbeTag = "TestProbe" };
|
||||
var client = new MxAccessClient(_staThread, proxy, config, _metrics);
|
||||
|
||||
await client.ConnectAsync();
|
||||
|
||||
// Probe tag should be subscribed (present in proxy items)
|
||||
proxy.Items.Values.ShouldContain("TestProbe");
|
||||
client.Dispose();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task ProbeTag_ProtectedFromUnsubscribe()
|
||||
{
|
||||
var proxy = new FakeMxProxy();
|
||||
var config = new MxAccessConfiguration { ProbeTag = "TestProbe" };
|
||||
var client = new MxAccessClient(_staThread, proxy, config, _metrics);
|
||||
|
||||
await client.ConnectAsync();
|
||||
proxy.Items.Values.ShouldContain("TestProbe");
|
||||
|
||||
// Attempt to unsubscribe the probe tag — should be protected
|
||||
await client.UnsubscribeAsync("TestProbe");
|
||||
|
||||
// Probe should still be in the proxy items (not removed)
|
||||
proxy.Items.Values.ShouldContain("TestProbe");
|
||||
client.Dispose();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user