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.
92 lines
3.3 KiB
C#
92 lines
3.3 KiB
C#
using Opc.Ua;
|
|
using ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Adapters;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests;
|
|
|
|
/// <summary>
|
|
/// Type-info: pure NodeId → friendly built-in DataType name mapping.
|
|
/// Known OPC UA built-in DataType NodeIds (ns=0;i=…) resolve to their CLR-ish
|
|
/// friendly names; unknown/custom DataType NodeIds fall back to the NodeId string.
|
|
/// No live server is required — this is a pure lookup helper.
|
|
/// </summary>
|
|
public class OpcUaDataTypeNameMapTests
|
|
{
|
|
/// <summary>Verifies that resolve, known built in types, return friendly names.</summary>
|
|
/// <param name="typeName">Test case input.</param>
|
|
[Theory]
|
|
[InlineData("Boolean")]
|
|
[InlineData("SByte")]
|
|
[InlineData("Byte")]
|
|
[InlineData("Int16")]
|
|
[InlineData("UInt16")]
|
|
[InlineData("Int32")]
|
|
[InlineData("UInt32")]
|
|
[InlineData("Int64")]
|
|
[InlineData("UInt64")]
|
|
[InlineData("Float")]
|
|
[InlineData("Double")]
|
|
[InlineData("String")]
|
|
[InlineData("DateTime")]
|
|
[InlineData("Guid")]
|
|
[InlineData("ByteString")]
|
|
public void Resolve_KnownBuiltInTypes_ReturnFriendlyNames(string typeName)
|
|
{
|
|
// Look up the well-known DataType NodeId by its standard name on
|
|
// DataTypeIds (e.g. DataTypeIds.Double) so the test mirrors exactly
|
|
// the constants the helper maps against.
|
|
var field = typeof(DataTypeIds).GetField(typeName)!;
|
|
var nodeId = (NodeId)field.GetValue(null)!;
|
|
|
|
Assert.Equal(typeName, OpcUaBuiltInTypeNames.Resolve(nodeId));
|
|
}
|
|
|
|
/// <summary>Verifies that resolve, double, returns double.</summary>
|
|
[Fact]
|
|
public void Resolve_Double_ReturnsDouble()
|
|
{
|
|
Assert.Equal("Double", OpcUaBuiltInTypeNames.Resolve(DataTypeIds.Double));
|
|
}
|
|
|
|
/// <summary>Verifies that resolve, int32, returns int32.</summary>
|
|
[Fact]
|
|
public void Resolve_Int32_ReturnsInt32()
|
|
{
|
|
Assert.Equal("Int32", OpcUaBuiltInTypeNames.Resolve(DataTypeIds.Int32));
|
|
}
|
|
|
|
/// <summary>Verifies that resolve, boolean, returns boolean.</summary>
|
|
[Fact]
|
|
public void Resolve_Boolean_ReturnsBoolean()
|
|
{
|
|
Assert.Equal("Boolean", OpcUaBuiltInTypeNames.Resolve(DataTypeIds.Boolean));
|
|
}
|
|
|
|
/// <summary>Verifies that resolve, string, returns string.</summary>
|
|
[Fact]
|
|
public void Resolve_String_ReturnsString()
|
|
{
|
|
Assert.Equal("String", OpcUaBuiltInTypeNames.Resolve(DataTypeIds.String));
|
|
}
|
|
|
|
/// <summary>Verifies that resolve, unknown custom node id, returns node id string.</summary>
|
|
[Fact]
|
|
public void Resolve_UnknownCustomNodeId_ReturnsNodeIdString()
|
|
{
|
|
// A vendor-defined DataType (string identifier, non-zero namespace) is
|
|
// not a built-in, so the helper falls back to the NodeId string — the
|
|
// only thing the UI can meaningfully display for an opaque type.
|
|
var custom = new NodeId("CustomType", 5);
|
|
|
|
Assert.Equal(custom.ToString(), OpcUaBuiltInTypeNames.Resolve(custom));
|
|
}
|
|
|
|
/// <summary>Verifies that resolve, null, returns empty string.</summary>
|
|
[Fact]
|
|
public void Resolve_Null_ReturnsEmptyString()
|
|
{
|
|
// Defensive: a null DataType attribute value must not throw during a
|
|
// best-effort browse type-read.
|
|
Assert.Equal(string.Empty, OpcUaBuiltInTypeNames.Resolve(null));
|
|
}
|
|
}
|