< Summary

Information
Class: TeleFlow.Telegram.Internal.Options.TelegramLongPollingOptionsValidator
Assembly: TeleFlow.Framework.LongPolling
File(s): /_/src/TeleFlow.Framework.LongPolling/Internal/Options/TelegramLongPollingOptionsValidator.cs
Line coverage
90%
Covered lines: 20
Uncovered lines: 2
Coverable lines: 22
Total lines: 59
Line coverage: 90.9%
Branch coverage
84%
Covered branches: 22
Total branches: 26
Branch coverage: 84.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Validate(...)60%111077.77%
ValidateBackoff(...)100%1616100%

File(s)

/_/src/TeleFlow.Framework.LongPolling/Internal/Options/TelegramLongPollingOptionsValidator.cs

#LineLine coverage
 1namespace TeleFlow.Telegram.Internal.Options;
 2
 3internal static class TelegramLongPollingOptionsValidator
 4{
 5    public static void Validate(TelegramLongPollingOptions options)
 6    {
 257        ArgumentNullException.ThrowIfNull(options);
 8
 259        if (options.TimeoutSeconds <= 0)
 10        {
 011            throw new InvalidOperationException("Long polling timeout must be greater than zero.");
 12        }
 13
 2514        if (options.Limit is < 1 or > 100)
 15        {
 016            throw new InvalidOperationException("Long polling limit must be between 1 and 100.");
 17        }
 18
 2519        if (options.AllowedUpdates is null)
 20        {
 121            throw new InvalidOperationException("Long polling allowed updates options must be configured.");
 22        }
 23
 2424        ValidateBackoff(options.Backoff);
 1725    }
 26
 27    private static void ValidateBackoff(TelegramBackoffOptions? options)
 28    {
 2429        if (options is null)
 30        {
 131            throw new InvalidOperationException("Long polling backoff options must be configured.");
 32        }
 33
 2334        if (options.MinDelay < TimeSpan.Zero)
 35        {
 136            throw new InvalidOperationException("Long polling backoff minimum delay must not be negative.");
 37        }
 38
 2239        if (options.MaxDelay < TimeSpan.Zero)
 40        {
 141            throw new InvalidOperationException("Long polling backoff maximum delay must not be negative.");
 42        }
 43
 2144        if (options.MaxDelay < options.MinDelay)
 45        {
 146            throw new InvalidOperationException("Long polling backoff maximum delay must be greater than or equal to min
 47        }
 48
 2049        if (options.Factor < 1)
 50        {
 151            throw new InvalidOperationException("Long polling backoff factor must be greater than or equal to one.");
 52        }
 53
 1954        if (options.Jitter is < 0 or > 1)
 55        {
 256            throw new InvalidOperationException("Long polling backoff jitter must be between zero and one.");
 57        }
 1758    }
 59}