review(Driver.Cli.Common): drop dead FormatStatus branch + timestamp-kind test

Re-review at 7286d320. -009: remove unreachable name-is-null branch in FormatStatus +
invariant test. -010: pin DateTimeKind.Unspecified FormatTimestamp behavior.
This commit is contained in:
Joseph Doherty
2026-06-19 11:21:36 -04:00
parent 13c1215811
commit 1180b017f5
3 changed files with 139 additions and 5 deletions
@@ -217,6 +217,39 @@ public sealed class SnapshotFormatterTests
table.ShouldContain("SOURCE TIME");
table.ShouldContain("---");
}
// --- Driver.Cli.Common-009: dead-code in FormatStatus ---
/// <summary>Verifies that FormatStatus always includes a parenthesised label — bare-hex-only output is unreachable.</summary>
/// <param name="statusCode">An arbitrary OPC UA status code.</param>
[Theory]
// The severity-class fallback fires for every code not in the named shortlist, so
// the output always carries a "(<label>)" suffix. Driver.Cli.Common-009 noted that
// the "name is null" branch after the fallback is dead code; this Theory pins the
// guarantee so the dead branch can be safely removed.
[InlineData(0x00000000u)] // Good
[InlineData(0x80000000u)] // Bad
[InlineData(0x40000000u)] // Uncertain
[InlineData(0x80990000u)] // Unknown-bad → fallback "Bad"
[InlineData(0xDEADBEEFu)] // Garbage → fallback "Bad"
public void FormatStatus_always_includes_parenthesised_label(uint statusCode)
{
// Verify the output contains "(" — meaning the name/severity label is always appended.
SnapshotFormatter.FormatStatus(statusCode).ShouldContain("(");
}
// --- Driver.Cli.Common-010: FormatTimestamp with Unspecified kind ---
/// <summary>Verifies that FormatTimestamp treats Unspecified kind as Local and converts to UTC.</summary>
[Fact]
public void FormatTimestamp_treats_unspecified_kind_as_local_and_converts_to_utc()
{
// DateTimeKind.Unspecified is silently treated as Local by ToUniversalTime().
// The result must still carry the "Z" suffix so consumers treat it as UTC.
var unspecified = new DateTime(2026, 4, 21, 12, 0, 0, DateTimeKind.Unspecified);
var formatted = SnapshotFormatter.FormatTimestamp(unspecified);
formatted.ShouldEndWith("Z");
}
}
[Trait("Category", "Unit")]