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.
67 lines
2.6 KiB
C#
67 lines
2.6 KiB
C#
namespace ZB.MOM.WW.ScadaBridge.HealthMonitoring.Tests;
|
|
|
|
/// <summary>
|
|
/// Regression coverage. <see cref="ISiteEventLogger.FailedWriteCount"/>
|
|
/// is a cumulative (point-in-time) counter. A periodic
|
|
/// <c>SiteEventLogFailureCountReporter</c> hosted service polls the count and
|
|
/// pushes it into the collector via
|
|
/// <see cref="ISiteHealthCollector.SetSiteEventLogWriteFailures"/> so the next
|
|
/// <see cref="ISiteHealthCollector.CollectReport"/> includes it in the report
|
|
/// payload as <c>SiteEventLogWriteFailures</c>. Unlike the per-interval
|
|
/// SiteAuditWriteFailures counter, this value is NOT reset on collect — it
|
|
/// carries forward whatever the most recent poller push delivered.
|
|
/// </summary>
|
|
public class SiteEventLogWriteFailuresMetricTests
|
|
{
|
|
private readonly SiteHealthCollector _collector = new();
|
|
|
|
/// <summary>Verifies that a count that was set appears in the collected report.</summary>
|
|
[Fact]
|
|
public void Set_Then_CollectReport_IncludesCount()
|
|
{
|
|
_collector.SetSiteEventLogWriteFailures(17L);
|
|
|
|
var report = _collector.CollectReport("site-1");
|
|
|
|
Assert.Equal(17L, report.SiteEventLogWriteFailures);
|
|
}
|
|
|
|
/// <summary>Verifies that the report payload includes the site event log write failure count, defaulting to zero.</summary>
|
|
[Fact]
|
|
public void Report_Payload_Includes_SiteEventLogWriteFailures_AsZeroByDefault()
|
|
{
|
|
var report = _collector.CollectReport("site-1");
|
|
|
|
Assert.Equal(0L, report.SiteEventLogWriteFailures);
|
|
}
|
|
|
|
/// <summary>Verifies that collecting a report does not reset the site event log write failure count.</summary>
|
|
[Fact]
|
|
public void CollectReport_DoesNotReset_SiteEventLogWriteFailures()
|
|
{
|
|
// This is a point-in-time cumulative count — successive CollectReport
|
|
// calls before the next poller tick MUST carry forward the same value
|
|
// rather than resetting to zero (which would falsely indicate no failures
|
|
// between the two reports).
|
|
_collector.SetSiteEventLogWriteFailures(42L);
|
|
|
|
var first = _collector.CollectReport("site-1");
|
|
var second = _collector.CollectReport("site-1");
|
|
|
|
Assert.Equal(42L, first.SiteEventLogWriteFailures);
|
|
Assert.Equal(42L, second.SiteEventLogWriteFailures);
|
|
}
|
|
|
|
/// <summary>Verifies that setting the count overwrites the previous value.</summary>
|
|
[Fact]
|
|
public void Set_Overwrites_Previous_Value()
|
|
{
|
|
_collector.SetSiteEventLogWriteFailures(5L);
|
|
_collector.SetSiteEventLogWriteFailures(9L);
|
|
|
|
var report = _collector.CollectReport("site-1");
|
|
|
|
Assert.Equal(9L, report.SiteEventLogWriteFailures);
|
|
}
|
|
}
|