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.
This commit is contained in:
Joseph Doherty
2026-10-07 15:05:49 -04:00
parent 0ffd4bdbea
commit 513fa1aa16
998 changed files with 17896 additions and 2395 deletions
@@ -3,12 +3,13 @@ using ZB.MOM.WW.ScadaBridge.Commons.Types.Debugging;
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Debugging;
/// <summary>
/// Final review M1: the ONE parser behind the graph node's exception subtitle and the step
/// The single parser behind the graph node's exception subtitle and the step
/// detail panel's exception block. Before it, the panel showed the OUTERMOST exception of a
/// wrapped chain while the node showed the innermost — the two now agree by construction.
/// </summary>
public class ExceptionHeaderTests
{
/// <summary>Verifies that a plain detail splits the type from the message and shortens the type only when asked.</summary>
[Fact]
public void Parse_PlainDetail_SplitsTypeFromMessage_AndShortensOnlyWhenAsked()
{
@@ -18,6 +19,7 @@ public class ExceptionHeaderTests
Assert.Equal(("System.InvalidOperationException", "Recipe 42 rejected"), ExceptionHeader.Parse(detail, shortenType: false));
}
/// <summary>Verifies that a wrapped exception chain resolves to the innermost exception.</summary>
[Fact]
public void Parse_WrappedChain_TakesTheINNERMOSTException()
{
@@ -28,6 +30,7 @@ public class ExceptionHeaderTests
Assert.Equal(("C.Innermost", "the real one"), ExceptionHeader.Parse(detail, shortenType: false));
}
/// <summary>Verifies that a generic type keeps its arity and arguments verbatim and only the head is shortened.</summary>
[Fact]
public void Parse_GenericType_KeepsTheArityAndArgumentsVerbatim_ShorteningOnlyTheHead()
{
@@ -37,6 +40,7 @@ public class ExceptionHeaderTests
ExceptionHeader.Parse("RecipeException`1[System.String]: msg", shortenType: true));
}
/// <summary>Verifies that the chain marker is matched after trimming, so a trailing marker is not treated as a chain.</summary>
[Fact]
public void Parse_ChainMarkerIsMatchedAfterTrimming_SoATrailingMarkerIsNotAChain()
{
@@ -46,12 +50,14 @@ public class ExceptionHeaderTests
Assert.Equal(("Outer", "outer --->"), ExceptionHeader.Parse("A.Outer: outer ---> ", shortenType: true));
}
/// <summary>Verifies that a line without a colon is treated as all type and no message.</summary>
[Fact]
public void Parse_LineWithoutAColon_IsAllTypeAndNoMessage()
{
Assert.Equal(("SomethingWentWrong", string.Empty), ExceptionHeader.Parse("SomethingWentWrong", shortenType: true));
}
/// <summary>Verifies that a CRLF detail has the carriage return trimmed off the first line.</summary>
[Fact]
public void Parse_CrLfDetail_TrimsTheCarriageReturnOffTheFirstLine()
{
@@ -59,6 +65,8 @@ public class ExceptionHeaderTests
ExceptionHeader.Parse("System.TimeoutException: took too long\r\n at X\r\n", shortenType: true));
}
/// <summary>Verifies that a missing or blank detail returns null.</summary>
/// <param name="detail">The exception detail text to parse.</param>
[Theory]
[InlineData(null)]
[InlineData("")]
@@ -4,6 +4,7 @@ namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Debugging;
public class FlowEnumContractTests
{
/// <summary>Verifies that the enum names and numeric values remain stable.</summary>
[Fact]
public void EnumNamesAndValues_RemainStable()
{
@@ -15,6 +16,7 @@ public class FlowEnumContractTests
Assert.Equal(Enumerable.Range(0, 7), Enum.GetValues<FlowStepOutcome>().Select(x => (int)x));
}
/// <summary>Verifies that the kind rank follows the display order independent of the enum's numeric value.</summary>
[Fact]
public void KindRank_UsesDisplayOrderIndependentOfEnumValue()
{
@@ -51,6 +51,7 @@ public class FlowGraphBuilderLogLineTests
private static FlowStep StepOf(FlowGraph graph, FlowStepKind kind) => Assert.Single(graph.Steps, s => s.Kind == kind);
/// <summary>Verifies that a log line carrying a step event id attaches to that step.</summary>
[Fact]
public void LogLine_WithStepEventId_AttachesToThatStep()
{
@@ -65,6 +66,7 @@ public class FlowGraphBuilderLogLineTests
Assert.Null(StepOf(graph, FlowStepKind.ScriptRun).Logs);
}
/// <summary>Verifies that a log line without a step id attaches to the execution anchor.</summary>
[Fact]
public void LogLine_WithoutStepId_AttachesToTheExecutionAnchor()
{
@@ -76,6 +78,7 @@ public class FlowGraphBuilderLogLineTests
Assert.Null(StepOf(graph, FlowStepKind.AttributeWrite).Logs);
}
/// <summary>Verifies that a central log line attaches to the inbound row rather than the response.</summary>
[Fact]
public void CentralLine_AttachesToInboundRow_NotResponse()
{
@@ -87,6 +90,7 @@ public class FlowGraphBuilderLogLineTests
Assert.Null(StepOf(graph, FlowStepKind.Response).Logs);
}
/// <summary>Verifies that a script-entry log line attaches to the route-call root.</summary>
[Fact]
public void ScriptEntryLine_AttachesToRouteCallRoot()
{
@@ -97,6 +101,7 @@ public class FlowGraphBuilderLogLineTests
Assert.Single(StepOf(graph, FlowStepKind.RouteCall).Logs!);
}
/// <summary>Verifies that a log line with an unknown step id falls back to the anchor.</summary>
[Fact]
public void LogLine_UnknownStepId_FallsBackToAnchor()
{
@@ -108,6 +113,7 @@ public class FlowGraphBuilderLogLineTests
Assert.Equal(0, graph.UnattachedLogLines);
}
/// <summary>Verifies that a log line with no anchor falls back to the first step.</summary>
[Fact]
public void LogLine_NoAnchor_FallsBackToFirstStep()
{
@@ -119,6 +125,7 @@ public class FlowGraphBuilderLogLineTests
Assert.Equal(0, graph.UnattachedLogLines);
}
/// <summary>Verifies that a log line whose execution has no step is counted as unattached.</summary>
[Fact]
public void LogLine_NoStepInExecution_IsCountedUnattached()
{
@@ -130,6 +137,7 @@ public class FlowGraphBuilderLogLineTests
Assert.All(graph.Steps, s => Assert.True(s.Logs is null or { Count: 0 }));
}
/// <summary>Verifies that building from log lines only returns an empty graph with the unattached count.</summary>
[Fact]
public void Build_LinesOnly_ReturnsEmptyGraphWithUnattachedCount()
{
@@ -141,6 +149,7 @@ public class FlowGraphBuilderLogLineTests
Assert.True(graph.LogsTruncated);
}
/// <summary>Verifies that lines within the same millisecond are ordered by sequence with null sequences last.</summary>
[Fact]
public void Lines_OrderBySeqWithinSameMillisecond_NullSeqLast()
{
@@ -160,6 +169,7 @@ public class FlowGraphBuilderLogLineTests
Assert.Equal(new[] { "one", "two", "three", "null" }, logs.Select(l => l.Message).ToArray());
}
/// <summary>Verifies that log lines never become graph steps.</summary>
[Fact]
public void LogLines_NeverBecomeSteps()
{
@@ -177,6 +187,7 @@ public class FlowGraphBuilderLogLineTests
Assert.DoesNotContain(graph.Edges, e => lineIds.Contains(e.FromEventId) || lineIds.Contains(e.ToEventId));
}
/// <summary>Verifies that the builder passes the logs-truncated flag through to the graph.</summary>
[Fact]
public void Build_PassesLogsTruncatedThrough()
{
@@ -188,6 +199,7 @@ public class FlowGraphBuilderLogLineTests
Assert.False(graph.Truncated);
}
/// <summary>Verifies that a log line on a folded outbound step attaches by the first row id.</summary>
[Fact]
public void LogLine_OnFoldedOutboundStep_AttachesByFirstRowId()
{
@@ -52,6 +52,7 @@ public class FlowGraphBuilderTests
return [inbound, route, wait, run, write2, write1, cascade];
}
/// <summary>Verifies that an inferred device cascade edge is drawn dashed.</summary>
[Fact]
public void InferredDeviceCascade_IsDashed()
{
@@ -65,6 +66,9 @@ public class FlowGraphBuilderTests
Assert.True(edge.External);
}
/// <summary>Verifies that a folded node uses the latest error detail from its rows.</summary>
/// <param name="initialDetail">The error detail on the initial row.</param>
/// <param name="finalDetail">The error detail on the final row.</param>
[Theory]
[InlineData(null, "terminal stack")]
[InlineData("old stack", null)]
@@ -81,6 +85,7 @@ public class FlowGraphBuilderTests
Assert.Equal(finalDetail, step.Lifecycle[1].ErrorDetail);
}
/// <summary>Verifies that the Delmia call shape projects the expected lanes and edges plus a synthesized response.</summary>
[Fact]
public void DelmiaShape_ProjectsLanes_Edges_AndSynthesizedResponse()
{
@@ -142,6 +147,7 @@ public class FlowGraphBuilderTests
Assert.All(graph.Steps, s => Assert.Equal(FlowStepOutcome.Ok, s.Outcome));
}
/// <summary>Verifies that building the graph is deterministic and the synthesized response id is stable.</summary>
[Fact]
public void Build_IsDeterministic_ResponseIdIsStable()
{
@@ -152,6 +158,7 @@ public class FlowGraphBuilderTests
Assert.Equal(a.Edges, b.Edges);
}
/// <summary>Verifies that the truncated flag passes through to the built graph.</summary>
[Fact]
public void Truncated_PassesThrough()
{
@@ -160,6 +167,7 @@ public class FlowGraphBuilderTests
Assert.Empty(FlowGraphBuilder.Build(Array.Empty<AuditEvent>()).Steps);
}
/// <summary>Verifies that an unrecognized step kind projects to an unknown node without throwing.</summary>
[Fact]
public void UnknownKind_ProjectsToUnknown_NeverThrows()
{
@@ -190,6 +198,7 @@ public class FlowGraphBuilderTests
Assert.Empty(graph.Edges);
}
/// <summary>Verifies that a failed script run with a timeout message is classified as timed out.</summary>
[Fact]
public void FailedScriptRun_WithTimeoutMessage_IsTimedOut()
{
@@ -205,6 +214,7 @@ public class FlowGraphBuilderTests
Assert.Single(graph.Edges);
}
/// <summary>Verifies that the script trace extra payload round-trips as camelCase JSON and ignores unknown members.</summary>
[Fact]
public void ScriptTraceExtra_RoundTrips_CamelCase_AndIgnoresUnknownMembers()
{
@@ -219,7 +229,7 @@ public class FlowGraphBuilderTests
Assert.Null(ScriptTraceExtra.TryParse("nope"));
}
// ---- Outbound calls (2026-09-06 plan, Task 2) --------------------------------------------
// ---- Outbound calls (2026-09-06 plan) --------------------------------------------
private static AuditEvent SiteRunRow(int ms, Guid executionId = default) => ScadaBridgeAuditEventFactory.Create(
AuditChannel.ScriptTrace, AuditKind.ScriptRun, AuditStatus.Delivered,
@@ -240,6 +250,7 @@ public class FlowGraphBuilderTests
executionId: SiteRun, sourceSiteId: "site-a", sourceInstanceId: "M1", errorMessage: error, durationMs: durationMs,
requestSummary: request, responseSummary: response);
/// <summary>Verifies that the four rows of a cached API call fold into a single asynchronous node.</summary>
[Fact]
public void CachedApiCall_FourRows_FoldIntoOneAsyncNode()
{
@@ -286,6 +297,7 @@ public class FlowGraphBuilderTests
Assert.Equal(3, graph.Edges.Count);
}
/// <summary>Verifies that a synchronous API call sits in the chain without an asynchronous edge.</summary>
[Fact]
public void SyncApiCall_SitsInChain_NoAsyncEdge()
{
@@ -309,6 +321,7 @@ public class FlowGraphBuilderTests
Assert.DoesNotContain(graph.Edges, e => e.FromEventId == graph.Steps[1].EventId && e.ToEventId == graph.Steps[3].EventId);
}
/// <summary>Verifies that two synchronous calls with no correlation id are not folded together.</summary>
[Fact]
public void TwoSyncCalls_NullCorrelation_AreNotFoldedTogether()
{
@@ -326,6 +339,7 @@ public class FlowGraphBuilderTests
Assert.Equal(2, graph.Edges.Count);
}
/// <summary>Verifies that a notification send and its parked central delivery fold into one parked notify node.</summary>
[Fact]
public void NotifySend_PlusCentralDeliverParked_FoldsIntoOneParkedNotifyNode()
{
@@ -354,6 +368,7 @@ public class FlowGraphBuilderTests
Assert.Equal(notify.EventId, async.ToEventId);
}
/// <summary>Verifies that a cached call with only a submit row is pending and has no duration.</summary>
[Fact]
public void CachedSubmitOnly_IsPending_WithNoDuration()
{
@@ -374,6 +389,7 @@ public class FlowGraphBuilderTests
Assert.Equal(graph.Steps[0].EventId, async.FromEventId);
}
/// <summary>Verifies that the response links from the last step of the inbound execution rather than the last cascaded step.</summary>
[Fact]
public void ResponseLinksFromTheInboundExecutionsLastStep_NotTheLastCascadedStep()
{
@@ -385,6 +401,7 @@ public class FlowGraphBuilderTests
Assert.Equal(FlowStepKind.RouteCall, graph.Steps[1].Kind);
}
/// <summary>Verifies that the response falls back to the inbound row when no other row shares its execution.</summary>
[Fact]
public void ResponseFallsBackToTheInboundRow_WhenNothingElseSharesItsExecution()
{
@@ -422,6 +439,7 @@ public class FlowGraphBuilderTests
return [inbound, route, run, write];
}
/// <summary>Verifies that with a site clock running ahead, site steps still follow their route call and precede the response.</summary>
[Fact]
public void SiteClockAhead_SiteStepsStillFollowTheirRouteCall_AndPrecedeResponse()
{
@@ -440,6 +458,7 @@ public class FlowGraphBuilderTests
Assert.Equal(T0.AddMilliseconds(900), graph.Steps[4].OccurredAtUtc.UtcDateTime);
}
/// <summary>Verifies that with a site clock running behind, site steps do not sort ahead of the inbound request.</summary>
[Fact]
public void SiteClockBehind_SiteStepsDoNotSortAheadOfTheInboundRequest()
{
@@ -456,6 +475,7 @@ public class FlowGraphBuilderTests
Assert.Equal(events.Select(e => e.EventId), graph.Steps.Take(4).Select(s => s.EventId));
}
/// <summary>Verifies that with a site clock running behind, a trigger cascade spawns from the last parent step rather than the first.</summary>
[Fact]
public void SiteClockBehind_TriggerCascade_SpawnsFromTheLastParentStep_NotTheFirst()
{
@@ -477,6 +497,7 @@ public class FlowGraphBuilderTests
Assert.Equal(run.EventId, spawn.ToEventId);
}
/// <summary>Verifies that on a shared clock a trigger cascade spawns from the write that fired it rather than the parent's last step.</summary>
[Fact]
public void SameClock_TriggerCascade_SpawnsFromTheWriteThatFiredIt_NotTheParentsLastStep()
{
@@ -502,6 +523,7 @@ public class FlowGraphBuilderTests
Assert.Equal(cascade.EventId, spawn.ToEventId);
}
/// <summary>Verifies that with simultaneous writes a trigger cascade spawns from the write of the trigger attribute rather than the last write.</summary>
[Fact]
public void SimultaneousWrites_TriggerCascade_SpawnsFromTheWriteOfTheTriggerAttribute_NotTheLastWrite()
{
@@ -524,6 +546,7 @@ public class FlowGraphBuilderTests
Assert.Equal(cascade.EventId, spawn.ToEventId);
}
/// <summary>Verifies that a trigger cascade whose attribute the parent never wrote falls back to time-based placement.</summary>
[Fact]
public void TriggerCascade_WhoseAttributeTheParentNeverWrote_FallsBackToTheTimeRule()
{
@@ -543,6 +566,7 @@ public class FlowGraphBuilderTests
Assert.Equal(writeA.EventId, spawn.FromEventId);
}
/// <summary>Verifies that a folded node takes the emission index of its earliest emitted row.</summary>
[Fact]
public void FoldedNode_TakesTheEmissionIndexOfItsEarliestEmittedRow()
{
@@ -562,8 +586,9 @@ public class FlowGraphBuilderTests
Assert.Equal(new[] { FlowStepKind.ApiCall, FlowStepKind.ScriptRun }, graph.Steps.Select(s => s.Kind));
}
// ---- Review findings on Task 2 (2026-09-06) --------------------------------------------
// ---- Review findings on outbound calls (2026-09-06) --------------------------------------------
/// <summary>Verifies that leading asynchronous steps hang off the spawner and are never orphaned.</summary>
[Fact]
public void LeadingAsyncSteps_HangOffTheSpawner_NeverOrphaned()
{
@@ -591,6 +616,7 @@ public class FlowGraphBuilderTests
Assert.Equal(3, graph.Edges.Count);
}
/// <summary>Verifies that when an execution has only notify rows, all of them link from the spawner.</summary>
[Fact]
public void OnlyNotifyRows_InAnExecution_AllLinkFromTheSpawner()
{
@@ -606,6 +632,7 @@ public class FlowGraphBuilderTests
Assert.All(graph.Edges, e => { Assert.True(e.Async); Assert.True(e.Spawn); Assert.Equal(graph.Steps[0].EventId, e.FromEventId); });
}
/// <summary>Verifies that folding is independent of row order and ties are broken by lifecycle rank.</summary>
[Fact]
public void Fold_IsOrderIndependent_AndTiesBreakByLifecycleRank()
{
@@ -628,6 +655,7 @@ public class FlowGraphBuilderTests
Assert.Equal(sa.Lifecycle!.Select(r => r.Kind), sb.Lifecycle!.Select(r => r.Kind));
}
/// <summary>Verifies that a cached step whose submit row is missing is still treated as asynchronous.</summary>
[Fact]
public void CachedStep_WhoseSubmitRowIsMissing_IsStillAsync()
{
@@ -642,6 +670,7 @@ public class FlowGraphBuilderTests
Assert.Single(graph.Edges, e => e.Async && e.ToEventId == api.EventId);
}
/// <summary>Verifies that edges on the external lane never count as cluster boundary crossings.</summary>
[Fact]
public void ExternalLaneEdges_NeverCountAsClusterBoundaryCrossings()
{
@@ -660,8 +689,9 @@ public class FlowGraphBuilderTests
Assert.Equal(graph.Steps[1].EventId, into.FromEventId);
}
// ---- Script entry point (2026-09-08 plan, Task 6) -----------------------------------------
// ---- Script entry point (2026-09-08 plan) -----------------------------------------
/// <summary>Verifies that a route-call root without an inbound row builds a central-to-site graph with no response.</summary>
[Fact]
public void RouteCallRoot_WithoutInboundRow_BuildsCentralToSite_AndNoResponse()
{
@@ -5,12 +5,13 @@ using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Debugging;
/// <summary>
/// Flow Debugger step-logs plan (2026-09-09) Task 1: the Commons log-line vocabulary —
/// Flow Debugger step-logs plan (2026-09-09): the Commons log-line vocabulary —
/// exception detail on a step (D3), and the <c>ScriptTrace.ScriptLog</c> row projecting
/// onto a <see cref="FlowLogLine"/> rather than a node (D1).
/// </summary>
public class FlowStepProjectorLogLineTests
{
/// <summary>Verifies that projecting an audit event carries its error detail onto the step.</summary>
[Fact]
public void Project_CarriesErrorDetail()
{
@@ -23,6 +24,7 @@ public class FlowStepProjectorLogLineTests
Assert.StartsWith("System.InvalidOperationException", step.ErrorDetail);
}
/// <summary>Verifies that the projected error detail is null when the audit event has none.</summary>
[Fact]
public void Project_ErrorDetail_IsNullWhenAbsent()
{
@@ -31,6 +33,7 @@ public class FlowStepProjectorLogLineTests
Assert.Null(FlowStepProjector.Project(evt).ErrorDetail);
}
/// <summary>Verifies that a script log row projects to the unknown kind and never to a step kind of its own.</summary>
[Fact]
public void ScriptLog_ProjectsToUnknownKind_NeverItsOwnStepKind()
{
@@ -40,6 +43,7 @@ public class FlowStepProjectorLogLineTests
Assert.False(Enum.GetNames<FlowStepKind>().Contains("ScriptLog"));
}
/// <summary>Verifies that a row is a log line only for the script trace channel with the script log kind.</summary>
[Fact]
public void IsLogLine_TrueOnlyForScriptTraceScriptLog()
{
@@ -50,6 +54,7 @@ public class FlowStepProjectorLogLineTests
Assert.False(FlowStepProjector.IsLogLine(run));
}
/// <summary>Verifies that rows on other channels are not log lines.</summary>
[Fact]
public void IsLogLine_FalseForOtherChannels()
{
@@ -58,6 +63,7 @@ public class FlowStepProjectorLogLineTests
Assert.False(FlowStepProjector.IsLogLine(outbound));
}
/// <summary>Verifies that converting a row to a log line reads its level, source and exception.</summary>
[Fact]
public void ToLogLine_ReadsLevelSourceAndException()
{
@@ -81,6 +87,7 @@ public class FlowStepProjectorLogLineTests
Assert.Equal(3, line.Seq);
}
/// <summary>Verifies that converting a row to a log line defaults the level and source when the extra payload is missing.</summary>
[Fact]
public void ToLogLine_DefaultsLevelAndSourceWhenExtraMissing()
{
@@ -97,6 +104,7 @@ public class FlowStepProjectorLogLineTests
Assert.Null(line.Seq);
}
/// <summary>Verifies that the log members of the script trace extra round-trip through JSON.</summary>
[Fact]
public void ScriptTraceExtra_LogMembers_RoundTripThroughJson()
{
@@ -111,6 +119,7 @@ public class FlowStepProjectorLogLineTests
Assert.Equal(12, parsed.Seq);
}
/// <summary>Verifies that a flow step's logs and error detail default to null.</summary>
[Fact]
public void FlowStep_LogsAndErrorDetail_DefaultToNull()
{
@@ -124,6 +133,7 @@ public class FlowStepProjectorLogLineTests
Assert.Single((step with { Logs = [line] }).Logs!);
}
/// <summary>Verifies that the log truncation members of a flow graph default to off.</summary>
[Fact]
public void FlowGraph_LogTruncationMembers_DefaultToOff()
{
@@ -6,13 +6,14 @@ using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums;
namespace ZB.MOM.WW.ScadaBridge.Commons.Tests.Debugging;
/// <summary>
/// Flow Debugger outbound-calls plan (2026-09-06) Task 0: the Commons vocabulary — External lane,
/// Flow Debugger outbound-calls plan (2026-09-06): the Commons vocabulary — External lane,
/// the three outbound kinds, Pending/Parked outcomes, the lifecycle row, and additive edge/step shapes.
/// </summary>
public class FlowStepProjectorTests
{
private static readonly DateTimeOffset T0 = new(2026, 9, 6, 12, 0, 0, TimeSpan.Zero);
/// <summary>Verifies that the vocabulary has an External lane, three outbound kinds, and Pending and Parked outcomes.</summary>
[Fact]
public void Vocabulary_HasExternalLane_ThreeOutboundKinds_AndPendingParkedOutcomes()
{
@@ -26,6 +27,7 @@ public class FlowStepProjectorTests
Assert.True(Enum.IsDefined(FlowStepOutcome.Parked));
}
/// <summary>Verifies that a flow step can be constructed without a lifecycle and defaults it to null.</summary>
[Fact]
public void FlowStep_WithoutLifecycle_StillConstructs_AndDefaultsToNull()
{
@@ -39,6 +41,7 @@ public class FlowStepProjectorTests
Assert.Equal("Submitted", withLifecycle.Lifecycle![0].Status);
}
/// <summary>Verifies that the Async and Spawn flags of a flow edge default to false.</summary>
[Fact]
public void FlowEdge_AsyncAndSpawn_DefaultFalse()
{
@@ -51,8 +54,9 @@ public class FlowStepProjectorTests
Assert.True(new FlowEdge(a, b, false, false, Async: false, Spawn: true).Spawn);
}
// ---- Task 1: outbound rows project onto the External lane ---------------------------------
// ---- Outbound rows project onto the External lane ---------------------------------
/// <summary>Verifies that a delivered synchronous API call projects to an Ok API-call step on the External lane with a sync subtitle.</summary>
[Fact]
public void SyncApiCall_Delivered_IsApiCall_External_Ok_SyncSubtitle()
{
@@ -73,6 +77,7 @@ public class FlowStepProjectorTests
Assert.Equal(212, step.DurationMs);
}
/// <summary>Verifies that a cached submit on the database outbound channel projects to a pending database-call step with a cached subtitle.</summary>
[Fact]
public void CachedSubmit_InDbOutbound_IsDbCall_Pending_CachedSubtitle()
{
@@ -87,6 +92,7 @@ public class FlowStepProjectorTests
Assert.Equal("Submitted · cached", step.Subtitle);
}
/// <summary>Verifies that a database write with a rows-affected extra has a subtitle combining the operation and the row count.</summary>
[Fact]
public void DbWrite_WithRowsAffectedExtra_SubtitleIsOpAndRows()
{
@@ -105,6 +111,7 @@ public class FlowStepProjectorTests
Assert.Equal("read · 1 row", FlowStepProjector.Project(read).Subtitle);
}
/// <summary>Verifies that a submitted notification send projects to a pending notify step.</summary>
[Fact]
public void NotifySend_Submitted_IsNotify_Pending()
{
@@ -120,6 +127,9 @@ public class FlowStepProjectorTests
Assert.Equal("Submitted", step.Subtitle);
}
/// <summary>Verifies that each outbound audit status maps to the expected flow step outcome.</summary>
/// <param name="status">The outbound audit status.</param>
/// <param name="expected">The expected flow step outcome.</param>
[Theory]
[InlineData(AuditStatus.Parked, FlowStepOutcome.Parked)]
[InlineData(AuditStatus.Discarded, FlowStepOutcome.Parked)]
@@ -139,6 +149,7 @@ public class FlowStepProjectorTests
Assert.Equal($"{status} · cached", step.Subtitle);
}
/// <summary>Verifies that script-trace outcomes are unchanged, so a failed status stays failed and other statuses are Ok.</summary>
[Fact]
public void ScriptTraceOutcome_Unchanged_FailedStaysFailed_OtherStatusesOk()
{
@@ -150,6 +161,9 @@ public class FlowStepProjectorTests
Assert.Equal(FlowStepOutcome.Failed, FlowStepProjector.Project(failed).Outcome);
}
/// <summary>Verifies that building a database subtitle never throws on odd extra values and yields the expected text.</summary>
/// <param name="extra">The extra payload of the audit row.</param>
/// <param name="expected">The expected subtitle.</param>
[Theory]
[InlineData("{\"op\":\"write\",\"rowsAffected\":2147483648}", "write")]
[InlineData("{\"op\":\"write\",\"rowsAffected\":1.5}", "write")]
@@ -163,6 +177,7 @@ public class FlowStepProjectorTests
Assert.Equal(expected, FlowStepProjector.Project(evt).Subtitle);
}
/// <summary>Verifies that projection carries the audit row's correlation id onto the step.</summary>
[Fact]
public void Project_CarriesTheAuditRowsCorrelationId()
{
@@ -173,6 +188,7 @@ public class FlowStepProjectorTests
Assert.Equal(corr, FlowStepProjector.Project(evt).CorrelationId);
}
/// <summary>Verifies that a null correlation id on the audit row leaves the step's correlation id null.</summary>
[Fact]
public void Project_NullCorrelation_LeavesCorrelationIdNull()
{
@@ -24,6 +24,7 @@ public class FlowTraceCollectorTests
AuditChannel.ScriptTrace, AuditKind.ScriptRun, AuditStatus.Delivered,
target: "S", requestSummary: details);
/// <summary>Verifies that add, when beyond cap, keeps first n and flags truncated.</summary>
[Fact]
public void Add_BeyondCap_KeepsFirstN_AndFlagsTruncated()
{
@@ -39,6 +40,7 @@ public class FlowTraceCollectorTests
Assert.Equal("499", snap[499].Target);
}
/// <summary>Verifies that snapshot, when is a copy, in emission order.</summary>
[Fact]
public void Snapshot_IsACopy_InEmissionOrder()
{
@@ -52,6 +54,8 @@ public class FlowTraceCollectorTests
Assert.Equal(new[] { "1", "2" }, c.Snapshot().Select(e => e.Target));
}
/// <summary>Verifies that concurrent adds, when never throw, and never exceed cap.</summary>
/// <returns>A task that represents the asynchronous operation.</returns>
[Fact]
public async Task ConcurrentAdds_NeverThrow_AndNeverExceedCap()
{
@@ -66,6 +70,7 @@ public class FlowTraceCollectorTests
Assert.True(c.Truncated);
}
/// <summary>Verifies that default cap, when is 500, and non-positive cap is rejected.</summary>
[Fact]
public void DefaultCap_Is500_AndNonPositiveCapIsRejected()
{
@@ -73,6 +78,7 @@ public class FlowTraceCollectorTests
Assert.Throws<ArgumentOutOfRangeException>(() => new FlowTraceCollector(0));
}
/// <summary>Verifies that complete, when closes the collector, later adds are ignored and never truncate.</summary>
[Fact]
public void Complete_ClosesTheCollector_LaterAddsAreIgnored_AndNeverTruncate()
{
@@ -198,6 +204,9 @@ public class FlowTraceCollectorTests
/// <summary>Upper-cases <c>DetailsJson</c> so a test can see the filtered copy land.</summary>
private sealed class UpperRedactor : IAuditRedactor
{
/// <summary>Applies the upper-casing redaction.</summary>
/// <param name="rawEvent">The raw event.</param>
/// <returns>The event with upper-cased details.</returns>
public AuditEvent Apply(AuditEvent rawEvent)
=> rawEvent with { DetailsJson = rawEvent.DetailsJson?.ToUpperInvariant() };
}