Files
wx-win-agent/tests/node-agent/WxAgent.Core.Tests/WechatTextInputTests.cs
T
rogee edba7d0d38
Build web service image / build (push) Successful in 1m15s
feat: support long text and safe attachment batches
2026-09-30 09:16:36 +08:00

36 lines
1.3 KiB
C#

using WxAgent.Core;
using Xunit;
namespace WxAgent.Core.Tests;
public sealed class WechatTextInputTests
{
[Fact]
public void PreservesMultilineWhitespaceWithCanonicalLineEndings()
{
Assert.Equal("first\n\n second\t\nthird", WechatTextInput.Prepare("first\r\n\r\n second\t\rthird"));
Assert.Equal(new string('x', 4000), WechatTextInput.Prepare(new string('x', 4000)));
Assert.Throws<WxAgentException>(() => WechatTextInput.Prepare(new string('x', 4001)));
}
[Theory]
[InlineData("")]
[InlineData(" \r\n\t")]
[InlineData("before\0after")]
[InlineData("before\u001bafter")]
public void RejectsEmptyOrUnsafeInput(string input) =>
Assert.Throws<WxAgentException>(() => WechatTextInput.Prepare(input));
[Fact]
public void QuoteParserPreservesBlankLinesAndIndentation()
{
const string reply = "first\n\n second ";
var parsed = Assert.Single(VisibleMessageParser.Parse([reply + "\n引用 Alice 的消息 : original"]));
Assert.Equal(reply, parsed.Text);
Assert.Equal(ChatMessageType.Quote, parsed.Type);
Assert.True(WechatSendConfirmation.Matches(parsed, new Dictionary<string, int>(),
new Dictionary<string, int> { [parsed.Fingerprint] = 1 }, ChatMessageType.Quote, reply));
Assert.Equal("original", parsed.Quote!.Text);
}
}