using AcDream.Core.Chat; using AcDream.UI.Abstractions.Panels.Chat; namespace AcDream.UI.Abstractions.Tests.Panels.Chat; /// /// Phase I.4: tracks the /// sender of the most recent INCOMING Tell so the chat panel can route /// /r replies. Outgoing self-sent Tell echoes (which run through /// with SenderGuid = 0) must not /// pollute the field. /// public sealed class ChatVMLastTellSenderTests { [Fact] public void LastIncomingTellSender_StartsNull() { var log = new ChatLog(); var vm = new ChatVM(log); Assert.Null(vm.LastIncomingTellSender); } [Fact] public void LastIncomingTellSender_PopulatedFromOnTellReceived() { var log = new ChatLog(); var vm = new ChatVM(log); log.OnTellReceived(sender: "Bestie", text: "ping", senderGuid: 0x5000_00AAu); Assert.Equal("Bestie", vm.LastIncomingTellSender); } [Fact] public void LastIncomingTellSender_UpdatedToMostRecentIncomingTell() { var log = new ChatLog(); var vm = new ChatVM(log); log.OnTellReceived("Bestie", "ping", 0x5000_00AAu); log.OnTellReceived("Regal", "yo", 0x5000_00BBu); Assert.Equal("Regal", vm.LastIncomingTellSender); } [Fact] public void LastIncomingTellSender_IgnoresSelfSentEcho() { var log = new ChatLog(); var vm = new ChatVM(log); // /r reply echo: SenderGuid = 0 (no real GUID for ourselves). // Must NOT clobber the captured sender. log.OnTellReceived("Bestie", "ping", 0x5000_00AAu); log.OnSelfSent(ChatKind.Tell, "back at you", targetOrChannel: "Bestie"); Assert.Equal("Bestie", vm.LastIncomingTellSender); } [Fact] public void LastIncomingTellSender_IgnoresLocalSpeech() { var log = new ChatLog(); var vm = new ChatVM(log); log.OnLocalSpeech("Caith", "hello", 0x5000_00CCu, isRanged: false); Assert.Null(vm.LastIncomingTellSender); } [Fact] public void LastIncomingTellSender_IgnoresChannelBroadcast() { var log = new ChatLog(); var vm = new ChatVM(log); log.OnChannelBroadcast(channelId: 7, sender: "Caith", text: "raid time"); Assert.Null(vm.LastIncomingTellSender); } }