Files
wx-win-agent/tests/WxAgent.Core.Tests/WechatMentionConfirmationTests.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

32 lines
1.4 KiB
C#

using WxAgent.Core;
using Xunit;
namespace WxAgent.Core.Tests;
public sealed class WechatMentionConfirmationTests
{
[Theory]
[InlineData("\uFFFC", true)]
[InlineData("\uFFFC\u2005", true)]
[InlineData("@Hao 豪", false)]
[InlineData("@", false)]
[InlineData("\uFFFCunexpected", false)]
[InlineData("\uFFFC\uFFFC", false)]
public void RequiresExactlyOneStructuredMentionToken(string value, bool expected) =>
Assert.Equal(expected, WechatSendConfirmation.IsMentionToken(value));
[Theory]
[InlineData("@Hao 豪 marker", "Hao 豪", true)]
[InlineData("@Hao 豪\u2005marker", "Hao 豪", true)]
[InlineData("@所有人 marker", "所有人", true)]
[InlineData("@Hao 豪 other", "Hao 豪", false)]
[InlineData("@Other marker", "Hao 豪", false)]
public void RequiresFreshExactMentionAndBody(string text, string member, bool expected)
{
var message = new ChatMessageSnapshot(text, "fresh", 0, ChatMessageType.Text);
Assert.Equal(expected, WechatSendConfirmation.MatchesMention(message, new HashSet<string>(), member, "marker"));
Assert.False(WechatSendConfirmation.MatchesMention(message, new HashSet<string> { "fresh" }, member, "marker"));
Assert.False(WechatSendConfirmation.MatchesMention(message with { Type = ChatMessageType.Quote }, new HashSet<string>(), member, "marker"));
}
}