fix(dcl): retry failed alarm re-subscribes, check alarm item create status, retry connection-level re-subscribe rows (DCL-2, DCL-3, DCL-8, WP3 task 3.2)
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
||||
using System.Reflection;
|
||||
using Opc.Ua;
|
||||
using Opc.Ua.Client;
|
||||
using ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Adapters;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests.Adapters;
|
||||
|
||||
/// <summary>
|
||||
/// DCL-3 (2026-12-02 review, WP3 task 3.2): <c>ApplyChangesAsync</c> does not throw for a
|
||||
/// per-item create failure, so the alarm path must read the event item's status — as the data
|
||||
/// path already does — instead of recording a rejected item as a live feed.
|
||||
/// </summary>
|
||||
public class RealOpcUaAlarmItemStatusTests
|
||||
{
|
||||
#pragma warning disable CS0618 // the parameterless MonitoredItem ctor is fine for a status-only probe
|
||||
private static MonitoredItem NewItem() => new();
|
||||
#pragma warning restore CS0618
|
||||
|
||||
// MonitoredItemStatus.SetError is not public; the SDK calls it when the server rejects a create.
|
||||
private static void SetError(MonitoredItem item, ServiceResult error) =>
|
||||
typeof(MonitoredItemStatus)
|
||||
.GetMethod("SetError", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)!
|
||||
.Invoke(item.Status, [error]);
|
||||
|
||||
/// <summary>A rejected create (e.g. BadNodeIdUnknown) is reported as the item's error.</summary>
|
||||
[Fact]
|
||||
public void RejectedItem_ReportsTheBadStatus()
|
||||
{
|
||||
var item = NewItem();
|
||||
SetError(item, new ServiceResult(StatusCodes.BadNodeIdUnknown));
|
||||
|
||||
var error = RealOpcUaClient.AlarmItemCreateError(item);
|
||||
|
||||
Assert.NotNull(error);
|
||||
Assert.Equal(StatusCodes.BadNodeIdUnknown, error!.StatusCode.Code);
|
||||
}
|
||||
|
||||
/// <summary>An item with no error (created) is not reported.</summary>
|
||||
[Fact]
|
||||
public void CreatedItem_ReportsNoError()
|
||||
{
|
||||
var item = NewItem();
|
||||
Assert.Null(RealOpcUaClient.AlarmItemCreateError(item));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user