513fa1aa16
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.
49 lines
1.9 KiB
C#
49 lines
1.9 KiB
C#
using ZB.MOM.WW.ScadaBridge.Commons.Messages.Health;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring.Tests;
|
|
|
|
/// <summary>
|
|
/// <c>SiteHealthReport.SecretMirrorStatuses</c> carries every site node's
|
|
/// deployed-secrets mirror failures (the standby's included) on the active node's report.
|
|
/// </summary>
|
|
public class SecretMirrorStatusHealthFieldTests
|
|
{
|
|
/// <summary>Verifies that a report collected before any status was supplied leaves the field null.</summary>
|
|
[Fact]
|
|
public void CollectReport_NeverTold_LeavesTheFieldNull()
|
|
{
|
|
Assert.Null(new SiteHealthCollector().CollectReport("TestSite").SecretMirrorStatuses);
|
|
}
|
|
|
|
/// <summary>Verifies that a collected report carries the latest snapshot without draining it.</summary>
|
|
[Fact]
|
|
public void CollectReport_CarriesTheLatestSnapshot_AndDoesNotDrainIt()
|
|
{
|
|
var collector = new SiteHealthCollector();
|
|
collector.SetSecretMirrorStatuses(
|
|
[
|
|
new SecretMirrorNodeStatus("node-a", DateTimeOffset.UtcNow, []),
|
|
new SecretMirrorNodeStatus(
|
|
"node-b", DateTimeOffset.UtcNow, [new SecretMirrorFailure("S1", "did not decrypt")]),
|
|
]);
|
|
|
|
var first = collector.CollectReport("TestSite").SecretMirrorStatuses!;
|
|
var second = collector.CollectReport("TestSite").SecretMirrorStatuses!;
|
|
|
|
Assert.Equal(["node-a", "node-b"], first.Select(s => s.NodeName));
|
|
Assert.Equal(2, second.Count); // point-in-time, not interval-drained
|
|
Assert.Equal("S1", Assert.Single(first[1].Failures).SecretName);
|
|
}
|
|
|
|
/// <summary>Verifies that setting the status to null resets the field to no data.</summary>
|
|
[Fact]
|
|
public void SetNull_ResetsToNoData()
|
|
{
|
|
var collector = new SiteHealthCollector();
|
|
collector.SetSecretMirrorStatuses([]);
|
|
collector.SetSecretMirrorStatuses(null);
|
|
|
|
Assert.Null(collector.CollectReport("TestSite").SecretMirrorStatuses);
|
|
}
|
|
}
|