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:
@@ -0,0 +1,60 @@
|
||||
using Microsoft.Extensions.Options;
|
||||
|
||||
namespace ZB.MOM.WW.ScadaBridge.SiteRuntime.Tests;
|
||||
|
||||
/// <summary>
|
||||
/// <see cref="SiteRuntimeOptions"/> values size the staggered Instance-Actor
|
||||
/// startup batches, the dedicated script-execution thread scheduler, and the
|
||||
/// site-wide stream buffer. A zero/negative count crashes actor construction with
|
||||
/// an opaque <see cref="ArgumentOutOfRangeException"/>; these tests assert the
|
||||
/// <see cref="SiteRuntimeOptionsValidator"/> rejects a bad
|
||||
/// <c>ScadaBridge:SiteRuntime</c> section with a clear, key-naming message.
|
||||
/// </summary>
|
||||
public class SiteRuntimeOptionsValidatorTests
|
||||
{
|
||||
private static ValidateOptionsResult Validate(SiteRuntimeOptions options) =>
|
||||
new SiteRuntimeOptionsValidator().Validate(Options.DefaultName, options);
|
||||
|
||||
[Fact]
|
||||
public void DefaultOptions_AreValid()
|
||||
{
|
||||
var result = Validate(new SiteRuntimeOptions());
|
||||
Assert.True(result.Succeeded, result.FailureMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZeroStartupBatchSize_IsRejected()
|
||||
{
|
||||
var result = Validate(new SiteRuntimeOptions { StartupBatchSize = 0 });
|
||||
|
||||
Assert.True(result.Failed);
|
||||
Assert.Contains("StartupBatchSize", result.FailureMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZeroScriptExecutionThreadCount_IsRejected()
|
||||
{
|
||||
var result = Validate(new SiteRuntimeOptions { ScriptExecutionThreadCount = 0 });
|
||||
|
||||
Assert.True(result.Failed);
|
||||
Assert.Contains("ScriptExecutionThreadCount", result.FailureMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void ZeroStreamBufferSize_IsRejected()
|
||||
{
|
||||
var result = Validate(new SiteRuntimeOptions { StreamBufferSize = 0 });
|
||||
|
||||
Assert.True(result.Failed);
|
||||
Assert.Contains("StreamBufferSize", result.FailureMessage);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void NegativeStartupBatchDelayMs_IsRejected()
|
||||
{
|
||||
var result = Validate(new SiteRuntimeOptions { StartupBatchDelayMs = -1 });
|
||||
|
||||
Assert.True(result.Failed);
|
||||
Assert.Contains("StartupBatchDelayMs", result.FailureMessage);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user