Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.HealthMonitoring.Tests/StartupReconcilerHealthFieldTests.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

85 lines
3.4 KiB
C#

namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring.Tests;
/// <summary>
/// Deferred-work register row 73 — <c>SiteHealthReport.StartupReconcilerActive</c> surfaces
/// whether a site node spawned its <c>SiteReconciliationActor</c> at boot.
/// </summary>
/// <remarks>
/// The skip used to be a single boot Warning and nothing else, so a node that lost its whole
/// self-heal path went on reporting itself perfectly healthy. The field is tri-state and the
/// three cases must stay distinct: null = not reported (central self-report, or a older
/// site build), true = running, false = skipped because no <c>IDeploymentConfigFetcher</c>
/// was available. Collapsing null into false would badge every site the moment central is
/// upgraded ahead of them.
/// </remarks>
public class StartupReconcilerHealthFieldTests
{
/// <summary>Verifies the case: collect Report, never Told, leaves The Field Null.</summary>
[Fact]
public void CollectReport_NeverTold_LeavesTheFieldNull()
{
// "Not reported" — NOT "the reconciler is missing". This is the state of central's
// own self-report and of every test host that never calls the setter.
var collector = new SiteHealthCollector();
var report = collector.CollectReport("TestSite");
Assert.Null(report.StartupReconcilerActive);
}
/// <summary>Verifies the case: collect Report, reconciler Spawned, reports True.</summary>
[Fact]
public void CollectReport_ReconcilerSpawned_ReportsTrue()
{
var collector = new SiteHealthCollector();
collector.SetStartupReconcilerActive(true);
Assert.True(collector.CollectReport("TestSite").StartupReconcilerActive);
}
/// <summary>Verifies the case: collect Report, reconciler Skipped, reports False, not Null.</summary>
[Fact]
public void CollectReport_ReconcilerSkipped_ReportsFalse_NotNull()
{
// The case the row exists for: false must be distinguishable from "not reported",
// because false is what central badges.
var collector = new SiteHealthCollector();
collector.SetStartupReconcilerActive(false);
var report = collector.CollectReport("TestSite");
Assert.NotNull(report.StartupReconcilerActive);
Assert.False(report.StartupReconcilerActive);
}
/// <summary>Verifies the case: collect Report, is Point In Time, not Drained On Collect.</summary>
[Fact]
public void CollectReport_IsPointInTime_NotDrainedOnCollect()
{
// A latched boot fact, not a per-interval counter: every subsequent report must
// carry it, or the badge would flicker off after the first report.
var collector = new SiteHealthCollector();
collector.SetStartupReconcilerActive(false);
collector.CollectReport("TestSite");
var second = collector.CollectReport("TestSite");
Assert.False(second.StartupReconcilerActive);
}
/// <summary>Verifies the case: set Startup Reconciler Active, is Not Write Once.</summary>
[Fact]
public void SetStartupReconcilerActive_IsNotWriteOnce()
{
// Nothing in the Host calls this twice today, but a latch that silently ignored a
// correction would be a nasty way to find that out.
var collector = new SiteHealthCollector();
collector.SetStartupReconcilerActive(false);
collector.SetStartupReconcilerActive(true);
Assert.True(collector.CollectReport("TestSite").StartupReconcilerActive);
}
}