Construct chat history, negotiated channels, friends, squelch, and reply targets in one presentation-independent Runtime owner. Make live routing, retained UI, devtools, and current-runtime projections borrow the exact instances, preserve reconnect reset semantics, and publish failure-isolated reentrant-safe chat commits. Co-authored-by: Codex <codex@openai.com>
48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
using AcDream.Core.Chat;
|
|
|
|
namespace AcDream.Core.Tests.Chat;
|
|
|
|
public sealed class ChatCommandTargetStateTests
|
|
{
|
|
[Fact]
|
|
public void TracksReplyAndRetellTargetsFromCommittedTranscript()
|
|
{
|
|
var chat = new ChatLog();
|
|
using var targets = new ChatCommandTargetState(chat);
|
|
|
|
chat.OnTellReceived("Bestie", "incoming", 0x50000001u);
|
|
chat.OnSelfSent(ChatKind.Tell, "outgoing", "Caith");
|
|
|
|
Assert.Equal("Bestie", targets.LastIncomingTellSender);
|
|
Assert.Equal("Caith", targets.LastOutgoingTellTarget);
|
|
}
|
|
|
|
[Fact]
|
|
public void ResetSessionForgetsTargetsButPreservesTranscript()
|
|
{
|
|
var chat = new ChatLog();
|
|
using var targets = new ChatCommandTargetState(chat);
|
|
chat.OnTellReceived("Bestie", "incoming", 0x50000001u);
|
|
chat.OnSelfSent(ChatKind.Tell, "outgoing", "Caith");
|
|
|
|
targets.ResetSession();
|
|
|
|
Assert.Null(targets.LastIncomingTellSender);
|
|
Assert.Null(targets.LastOutgoingTellTarget);
|
|
Assert.Equal(2, chat.Count);
|
|
}
|
|
|
|
[Fact]
|
|
public void DisposeDetachesAndIsIdempotent()
|
|
{
|
|
var chat = new ChatLog();
|
|
var targets = new ChatCommandTargetState(chat);
|
|
|
|
targets.Dispose();
|
|
targets.Dispose();
|
|
chat.OnTellReceived("After", "ignored", 0x50000002u);
|
|
|
|
Assert.Null(targets.LastIncomingTellSender);
|
|
Assert.Null(targets.LastOutgoingTellTarget);
|
|
}
|
|
}
|