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