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.
69 lines
3.2 KiB
C#
69 lines
3.2 KiB
C#
using Opc.Ua;
|
|
using ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Adapters;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests;
|
|
|
|
/// <summary>
|
|
/// Regression: standard OPC UA A&C events carry an event-type
|
|
/// <see cref="NodeId"/> (e.g. <c>i=9341</c> for ExclusiveLevelAlarmType), but the
|
|
/// client-side conditionFilter gate — and the server-side WhereClause — both key off
|
|
/// the friendly type names in <see cref="RealOpcUaClient.KnownConditionTypeIds"/>.
|
|
/// <see cref="RealOpcUaClient.ResolveAlarmTypeName"/> bridges the two by resolving the
|
|
/// event-type NodeId back to its friendly name (NodeId-string fallback for custom
|
|
/// types), so a friendly-name filter actually matches the events the server delivers.
|
|
/// </summary>
|
|
public class RealOpcUaClientAlarmFilterTests
|
|
{
|
|
/// <summary>Verifies that a known standard node id resolves to its friendly alarm type name.</summary>
|
|
[Fact]
|
|
public void ResolveAlarmTypeName_KnownStandardNodeId_ReturnsFriendlyName()
|
|
{
|
|
// The well-known NodeId for ExclusiveLevelAlarmType (i=9341) must resolve to
|
|
// the friendly name the conditionFilter/WhereClause use.
|
|
var resolved = RealOpcUaClient.ResolveAlarmTypeName(ObjectTypeIds.ExclusiveLevelAlarmType);
|
|
Assert.Equal("ExclusiveLevelAlarmType", resolved);
|
|
}
|
|
|
|
/// <summary>Verifies that a discrete alarm node id resolves to its friendly alarm type name.</summary>
|
|
[Fact]
|
|
public void ResolveAlarmTypeName_DiscreteAlarmNodeId_ReturnsFriendlyName()
|
|
{
|
|
var resolved = RealOpcUaClient.ResolveAlarmTypeName(ObjectTypeIds.DiscreteAlarmType);
|
|
Assert.Equal("DiscreteAlarmType", resolved);
|
|
}
|
|
|
|
/// <summary>Verifies that an unknown custom node id resolves to its node id string.</summary>
|
|
[Fact]
|
|
public void ResolveAlarmTypeName_UnknownCustomNodeId_ReturnsNodeIdString()
|
|
{
|
|
// A vendor/custom subtype not in KnownConditionTypeIds: we cannot map it to a
|
|
// friendly name, so we fall back to its NodeId string. This is consistent —
|
|
// the WhereClause is also omitted for unknown names, so the client gate matches
|
|
// the NodeId string, which is the only thing such a filter could carry.
|
|
var custom = new NodeId(987654u, 7);
|
|
var resolved = RealOpcUaClient.ResolveAlarmTypeName(custom);
|
|
Assert.Equal(custom.ToString(), resolved);
|
|
}
|
|
|
|
/// <summary>Verifies that a null node id resolves to an empty string.</summary>
|
|
[Fact]
|
|
public void ResolveAlarmTypeName_Null_ReturnsEmptyString()
|
|
{
|
|
Assert.Equal("", RealOpcUaClient.ResolveAlarmTypeName(null));
|
|
}
|
|
|
|
/// <summary>Verifies that the inverse map round-trips every known condition type.</summary>
|
|
[Fact]
|
|
public void InverseMap_RoundTrips_EveryKnownConditionType()
|
|
{
|
|
// The friendly→NodeId map (KnownConditionTypeIds) and the NodeId→friendly map
|
|
// are derived from a single source of truth, so they must round-trip for every
|
|
// entry — guards against the two maps drifting apart.
|
|
foreach (var (friendlyName, nodeId) in RealOpcUaClient.KnownConditionTypeIds)
|
|
{
|
|
var resolved = RealOpcUaClient.ResolveAlarmTypeName(nodeId);
|
|
Assert.Equal(friendlyName, resolved);
|
|
}
|
|
}
|
|
}
|