Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.Commons.Tests/Messages/TraceFlagDefaultsTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
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.
2026-10-07 15:05:49 -04:00

56 lines
2.3 KiB
C#

using ZB.MOM.WW.Audit;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.InboundApi;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Instance;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.ScriptExecution;
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Streaming;
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Messages;
/// <summary>
/// Flow Debugger (design 2026-09-05 §5.2/§5.4): the trace flag and trace payload are additive
/// trailing optional members — every pre-existing positional construction stays untraced.
/// </summary>
public class TraceFlagDefaultsTests
{
/// <summary>Verifies that existing positional constructions default to untraced.</summary>
[Fact]
public void ExistingPositionalConstructions_DefaultToUntraced()
{
var now = DateTimeOffset.UtcNow;
Assert.False(new RouteToCallRequest("c", "i", "s", null, now).Trace);
Assert.False(new RouteToSetAttributesRequest("c", "i", new Dictionary<string, string>(), now).Trace);
Assert.False(new ScriptCallRequest("s", null, 0, "c").Trace);
Assert.False(new SetStaticAttributeCommand("c", "i", "a", "v", now).Trace);
Assert.False(new AttributeValueChanged("i", "p", "a", 1, "Good", now).Trace);
var reply = new RouteToCallResponse("c", true, null, null, now);
Assert.Null(reply.ChildExecutionId);
Assert.Null(reply.TraceEvents);
var result = new ScriptCallResult("c", true, null, null);
Assert.Null(result.ExecutionId);
Assert.Null(result.TraceEvents);
}
/// <summary>Verifies that trace events are audit events.</summary>
[Fact]
public void TraceEvents_AreAuditEvents()
{
var evt = new AuditEvent
{
EventId = Guid.NewGuid(),
OccurredAtUtc = DateTimeOffset.UtcNow,
Actor = "a",
Action = "ScriptTrace.ScriptRun",
Outcome = AuditOutcome.Success
};
var result = new ScriptCallResult("c", true, null, null, Guid.NewGuid(), [evt]);
Assert.Single(result.TraceEvents!);
Assert.NotNull(result.ExecutionId);
var reply = new RouteToCallResponse("c", true, null, null, DateTimeOffset.UtcNow, result.ExecutionId, result.TraceEvents);
Assert.Equal(result.ExecutionId, reply.ChildExecutionId);
Assert.Same(evt, reply.TraceEvents![0]);
}
}