Files
ScadaBridge/tests/ZB.MOM.WW.ScadaBridge.NotificationService.Tests/NotificationOptionsValidatorTests.cs
T
Joseph Doherty 513fa1aa16 docs(tests): fix CommentChecker findings across tests/ — 13,392 → 0 (repo-wide scan clean)
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.
2026-10-07 15:05:49 -04:00

64 lines
2.4 KiB
C#

using Microsoft.Extensions.Options;
namespace ZB.MOM.WW.ScadaBridge.NotificationService.Tests;
/// <summary>
/// Arch-review 08 §1.5: <see cref="NotificationOptions"/> supplies the SMTP fallback
/// connection timeout and max-concurrent-connections used by the central Email delivery
/// adapter when the deployed <c>SmtpConfiguration</c> leaves them unset. A non-positive
/// value there is not a usable fallback; reject it fast at startup with a key-naming message.
/// </summary>
public class NotificationOptionsValidatorTests
{
private static ValidateOptionsResult Validate(NotificationOptions options) =>
new NotificationOptionsValidator().Validate(Options.DefaultName, options);
/// <summary>Verifies that the default options pass validation.</summary>
[Fact]
public void DefaultOptions_AreValid()
{
var result = Validate(new NotificationOptions());
Assert.True(result.Succeeded, result.FailureMessage);
}
/// <summary>Verifies that a zero connection timeout is rejected.</summary>
[Fact]
public void ZeroConnectionTimeoutSeconds_IsRejected()
{
var result = Validate(new NotificationOptions { ConnectionTimeoutSeconds = 0 });
Assert.True(result.Failed);
Assert.Contains("ConnectionTimeoutSeconds", result.FailureMessage);
}
/// <summary>Verifies that a negative connection timeout is rejected.</summary>
[Fact]
public void NegativeConnectionTimeoutSeconds_IsRejected()
{
var result = Validate(new NotificationOptions { ConnectionTimeoutSeconds = -1 });
Assert.True(result.Failed);
Assert.Contains("ConnectionTimeoutSeconds", result.FailureMessage);
}
/// <summary>Verifies that a zero maximum concurrent connection count is rejected.</summary>
[Fact]
public void ZeroMaxConcurrentConnections_IsRejected()
{
var result = Validate(new NotificationOptions { MaxConcurrentConnections = 0 });
Assert.True(result.Failed);
Assert.Contains("MaxConcurrentConnections", result.FailureMessage);
}
/// <summary>Verifies that a negative maximum concurrent connection count is rejected.</summary>
[Fact]
public void NegativeMaxConcurrentConnections_IsRejected()
{
var result = Validate(new NotificationOptions { MaxConcurrentConnections = -1 });
Assert.True(result.Failed);
Assert.Contains("MaxConcurrentConnections", result.FailureMessage);
}
}