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).
This commit is contained in:
@@ -1191,6 +1191,7 @@ public class OpcUaClientServiceTests : IDisposable
|
|||||||
|
|
||||||
result.ShouldBe(StatusCodes.Good);
|
result.ShouldBe(StatusCodes.Good);
|
||||||
session.CallMethodCount.ShouldBe(1);
|
session.CallMethodCount.ShouldBe(1);
|
||||||
|
session.CallMethodObjectIds[0].ShouldBe(NodeId.Parse("ns=2;s=Cond.Condition"));
|
||||||
session.CallMethodMethodIds[0].ShouldBe(MethodIds.ConditionType_Enable);
|
session.CallMethodMethodIds[0].ShouldBe(MethodIds.ConditionType_Enable);
|
||||||
session.CallMethodInputArgs[0].ShouldBeEmpty();
|
session.CallMethodInputArgs[0].ShouldBeEmpty();
|
||||||
}
|
}
|
||||||
@@ -1210,10 +1211,31 @@ public class OpcUaClientServiceTests : IDisposable
|
|||||||
|
|
||||||
result.ShouldBe(StatusCodes.Good);
|
result.ShouldBe(StatusCodes.Good);
|
||||||
session.CallMethodCount.ShouldBe(1);
|
session.CallMethodCount.ShouldBe(1);
|
||||||
|
session.CallMethodObjectIds[0].ShouldBe(NodeId.Parse("ns=2;s=Cond.Condition"));
|
||||||
session.CallMethodMethodIds[0].ShouldBe(MethodIds.ConditionType_Disable);
|
session.CallMethodMethodIds[0].ShouldBe(MethodIds.ConditionType_Disable);
|
||||||
session.CallMethodInputArgs[0].ShouldBeEmpty();
|
session.CallMethodInputArgs[0].ShouldBeEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 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
|
||||||
|
/// <see cref="AcknowledgeAlarmAsync_LeavesConditionSuffixAlone"/> for the Enable path so the
|
||||||
|
/// object-node derivation in CallEnableDisableAsync is regression-covered.
|
||||||
|
/// </summary>
|
||||||
|
[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"));
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Verifies that a <see cref="ServiceResultException"/> from the session is captured and
|
/// Verifies that a <see cref="ServiceResultException"/> from the session is captured and
|
||||||
/// returned as a bad <see cref="StatusCode"/> rather than propagating to the caller.
|
/// returned as a bad <see cref="StatusCode"/> rather than propagating to the caller.
|
||||||
|
|||||||
Reference in New Issue
Block a user