Files
Telegram-Panel/tests/TelegramPanel.Web.Tests/UserChatActiveSendRetryPolicyTests.cs
2026-07-26 18:20:09 +08:00

48 lines
1.5 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using TelegramPanel.Web.Services;
using Xunit;
namespace TelegramPanel.Web.Tests;
public sealed class UserChatActiveSendRetryPolicyTests
{
[Theory]
[InlineData(-1, 0)]
[InlineData(0, 0)]
[InlineData(3, 3)]
[InlineData(8, 5)]
public void (int configured, int expected)
{
Assert.Equal(expected, UserChatActiveSendRetryPolicy.NormalizeMaxRetries(configured));
}
[Theory]
[InlineData("连接失败A task was canceled.")]
[InlineData("请求超时The operation timed out")]
[InlineData("连接失败CHANNEL_INVALID")]
[InlineData("PEER_ID_INVALID")]
[InlineData("CHAT_ID_INVALID")]
public void Peer错误允许重试(string error)
{
Assert.True(UserChatActiveSendRetryPolicy.ShouldRetry(error));
}
[Theory]
[InlineData("")]
[InlineData("账号权限不足CHAT_WRITE_FORBIDDEN")]
[InlineData("Session 失效AUTH_KEY_UNREGISTERED")]
[InlineData("词典模板解析结果为空,无法发送")]
[InlineData("触发限流FLOOD_WAIT")]
public void (string error)
{
Assert.False(UserChatActiveSendRetryPolicy.ShouldRetry(error));
}
[Fact]
public void ()
{
Assert.Equal(
"连接失败CHANNEL_INVALID自动重试 3 次后仍失败)",
UserChatActiveSendRetryPolicy.DescribeFinalFailure("连接失败CHANNEL_INVALID", 3));
}
}