< Summary - AsyncResponse (Release / net8.0+net10.0 / unit+integration)

Information
Class: AsyncResponse.Transports.Redis.RedisTransportOptionsValidator
Assembly: AsyncResponse.Transports.Redis
File(s): /home/runner/work/AsyncResponse/AsyncResponse/src/Transports/AsyncResponse.Transports.Redis/RedisTransportOptionsValidator.cs
Line coverage
100%
Covered lines: 35
Uncovered lines: 0
Coverable lines: 35
Total lines: 63
Line coverage: 100%
Branch coverage
100%
Covered branches: 18
Total branches: 18
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Required(...)100%22100%
Positive(...)100%22100%
PositiveOrNull(...)100%44100%
ValidateCommon(...)100%1010100%

File(s)

/home/runner/work/AsyncResponse/AsyncResponse/src/Transports/AsyncResponse.Transports.Redis/RedisTransportOptionsValidator.cs

#LineLine coverage
 1namespace AsyncResponse.Transports.Redis;
 2
 3internal static class RedisTransportOptionsValidator
 4{
 5    /// <summary>Validates the supplied options.</summary>
 6    public static string Required(string? value, string name)
 37        => !string.IsNullOrWhiteSpace(value)
 38            ? value
 39            : throw new InvalidOperationException($"{nameof(RedisAsyncResponseTransportOptions)}.{name} must be configur
 10
 11    /// <summary>Validates the supplied options.</summary>
 12    public static void Positive(TimeSpan value, string name)
 13    {
 314        if (value <= TimeSpan.Zero)
 315            throw new InvalidOperationException($"{nameof(RedisAsyncResponseTransportOptions)}.{name} must be positive."
 316    }
 17
 18    /// <summary>Validates the supplied options.</summary>
 19    public static void PositiveOrNull(long? value, string name)
 20    {
 321        if (value is <= 0)
 322            throw new InvalidOperationException($"{nameof(RedisAsyncResponseTransportOptions)}.{name} must be positive w
 323    }
 24
 25    /// <summary>Validates the supplied options.</summary>
 26    public static void ValidateCommon(RedisAsyncResponseTransportOptions options)
 27    {
 328        _ = Required(options.KeyPrefix, nameof(options.KeyPrefix));
 329        _ = Required(options.WorkerConsumerGroup, nameof(options.WorkerConsumerGroup));
 330        _ = Required(options.ResponseConsumerGroup, nameof(options.ResponseConsumerGroup));
 331        _ = Required(options.CorrelationIdField, nameof(options.CorrelationIdField));
 332        _ = Required(options.PayloadField, nameof(options.PayloadField));
 333        _ = Required(options.DefaultReplyTargetName, nameof(options.DefaultReplyTargetName));
 34
 335        Positive(options.OperationTimeout, nameof(options.OperationTimeout));
 336        Positive(options.PublishRetryBaseDelay, nameof(options.PublishRetryBaseDelay));
 337        Positive(options.PublishRetryMaxDelay, nameof(options.PublishRetryMaxDelay));
 338        Positive(options.SubscriberRetryBaseDelay, nameof(options.SubscriberRetryBaseDelay));
 339        Positive(options.SubscriberRetryMaxDelay, nameof(options.SubscriberRetryMaxDelay));
 340        PositiveOrNull(options.StreamMaxLength, nameof(options.StreamMaxLength));
 341        PositiveOrNull(options.DeadLetterStreamMaxLength, nameof(options.DeadLetterStreamMaxLength));
 42
 343        if (options.PublishMaxAttempts <= 0)
 344            throw new InvalidOperationException($"{nameof(RedisAsyncResponseTransportOptions)}.{nameof(options.PublishMa
 45
 346        if (options.PublishRetryBaseDelay > options.PublishRetryMaxDelay)
 47        {
 348            throw new InvalidOperationException(
 349                $"{nameof(RedisAsyncResponseTransportOptions)}.{nameof(options.PublishRetryBaseDelay)} cannot exceed " +
 350                $"{nameof(RedisAsyncResponseTransportOptions)}.{nameof(options.PublishRetryMaxDelay)}.");
 51        }
 52
 353        if (options.SubscriberRetryBaseDelay > options.SubscriberRetryMaxDelay)
 54        {
 355            throw new InvalidOperationException(
 356                $"{nameof(RedisAsyncResponseTransportOptions)}.{nameof(options.SubscriberRetryBaseDelay)} cannot exceed 
 357                $"{nameof(RedisAsyncResponseTransportOptions)}.{nameof(options.SubscriberRetryMaxDelay)}.");
 58        }
 59
 360        if (options.HostShutdownTimeout is { } hostShutdownTimeout && hostShutdownTimeout <= TimeSpan.Zero)
 361            throw new InvalidOperationException($"{nameof(RedisAsyncResponseTransportOptions)}.{nameof(options.HostShutd
 362    }
 63}