513fa1aa16
Comment/XML-doc changes only: - add summaries to ~10k test methods, fixtures, fakes and helpers (+ <param> on theories, <returns> on async Task methods, <inheritdoc/> on interface implementations the checker can resolve) - strip ~2.6k project-tracking references (WP*, P*-*, row-NN, Task N, #NN, Component-0NN) from comments, keeping the explanatory text; reword false positives in comments only - real docs on fakes implementing BCL/library interfaces (IDisposable, ILogger, IOptionsMonitor, IAsyncLifetime) - reword the last 5 src/ false positives (CWE-1236, failures-1, year-0001, M365) Only non-comment edits: four one-line nested classes split across lines so members can carry docs. Build 0 errors / 0 warnings.
85 lines
3.5 KiB
C#
85 lines
3.5 KiB
C#
using System.Collections.Generic;
|
|
using Opc.Ua;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests.Adapters;
|
|
|
|
/// <summary>
|
|
/// SCOPE: these tests cover ONLY the SDK-level building block the write path
|
|
/// relies on — that <c>new Variant(collection)</c> wraps a CLR array / list as a
|
|
/// typed array <see cref="Variant"/> (ValueRank = OneDimension) without throwing.
|
|
/// They are NOT an end-to-end test of the runtime write flow: they feed a
|
|
/// hand-built collection straight into <see cref="Variant"/>, bypassing the
|
|
/// InstanceActor decode step that produces that collection.
|
|
///
|
|
/// The END-TO-END flow — a script's canonical JSON list string being DECODED to a
|
|
/// typed <c>List<T></c> before the <c>WriteTagRequest</c> reaches the DCL
|
|
/// (so OPC UA writes an array node, not a String scalar) — is covered by
|
|
/// <c>InstanceActorTests.InstanceActor_DataSourcedListWrite_SendsTypedArrayToDcl_NotJsonString</c>.
|
|
/// The runtime hands <see cref="RealOpcUaClient.WriteValueAsync"/> a
|
|
/// <c>List<T></c> (the codec's decode result), which the SDK wraps
|
|
/// identically to a CLR array — see the <c>List<int></c> case below. A full
|
|
/// device round-trip needs a live server and is covered by the live OPC UA smoke
|
|
/// tests.
|
|
/// </summary>
|
|
[Trait("Category", "Unit")]
|
|
public class RealOpcUaClientArrayWriteTests
|
|
{
|
|
/// <summary>Verifies that an integer list wraps into a variant array without throwing.</summary>
|
|
[Fact]
|
|
public void Variant_wraps_int_list_as_array_without_throwing()
|
|
{
|
|
// The runtime actually hands WriteValueAsync a List<T> (the decode result),
|
|
// not a raw T[]; assert the SDK wraps it as a typed array all the same.
|
|
var value = new List<int> { 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);
|
|
}
|
|
|
|
/// <summary>Verifies that an integer array wraps into a variant without throwing.</summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>Verifies that a double array wraps into a variant without throwing.</summary>
|
|
[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);
|
|
}
|
|
|
|
/// <summary>Verifies that a string array wraps into a variant without throwing.</summary>
|
|
[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);
|
|
}
|
|
}
|