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.
40 lines
1.9 KiB
C#
40 lines
1.9 KiB
C#
using WxAgent.Core;
|
|
using Xunit;
|
|
|
|
namespace WxAgent.Core.Tests;
|
|
|
|
public sealed class WechatSendConfirmationTests
|
|
{
|
|
[Fact]
|
|
public void RequiresFreshMatchingTypeAndExactReplyText()
|
|
{
|
|
var baseline = new HashSet<string> { "old" };
|
|
var reply = new ChatMessageSnapshot("reply", "new", 0, ChatMessageType.Quote);
|
|
Assert.True(WechatSendConfirmation.Matches(reply, baseline, ChatMessageType.Quote, "reply"));
|
|
Assert.False(WechatSendConfirmation.Matches(reply with { Fingerprint = "old" }, baseline, ChatMessageType.Quote, "reply"));
|
|
Assert.False(WechatSendConfirmation.Matches(reply with { Type = ChatMessageType.Text }, baseline, ChatMessageType.Quote, "reply"));
|
|
Assert.False(WechatSendConfirmation.Matches(reply with { Text = "another reply" }, baseline, ChatMessageType.Quote, "reply"));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData("report.txt", true)]
|
|
[InlineData("文件\nreport.txt\n1 KB", true)]
|
|
[InlineData("文件\r\nreport.txt\r\n1 KB", true)]
|
|
[InlineData("other-report.txt", false)]
|
|
[InlineData("report.txt.backup", false)]
|
|
public void FileConfirmationRequiresExactFilenameLine(string text, bool expected)
|
|
{
|
|
var message = new ChatMessageSnapshot(text, "new", 0, ChatMessageType.File);
|
|
Assert.Equal(expected, WechatSendConfirmation.Matches(message, new HashSet<string>(), ChatMessageType.File, "report.txt"));
|
|
}
|
|
|
|
[Fact]
|
|
public void ImageConfirmationRejectsOtherTypesAndOldRows()
|
|
{
|
|
var message = new ChatMessageSnapshot("[图片]", "new", 0, ChatMessageType.Image);
|
|
Assert.True(WechatSendConfirmation.Matches(message, new HashSet<string>(), ChatMessageType.Image, null));
|
|
Assert.False(WechatSendConfirmation.Matches(message, new HashSet<string> { "new" }, ChatMessageType.Image, null));
|
|
Assert.False(WechatSendConfirmation.Matches(message with { Type = ChatMessageType.Text }, new HashSet<string>(), ChatMessageType.Image, null));
|
|
}
|
|
}
|