From f81fa768097d64a7c243b7879fd95194dc1a9c12 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Fri, 19 Jun 2026 01:57:53 -0400 Subject: [PATCH] test(cli): assert Enable/Disable object node + add suffix-idempotency test Closes the code-review gap: the Enable/Disable success tests now assert the derived '.Condition' object node (the CallMethodObjectIds capture was added but unused), and a new test proves an already-suffixed condition node isn't double-suffixed (mirrors AcknowledgeAlarmAsync_LeavesConditionSuffixAlone). --- .../OpcUaClientServiceTests.cs | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/Client/ZB.MOM.WW.OtOpcUa.Client.Shared.Tests/OpcUaClientServiceTests.cs b/tests/Client/ZB.MOM.WW.OtOpcUa.Client.Shared.Tests/OpcUaClientServiceTests.cs index 820d30b4..631c8668 100644 --- a/tests/Client/ZB.MOM.WW.OtOpcUa.Client.Shared.Tests/OpcUaClientServiceTests.cs +++ b/tests/Client/ZB.MOM.WW.OtOpcUa.Client.Shared.Tests/OpcUaClientServiceTests.cs @@ -1191,6 +1191,7 @@ public class OpcUaClientServiceTests : IDisposable result.ShouldBe(StatusCodes.Good); session.CallMethodCount.ShouldBe(1); + session.CallMethodObjectIds[0].ShouldBe(NodeId.Parse("ns=2;s=Cond.Condition")); session.CallMethodMethodIds[0].ShouldBe(MethodIds.ConditionType_Enable); session.CallMethodInputArgs[0].ShouldBeEmpty(); } @@ -1210,10 +1211,31 @@ public class OpcUaClientServiceTests : IDisposable result.ShouldBe(StatusCodes.Good); session.CallMethodCount.ShouldBe(1); + session.CallMethodObjectIds[0].ShouldBe(NodeId.Parse("ns=2;s=Cond.Condition")); session.CallMethodMethodIds[0].ShouldBe(MethodIds.ConditionType_Disable); session.CallMethodInputArgs[0].ShouldBeEmpty(); } + /// + /// Verifies the ".Condition" suffix is appended when the caller supplies the source node, + /// but left alone when the caller already passes the condition node — mirrors + /// for the Enable path so the + /// object-node derivation in CallEnableDisableAsync is regression-covered. + /// + [Fact] + public async Task EnableAsync_WhenConditionSuffixAlreadyPresent_DoesNotDoubleSuffix() + { + var session = new FakeSessionAdapter(); + _sessionFactory.EnqueueSession(session); + await _service.ConnectAsync(ValidSettings()); + + var result = await _service.EnableAsync("ns=2;s=Cond.Condition"); + + result.ShouldBe(StatusCodes.Good); + session.CallMethodCount.ShouldBe(1); + session.CallMethodObjectIds[0].ShouldBe(NodeId.Parse("ns=2;s=Cond.Condition")); + } + /// /// Verifies that a from the session is captured and /// returned as a bad rather than propagating to the caller.