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.
34 lines
1.8 KiB
C#
34 lines
1.8 KiB
C#
using System.Reflection;
|
|
using Opc.Ua;
|
|
using ZB.MOM.WW.ScadaBridge.Commons.Types.Alarms;
|
|
using ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Adapters;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests.Adapters;
|
|
|
|
public class RealOpcUaSnapshotScopeTests
|
|
{
|
|
/// <summary>Verifies that refresh boundaries, preserve source and have distinct epochs.</summary>
|
|
[Fact]
|
|
public void RefreshBoundaries_PreserveSourceAndHaveDistinctEpochs()
|
|
{
|
|
var client = new RealOpcUaClient();
|
|
var events = new List<NativeAlarmTransition>();
|
|
var handler = typeof(RealOpcUaClient).GetMethod("HandleAlarmEvent", BindingFlags.Instance | BindingFlags.NonPublic)!;
|
|
void Emit(string handle, string source, NodeId type) => handler.Invoke(client,
|
|
[handle, source, new EventFieldList { EventFields = new VariantCollection { new(type), new(), new(), new(), new(), new() } }, (Action<NativeAlarmTransition>)events.Add]);
|
|
Emit("a", "A", ObjectTypeIds.RefreshStartEventType);
|
|
Emit("b", "B", ObjectTypeIds.RefreshStartEventType);
|
|
Emit("a", "A", ObjectTypeIds.RefreshEndEventType);
|
|
Emit("b", "B", ObjectTypeIds.RefreshEndEventType);
|
|
Assert.Equal(4, events.Count);
|
|
Assert.Equal(["SnapshotStart", "SnapshotStart", "SnapshotComplete", "SnapshotComplete"], events.Select(e => e.Kind.ToString()));
|
|
Assert.Equal(["A", "B", "A", "B"], events.Select(e => e.SourceObjectReference));
|
|
var epoch = typeof(NativeAlarmTransition).GetProperty("SnapshotId")!;
|
|
Assert.NotNull(epoch);
|
|
Assert.NotNull(epoch.GetValue(events[0]));
|
|
Assert.Equal(epoch.GetValue(events[0]), epoch.GetValue(events[2]));
|
|
Assert.Equal(epoch.GetValue(events[1]), epoch.GetValue(events[3]));
|
|
Assert.NotEqual(epoch.GetValue(events[0]), epoch.GetValue(events[1]));
|
|
}
|
|
}
|