fix(otopcua): report NodeAdded model-change outside the node Lock
This commit is contained in:
@@ -60,6 +60,30 @@ public sealed class NodeManagerModelChangeOnAddTests : IDisposable
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>For an affected id that is not (yet) materialised, the built event still announces NodeAdded but
|
||||
/// its AffectedType falls back to <see cref="NodeId.Null"/> (a valid Part 3 "type not applicable") — the
|
||||
/// documented fallback of <see cref="OtOpcUaNodeManager.BuildNodesAddedModelChange"/>, locked in as an
|
||||
/// invariant.</summary>
|
||||
[Trait("Category", "Unit")]
|
||||
[Fact]
|
||||
public async Task Built_event_for_unknown_id_falls_back_to_null_AffectedType()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
// No EnsureFolder/EnsureVariable for this id — it is not in the node maps.
|
||||
var e = nm.BuildNodesAddedModelChange("eq-unknown");
|
||||
|
||||
e.ShouldNotBeNull();
|
||||
e.Changes.ShouldNotBeNull();
|
||||
var changes = e.Changes.Value;
|
||||
changes.Length.ShouldBe(1);
|
||||
changes[0].Verb.ShouldBe((byte)ModelChangeStructureVerbMask.NodeAdded);
|
||||
changes[0].AffectedType.ShouldBe(NodeId.Null);
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>Raising the announcement is tolerant: callable before any nodes exist (unknown affected id ⇒
|
||||
/// AffectedType defaults to null, still a valid Part 3 change) AND after they are materialised, and never
|
||||
/// throws even when the event path reaches no monitored items (same tolerance as the write-revert path).</summary>
|
||||
|
||||
Reference in New Issue
Block a user