test(opcua): cover null-arrayLength dimension + tighten scalar assertion (review)
This commit is contained in:
@@ -43,6 +43,26 @@ public sealed class NodeManagerArrayTests : IDisposable
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>When arrayLength is null the created node must still be a 1-D array (ValueRank=OneDimension)
|
||||
/// with ArrayDimensions [0] — the "unfixed-length" contract.</summary>
|
||||
[Fact]
|
||||
public async Task EnsureVariable_with_null_arrayLength_sets_dimension_zero()
|
||||
{
|
||||
var (host, server) = await BootAsync();
|
||||
var nm = server.NodeManager!;
|
||||
|
||||
nm.EnsureVariable("eq-1/arr-unfixed", parentFolderNodeId: null, displayName: "arr-unfixed", dataType: "Int32",
|
||||
writable: false, historianTagname: null, isArray: true, arrayLength: null);
|
||||
|
||||
var variable = nm.TryGetVariable("eq-1/arr-unfixed");
|
||||
variable.ShouldNotBeNull();
|
||||
variable!.ValueRank.ShouldBe(ValueRanks.OneDimension);
|
||||
variable.ArrayDimensions.ShouldNotBeNull();
|
||||
variable.ArrayDimensions.ShouldBe(new uint[] { 0u });
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>A default (scalar) EnsureVariable call keeps ValueRank=Scalar and leaves
|
||||
/// ArrayDimensions null/empty.</summary>
|
||||
[Fact]
|
||||
@@ -57,7 +77,7 @@ public sealed class NodeManagerArrayTests : IDisposable
|
||||
var variable = nm.TryGetVariable("eq-1/scalar");
|
||||
variable.ShouldNotBeNull();
|
||||
variable!.ValueRank.ShouldBe(ValueRanks.Scalar);
|
||||
(variable.ArrayDimensions is null || variable.ArrayDimensions.Count == 0).ShouldBeTrue();
|
||||
variable.ArrayDimensions.ShouldBeNull();
|
||||
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user