acdream/tests/AcDream.Core.Tests/Chat/ChatCommandTargetStateTests.cs
Erik c9d25ade50 refactor(runtime): own communication and social state
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>
2026-07-26 07:50:16 +02:00

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);
}
}