Files
wx-win-agent/tests/WxAgent.Core.Tests/WechatTextInputTests.cs
T
rogee c49f6a10b2 feat: generalize session sending with multiline text and structured mentions
Add named-session file/image/reply sending, preserve multiline text, and share safe member/all mention handling. Protect existing drafts, bind popup selection to the current window, validate structured mention tokens, and require fresh matching visible messages without automatic resend. Core tests: 121 passed. Windows 4.1.13.63 final validation: 9/9 passed. Record explicit coverage limits and sanitized evidence.
2026-09-06 17:10:53 +08:00

35 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 HashSet<string>(), ChatMessageType.Quote, reply));
Assert.Equal("original", parsed.Quote!.Text);
}
}