< Summary

Information
Class: TeleFlow.Telegram.Webhooks.Internal.TelegramWebhookOptionsValidator
Assembly: TeleFlow.Framework.Webhooks
File(s): /_/src/TeleFlow.Framework.Webhooks/Internal/TelegramWebhookOptionsValidator.cs
Line coverage
91%
Covered lines: 11
Uncovered lines: 1
Coverable lines: 12
Total lines: 33
Line coverage: 91.6%
Branch coverage
87%
Covered branches: 7
Total branches: 8
Branch coverage: 87.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Validate(...)87.5%8891.66%

File(s)

/_/src/TeleFlow.Framework.Webhooks/Internal/TelegramWebhookOptionsValidator.cs

#LineLine coverage
 1namespace TeleFlow.Telegram.Webhooks.Internal;
 2
 3internal static class TelegramWebhookOptionsValidator
 4{
 5    public static void Validate(TelegramWebhookOptions options)
 6    {
 177        ArgumentNullException.ThrowIfNull(options);
 8
 179        if (string.IsNullOrWhiteSpace(options.Path))
 10        {
 011            throw new InvalidOperationException("Webhook path must not be empty.");
 12        }
 13
 1714        options.Path = options.Path.Trim();
 15
 1716        if (!options.Path.StartsWith('/'))
 17        {
 118            throw new InvalidOperationException("Webhook path must start with '/'.");
 19        }
 20
 1621        if (options.SecretToken is null)
 22        {
 1323            return;
 24        }
 25
 326        if (string.IsNullOrWhiteSpace(options.SecretToken))
 27        {
 128            throw new InvalidOperationException("Webhook secret token must not be empty.");
 29        }
 30
 231        options.SecretToken = options.SecretToken.Trim();
 232    }
 33}