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