feat(mosstank): add VTank-style automation PoC
This commit is contained in:
parent
f6fe0f2a4f
commit
4e6e9bc9d9
212 changed files with 49462 additions and 416 deletions
|
|
@ -7,6 +7,23 @@ namespace AcDream.UI.Abstractions.Tests.Panels.Chat;
|
|||
|
||||
public class ChatCommandRouterTests
|
||||
{
|
||||
[Fact]
|
||||
public void PluginCommand_IsHandledBeforeUnknownServerFallback()
|
||||
{
|
||||
var (vm, _, inner) = Fixture();
|
||||
var bus = new PluginCommandBus(inner);
|
||||
|
||||
SubmitOutcome outcome = ChatCommandRouter.Submit(
|
||||
"/vt start",
|
||||
vm,
|
||||
bus,
|
||||
ChatChannelKind.Say);
|
||||
|
||||
Assert.Equal(SubmitOutcome.ClientHandled, outcome);
|
||||
Assert.Equal("/vt start", bus.Handled);
|
||||
Assert.Empty(inner.Published);
|
||||
}
|
||||
|
||||
private sealed class CaptureBus : ICommandBus
|
||||
{
|
||||
public List<object> Published { get; } = new();
|
||||
|
|
@ -15,6 +32,21 @@ public class ChatCommandRouterTests
|
|||
=> Published.Add(command);
|
||||
}
|
||||
|
||||
private sealed class PluginCommandBus(CaptureBus inner)
|
||||
: IPluginCommandBus
|
||||
{
|
||||
public string? Handled { get; private set; }
|
||||
|
||||
public bool TryHandlePluginCommand(string commandLine)
|
||||
{
|
||||
Handled = commandLine;
|
||||
return true;
|
||||
}
|
||||
|
||||
public void Publish<T>(T command) where T : notnull =>
|
||||
inner.Publish(command);
|
||||
}
|
||||
|
||||
private static (ChatVM vm, ChatLog log, CaptureBus bus) Fixture()
|
||||
{
|
||||
var log = new ChatLog();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue