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.
This commit is contained in:
@@ -0,0 +1,34 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user