Snapshot for release 2026.10.28.3 (internal 7496938)
This commit is contained in:
parent
c68e251cd6
commit
f9db7bad87
24 changed files with 583 additions and 98 deletions
|
|
@ -19,6 +19,7 @@ internal static class Program
|
|||
VaultTests.Register(runner);
|
||||
QuestPackTests.Register(runner);
|
||||
LevistrasTests.Register(runner);
|
||||
ServerPackCommandsTests.Register(runner);
|
||||
return runner.Run("RynthServerPack tests", args.Length > 0 ? args[0] : null);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -29,6 +29,9 @@
|
|||
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackPages.cs" Link="Plugin\ServerPackPages.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackSettings.cs" Link="Plugin\ServerPackSettings.cs" />
|
||||
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerChatRequest.cs" Link="Plugin\ServerChatRequest.cs" />
|
||||
<!-- "/rserver" words and answers (2026-10-28) and the shared reply queue. -->
|
||||
<Compile Include="..\..\Plugins\Shared\ServerPack\ServerPackCommands.cs" Link="Plugin\ServerPackCommands.cs" />
|
||||
<Compile Include="$(RynthSuiteRoot)Plugins\Shared\CommandReply.cs" Link="Shared\CommandReply.cs" />
|
||||
<!-- RynthConquest's own features (pure parts) and the RynthOracle sources it links. -->
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthConquest\Conquest\ConquestData.cs" Link="Conquest\ConquestData.cs" />
|
||||
<Compile Include="..\..\Plugins\RynthCore.Plugin.RynthConquest\Conquest\ConquestFeature.cs" Link="Conquest\ConquestFeature.cs" />
|
||||
|
|
|
|||
67
Tools/RynthServerPack.Tests/ServerPackCommandsTests.cs
Normal file
67
Tools/RynthServerPack.Tests/ServerPackCommandsTests.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using RynthCore.Plugin.ServerPack;
|
||||
using RynthCore.Plugin.Shared;
|
||||
using RynthCore.RynthAiTests.Harness;
|
||||
|
||||
namespace RynthServerPack.Tests;
|
||||
|
||||
// Every "/rserver" command answers in chat (2026-10-28). RunCommand needs the plugin's host, so the words
|
||||
// (shared and a server's own, as RynthAelrynth's "vault"), the verb each one is, and the lines are checked
|
||||
// here, plus the shared reply queue the server plugins write through.
|
||||
internal static class ServerPackCommandsTests
|
||||
{
|
||||
public static void Register(Runner r)
|
||||
{
|
||||
r.Add("rserver: every word is a verb or a server id, typed right and wrong", Words);
|
||||
r.Add("rserver: the window, usage and unknown-word lines", Lines);
|
||||
r.Add("rserver: replies go through the shared queue, tagged with the plugin's name", Queue);
|
||||
}
|
||||
|
||||
private static readonly HashSet<string> Vault = new(StringComparer.OrdinalIgnoreCase) { "vault" };
|
||||
|
||||
private static void Words()
|
||||
{
|
||||
var table = new (string Line, ServerVerb Verb)[]
|
||||
{
|
||||
("/rserver", ServerVerb.Toggle), ("/rserver show", ServerVerb.Show), ("/rserver HIDE", ServerVerb.Hide),
|
||||
("/rserver toggle", ServerVerb.Toggle), ("/rserver info", ServerVerb.Info), ("/rserver help", ServerVerb.Help),
|
||||
("/rserver auto", ServerVerb.Auto), ("/rserver on", ServerVerb.On), ("/rserver off", ServerVerb.Off),
|
||||
("/rserver vault", ServerVerb.Server), ("/rserver wobble", ServerVerb.Unknown),
|
||||
};
|
||||
var seen = new HashSet<ServerVerb>();
|
||||
foreach (var (line, verb) in table)
|
||||
{
|
||||
ServerVerb got = ServerPackCommands.Verb(line.Split(' ', StringSplitOptions.RemoveEmptyEntries), Vault);
|
||||
Check.Eq(got, verb, $"'{line}'");
|
||||
seen.Add(got);
|
||||
}
|
||||
foreach (ServerVerb v in Enum.GetValues<ServerVerb>()) Check.True(seen.Contains(v), $"the table covers /rserver's {v}");
|
||||
Check.True(ServerPackCommands.IsVerb("Info", Vault) && ServerPackCommands.IsVerb("vault", Vault), "shared and own verbs");
|
||||
Check.False(ServerPackCommands.IsVerb("coldeve", Vault), "a server id isn't a verb (\"/rserver coldeve info\")");
|
||||
Check.Eq(ServerPackCommands.Verb(new[] { "/rserver", "vault" }, new HashSet<string>()), ServerVerb.Unknown, "another server's own verb is unknown here");
|
||||
}
|
||||
|
||||
private static void Lines()
|
||||
{
|
||||
Check.Eq(ServerPackCommands.Window("Coldeve", true), "The Coldeve window shown.", "show");
|
||||
Check.Eq(ServerPackCommands.Window("Coldeve", false), "The Coldeve window hidden.", "hide");
|
||||
string[] usage = ServerPackCommands.Usage("Coldeve");
|
||||
Check.Eq(usage.Length, 2, "two usage lines");
|
||||
Check.True(usage[0].Contains("/rserver [show|hide|toggle]") && usage[1].Contains("/rserver auto|on|off"), "the usage names every verb");
|
||||
Check.Eq(ServerPackCommands.Unknown("wobble"), "Unknown '/rserver wobble'.", "an unknown word");
|
||||
}
|
||||
|
||||
private static void Queue()
|
||||
{
|
||||
var chat = new List<(string, int)>();
|
||||
var r = new CommandReply("[RynthColdeve]", (t, c) => { chat.Add((t, c)); return true; });
|
||||
r.Ok(ServerPackCommands.Window("Coldeve", true));
|
||||
r.Fail("[RynthAelrynth] The account vault is Aelrynth's; RynthCore doesn't see this world as Aelrynth.");
|
||||
while (r.Flush()) { }
|
||||
Check.Eq(chat.Count, 2, "both lines written");
|
||||
Check.Eq(chat[0], ("[RynthColdeve] The Coldeve window shown.", CommandReply.OkChatType), "untagged: the plugin's tag, the ok colour");
|
||||
Check.Eq(chat[1].Item2, CommandReply.FailChatType, "a refusal: the failure colour");
|
||||
Check.True(chat[1].Item1.StartsWith("[RynthAelrynth] ", StringComparison.Ordinal), "a line with its own tag keeps it");
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue