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.
43 lines
1.7 KiB
C#
43 lines
1.7 KiB
C#
using Microsoft.Extensions.Options;
|
|
|
|
namespace ZB.MOM.WW.ScadaBridge.DataConnectionLayer.Tests;
|
|
|
|
/// <summary>
|
|
/// Regression: <see cref="DataConnectionOptions"/> intervals/timeouts drive the
|
|
/// DCL reconnect/tag-resolution timers and the seed-read retry loop; a
|
|
/// zero/negative duration (or a non-positive <c>SeedReadMaxAttempts</c>) must be
|
|
/// rejected at startup by an <see cref="IValidateOptions{TOptions}"/> with a
|
|
/// clear, key-naming message rather than surfacing later at runtime.
|
|
/// </summary>
|
|
public class DataConnectionOptionsValidatorTests
|
|
{
|
|
private static ValidateOptionsResult Validate(DataConnectionOptions options) =>
|
|
new DataConnectionOptionsValidator().Validate(Options.DefaultName, options);
|
|
|
|
/// <summary>Verifies that the default options are valid.</summary>
|
|
[Fact]
|
|
public void DefaultOptions_AreValid()
|
|
{
|
|
var result = Validate(new DataConnectionOptions());
|
|
Assert.True(result.Succeeded, result.FailureMessage);
|
|
}
|
|
|
|
/// <summary>Verifies that a zero reconnect interval is rejected.</summary>
|
|
[Fact]
|
|
public void ZeroReconnectInterval_IsRejected()
|
|
{
|
|
var result = Validate(new DataConnectionOptions { ReconnectInterval = TimeSpan.Zero });
|
|
Assert.True(result.Failed);
|
|
Assert.Contains("ReconnectInterval", result.FailureMessage);
|
|
}
|
|
|
|
/// <summary>Verifies that a non-positive seed-read max attempts value is rejected.</summary>
|
|
[Fact]
|
|
public void NonPositiveSeedReadMaxAttempts_IsRejected()
|
|
{
|
|
var result = Validate(new DataConnectionOptions { SeedReadMaxAttempts = 0 });
|
|
Assert.True(result.Failed);
|
|
Assert.Contains("SeedReadMaxAttempts", result.FailureMessage);
|
|
}
|
|
}
|