feat(dcl): coerce OPC UA array reads to typed list attributes; Bad quality on element mismatch
This commit is contained in:
+56
@@ -0,0 +1,56 @@
|
||||
using Opc.Ua;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests.Adapters;
|
||||
|
||||
/// <summary>
|
||||
/// MV-8: the OPC UA WRITE path (<see cref="RealOpcUaClient.WriteValueAsync"/>)
|
||||
/// wraps the outgoing value in <c>new Variant(value)</c> and lets the OPC
|
||||
/// Foundation SDK serialize it. For a structured multi-value (List) attribute
|
||||
/// the value handed down is a CLR array. These tests assert that the load-bearing
|
||||
/// step — wrapping an array in a <see cref="Variant"/> — succeeds without
|
||||
/// throwing, which is what the write path relies on (no separate array handling
|
||||
/// is required in our code). A full device round-trip needs a live server and is
|
||||
/// covered by the live OPC UA browse/read smoke tests.
|
||||
/// </summary>
|
||||
[Trait("Category", "Unit")]
|
||||
public class RealOpcUaClientArrayWriteTests
|
||||
{
|
||||
[Fact]
|
||||
public void Variant_wraps_int_array_without_throwing()
|
||||
{
|
||||
var value = new[] { 10, 20, 30 };
|
||||
|
||||
var ex = Record.Exception(() => new Variant(value));
|
||||
|
||||
Assert.Null(ex);
|
||||
var variant = new Variant(value);
|
||||
Assert.Equal(BuiltInType.Int32, variant.TypeInfo.BuiltInType);
|
||||
Assert.Equal(ValueRanks.OneDimension, variant.TypeInfo.ValueRank);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Variant_wraps_double_array_without_throwing()
|
||||
{
|
||||
var value = new[] { 1.5, 2.5, 3.5 };
|
||||
|
||||
var ex = Record.Exception(() => new Variant(value));
|
||||
|
||||
Assert.Null(ex);
|
||||
var variant = new Variant(value);
|
||||
Assert.Equal(BuiltInType.Double, variant.TypeInfo.BuiltInType);
|
||||
Assert.Equal(ValueRanks.OneDimension, variant.TypeInfo.ValueRank);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Variant_wraps_string_array_without_throwing()
|
||||
{
|
||||
var value = new[] { "a", "b", "c" };
|
||||
|
||||
var ex = Record.Exception(() => new Variant(value));
|
||||
|
||||
Assert.Null(ex);
|
||||
var variant = new Variant(value);
|
||||
Assert.Equal(BuiltInType.String, variant.TypeInfo.BuiltInType);
|
||||
Assert.Equal(ValueRanks.OneDimension, variant.TypeInfo.ValueRank);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user