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.
129 lines
5.3 KiB
C#
129 lines
5.3 KiB
C#
namespace ZB.MOM.WW.ScadaBridge.SiteCallAudit.Tests;
|
|
|
|
public class SiteCallAuditOptionsTests
|
|
{
|
|
/// <summary>Verifies that the defaults are the expected values.</summary>
|
|
[Fact]
|
|
public void Defaults_AreExpectedValues()
|
|
{
|
|
var options = new SiteCallAuditOptions();
|
|
|
|
// Stuck threshold mirrors NotificationOutboxOptions.StuckAgeThreshold.
|
|
Assert.Equal(TimeSpan.FromMinutes(10), options.StuckAgeThreshold);
|
|
// KPI interval mirrors NotificationOutboxOptions.DeliveredKpiWindow.
|
|
Assert.Equal(TimeSpan.FromMinutes(1), options.KpiInterval);
|
|
|
|
// Reconciliation tick cadence mirrors SiteAuditReconciliationOptions.
|
|
Assert.Equal(TimeSpan.FromMinutes(5), options.ReconciliationInterval);
|
|
// Purge tick cadence mirrors AuditLogPurgeOptions.
|
|
Assert.Equal(TimeSpan.FromHours(24), options.PurgeInterval);
|
|
// Retention window mirrors the central audit-store retention policy.
|
|
Assert.Equal(365, options.RetentionDays);
|
|
}
|
|
|
|
/// <summary>Verifies that the resolved reconciliation interval defaults to the configured value.</summary>
|
|
[Fact]
|
|
public void ResolvedReconciliationInterval_DefaultsToConfiguredValue()
|
|
{
|
|
var options = new SiteCallAuditOptions();
|
|
|
|
Assert.Equal(options.ReconciliationInterval, options.ResolvedReconciliationInterval);
|
|
}
|
|
|
|
/// <summary>Verifies that the resolved reconciliation interval clamps a zero or negative value to the minimum.</summary>
|
|
/// <param name="configuredSeconds">The configured interval in seconds.</param>
|
|
[Theory]
|
|
[InlineData(0)]
|
|
[InlineData(-5)]
|
|
public void ResolvedReconciliationInterval_ClampsZeroOrNegativeToMinimum(int configuredSeconds)
|
|
{
|
|
// A misconfigured 0 / negative interval must never resolve to TimeSpan.Zero
|
|
// (which would make Akka's ScheduleTellRepeatedlyCancelable spin). The
|
|
// documented floor is >= 1 second.
|
|
var options = new SiteCallAuditOptions
|
|
{
|
|
ReconciliationInterval = TimeSpan.FromSeconds(configuredSeconds),
|
|
};
|
|
|
|
Assert.True(
|
|
options.ResolvedReconciliationInterval >= TimeSpan.FromSeconds(1),
|
|
$"expected the resolved interval to clamp to >= 1s, got {options.ResolvedReconciliationInterval}");
|
|
Assert.Equal(TimeSpan.FromSeconds(1), options.ResolvedReconciliationInterval);
|
|
}
|
|
|
|
/// <summary>Verifies that an override of the reconciliation interval bypasses the clamp.</summary>
|
|
[Fact]
|
|
public void ResolvedReconciliationInterval_OverrideBypassesClamp()
|
|
{
|
|
// The test-only override drops the cadence below the clamp floor so unit
|
|
// tests can run the tick at millisecond cadence.
|
|
var sub1Second = TimeSpan.FromMilliseconds(50);
|
|
var options = new SiteCallAuditOptions
|
|
{
|
|
ReconciliationInterval = TimeSpan.FromMinutes(5),
|
|
ReconciliationIntervalOverride = sub1Second,
|
|
};
|
|
|
|
Assert.Equal(sub1Second, options.ResolvedReconciliationInterval);
|
|
}
|
|
|
|
/// <summary>Verifies that the resolved purge interval defaults to the configured value.</summary>
|
|
[Fact]
|
|
public void ResolvedPurgeInterval_DefaultsToConfiguredValue()
|
|
{
|
|
var options = new SiteCallAuditOptions();
|
|
|
|
Assert.Equal(options.PurgeInterval, options.ResolvedPurgeInterval);
|
|
}
|
|
|
|
/// <summary>Verifies that the resolved purge interval clamps a zero or negative value to the minimum.</summary>
|
|
/// <param name="configuredSeconds">The configured interval in seconds.</param>
|
|
[Theory]
|
|
[InlineData(0)]
|
|
[InlineData(-30)]
|
|
public void ResolvedPurgeInterval_ClampsZeroOrNegativeToMinimum(int configuredSeconds)
|
|
{
|
|
// A misconfigured 0 / negative purge interval clamps to the documented
|
|
// >= 1 minute floor (the purge is daily, so a more generous floor than
|
|
// the reconciliation tick).
|
|
var options = new SiteCallAuditOptions
|
|
{
|
|
PurgeInterval = TimeSpan.FromSeconds(configuredSeconds),
|
|
};
|
|
|
|
Assert.True(
|
|
options.ResolvedPurgeInterval >= TimeSpan.FromMinutes(1),
|
|
$"expected the resolved interval to clamp to >= 1min, got {options.ResolvedPurgeInterval}");
|
|
Assert.Equal(TimeSpan.FromMinutes(1), options.ResolvedPurgeInterval);
|
|
}
|
|
|
|
/// <summary>Verifies that a purge interval below the one-minute floor is clamped to the minimum.</summary>
|
|
[Fact]
|
|
public void ResolvedPurgeInterval_BelowMinuteFloorClampsToMinimum()
|
|
{
|
|
// A positive-but-sub-minute config value still clamps to the 1-minute floor.
|
|
var options = new SiteCallAuditOptions
|
|
{
|
|
PurgeInterval = TimeSpan.FromSeconds(5),
|
|
};
|
|
|
|
Assert.Equal(TimeSpan.FromMinutes(1), options.ResolvedPurgeInterval);
|
|
}
|
|
|
|
/// <summary>Verifies that an override of the purge interval bypasses the clamp.</summary>
|
|
[Fact]
|
|
public void ResolvedPurgeInterval_OverrideBypassesClamp()
|
|
{
|
|
// The test-only override drops the cadence below the clamp floor so unit
|
|
// tests can run the purge tick at millisecond cadence.
|
|
var subMinute = TimeSpan.FromMilliseconds(50);
|
|
var options = new SiteCallAuditOptions
|
|
{
|
|
PurgeInterval = TimeSpan.FromHours(24),
|
|
PurgeIntervalOverride = subMinute,
|
|
};
|
|
|
|
Assert.Equal(subMinute, options.ResolvedPurgeInterval);
|
|
}
|
|
}
|