namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring.Tests;
///
/// Deferred-work register row 73 — SiteHealthReport.StartupReconcilerActive surfaces
/// whether a site node spawned its SiteReconciliationActor at boot.
///
///
/// 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 pre-row-73
/// site build), true = running, false = skipped because no IDeploymentConfigFetcher
/// was available. Collapsing null into false would badge every site the moment central is
/// upgraded ahead of them.
///
public class StartupReconcilerHealthFieldTests
{
[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);
}
[Fact]
public void CollectReport_ReconcilerSpawned_ReportsTrue()
{
var collector = new SiteHealthCollector();
collector.SetStartupReconcilerActive(true);
Assert.True(collector.CollectReport("TestSite").StartupReconcilerActive);
}
[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);
}
[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);
}
[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);
}
}