using AcDream.Runtime.Chat; namespace AcDream.Runtime.Tests.Chat; /// /// Campaign CT slice B2: retail expands a typed reply abbreviation the moment /// the space lands, so the player can see who they are replying to. /// public sealed class ChatTextReplacementsTests { private const string LastTeller = "Dww"; [Theory] // Recovered from the constant pool: data_7C4C70 "r ", data_7C4C68 "rp ", // data_7C4C58 "reply " — and SetReplyTextInChatBox accepts either command // prefix, testing the first character against '/' (0x2F) or '@' (0x40). [InlineData("/r ")] [InlineData("/rp ")] [InlineData("/reply ")] [InlineData("@r ")] [InlineData("@rp ")] [InlineData("@reply ")] [InlineData("/R ")] public void AReplyAbbreviationExpandsToATellAtTheLastTeller(string typed) => Assert.Equal("@tell Dww, ", ChatTextReplacements.Expand(typed, LastTeller)); [Fact] public void TheExpansionEndsInASpaceSoTypingContinuesCleanly() { // Without it the first character the player types joins the comma. string expanded = ChatTextReplacements.Expand("/r ", LastTeller)!; Assert.EndsWith(", ", expanded); } [Theory] // Still being typed — "/r" could yet become "/roleplay", so expanding // before the space would hijack a different command mid-word. [InlineData("/r")] [InlineData("/rep")] // A longer verb that merely STARTS with a reply verb. [InlineData("/roleplay ")] [InlineData("/rt ")] // Already has a message: the trigger is the abbreviation ALONE. [InlineData("/r hello ")] // Not a command at all. [InlineData("r ")] [InlineData("hello ")] [InlineData("")] public void AnythingElseIsLeftAlone(string typed) => Assert.Null(ChatTextReplacements.Expand(typed, LastTeller)); [Fact] public void WithNobodyToReplyToNothingIsRewritten() { // Retail performs no expansion rather than producing a tell addressed // to nobody; the ordinary submit path is what says // "Someone must @tell you first!". Assert.Null(ChatTextReplacements.Expand("/r ", lastTeller: null)); Assert.Null(ChatTextReplacements.Expand("/r ", lastTeller: string.Empty)); } [Fact] public void ANameWithSpacesIsPreserved() { // AC names can be multiple words, and retail's own tell syntax needs // the comma precisely because of that. Assert.Equal( "@tell Aunt Agatha, ", ChatTextReplacements.Expand("/r ", "Aunt Agatha")); } }