fix: preserve SDK 2.0 client value and lifetime contracts

This commit is contained in:
Joseph Doherty
2026-11-10 10:19:42 -05:00
parent 0ecea3c6be
commit 3ca06e1b87
38 changed files with 591 additions and 186 deletions
@@ -7,32 +7,29 @@ namespace ZB.MOM.WW.OtOpcUa.Client.Shared.Tests.Helpers;
public class HistoryReadStatusTests
{
public static IEnumerable<object[]> Refusals() => new[] { StatusCodes.BadHistoryOperationUnsupported,
StatusCodes.BadUserAccessDenied, StatusCodes.BadNodeIdUnknown, StatusCodes.BadTimeout }.Select(s => new object[] { s });
public static IEnumerable<object[]> NonRefusals() => new[] { StatusCodes.Good, StatusCodes.GoodNoData,
StatusCodes.GoodMoreData, StatusCodes.UncertainNoCommunicationLastUsableValue, StatusCodes.BadNoData }.Select(s => new object[] { s });
/// <summary>A refused read must surface, carrying the status code, rather than read as an empty result.</summary>
/// <param name="code">The Bad per-node status code.</param>
[Theory]
[InlineData(StatusCodes.BadHistoryOperationUnsupported)]
[InlineData(StatusCodes.BadUserAccessDenied)]
[InlineData(StatusCodes.BadNodeIdUnknown)]
[InlineData(StatusCodes.BadTimeout)]
public void Bad_status_throws_ServiceResultException_with_the_code(uint code)
[MemberData(nameof(Refusals))]
public void Bad_status_throws_ServiceResultException_with_the_code(StatusCode code)
{
var ex = Should.Throw<ServiceResultException>(
() => HistoryReadStatus.ThrowIfRefused(new StatusCode(code), new NodeId("n", 2)));
() => HistoryReadStatus.ThrowIfRefused(code, new NodeId("n", 2)));
ex.StatusCode.ShouldBe(code);
ex.StatusCode.ShouldBe(code.Code);
ex.Message.ShouldContain("ns=2;s=n");
}
/// <summary>Good, GoodNoData, Uncertain and BadNoData are all non-refusals (the window may simply be empty).</summary>
/// <param name="code">The non-refusal status code.</param>
[Theory]
[InlineData(StatusCodes.Good)]
[InlineData(StatusCodes.GoodNoData)]
[InlineData(StatusCodes.GoodMoreData)]
[InlineData(StatusCodes.UncertainNoCommunicationLastUsableValue)]
[InlineData(StatusCodes.BadNoData)]
public void Non_refusal_status_does_not_throw(uint code)
[MemberData(nameof(NonRefusals))]
public void Non_refusal_status_does_not_throw(StatusCode code)
{
Should.NotThrow(() => HistoryReadStatus.ThrowIfRefused(new StatusCode(code), new NodeId("n", 2)));
Should.NotThrow(() => HistoryReadStatus.ThrowIfRefused(code, new NodeId("n", 2)));
}
}