feat(options): eager startup validation for site-pipeline options (SiteRuntime, S&F, SiteEventLog) (arch-review 08 §1.5)
Claude-Session: https://claude.ai/code/session_01MtdgwpEeCUn6cUA5f1LMPj
This commit is contained in:
+50
@@ -0,0 +1,50 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.SiteEventLogging.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="SiteEventLogOptions"/> retention/purge values drive the daily purge
|
||||
/// PeriodicTimer (zero/negative trips its constructor) and the paging bounds gate
|
||||
/// query result sizes. These tests assert the
|
||||
/// <see cref="SiteEventLogOptionsValidator"/> rejects a bad
|
||||
/// <c>ScadaBridge:SiteEventLog</c> section with a clear, key-naming message.
|
||||
/// </summary>
|
||||
public class SiteEventLogOptionsValidatorTests
|
||||
{
|
||||
private static ValidateOptionsResult Validate(SiteEventLogOptions options) =>
|
||||
new SiteEventLogOptionsValidator().Validate(Options.DefaultName, options);
|
||||
|
||||
[Fact]
|
||||
public void DefaultOptions_AreValid()
|
||||
{
|
||||
var result = Validate(new SiteEventLogOptions());
|
||||
Assert.True(result.Succeeded, result.FailureMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZeroRetentionDays_IsRejected()
|
||||
{
|
||||
var result = Validate(new SiteEventLogOptions { RetentionDays = 0 });
|
||||
|
||||
Assert.True(result.Failed);
|
||||
Assert.Contains("RetentionDays", result.FailureMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZeroPurgeInterval_IsRejected()
|
||||
{
|
||||
var result = Validate(new SiteEventLogOptions { PurgeInterval = TimeSpan.Zero });
|
||||
|
||||
Assert.True(result.Failed);
|
||||
Assert.Contains("PurgeInterval", result.FailureMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void MaxQueryPageSize_BelowQueryPageSize_IsRejected()
|
||||
{
|
||||
var result = Validate(new SiteEventLogOptions { QueryPageSize = 500, MaxQueryPageSize = 100 });
|
||||
|
||||
Assert.True(result.Failed);
|
||||
Assert.Contains("MaxQueryPageSize", result.FailureMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user