Toolshed refactor (#33598)
* Content changes for engine toolshed PR * add contains command * more permissive commands
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using Robust.Shared.IoC;
|
||||
using System.Reflection;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Toolshed;
|
||||
|
||||
@@ -14,10 +14,27 @@ public sealed class LocTest : ToolshedTest
|
||||
[Test]
|
||||
public async Task AllCommandsHaveDescriptions()
|
||||
{
|
||||
var locMan = Server.ResolveDependency<ILocalizationManager>();
|
||||
var toolMan = Server.ResolveDependency<ToolshedManager>();
|
||||
var locStrings = new HashSet<string>();
|
||||
|
||||
var ignored = new HashSet<Assembly>()
|
||||
{typeof(LocTest).Assembly, typeof(Robust.UnitTesting.Shared.Toolshed.LocTest).Assembly};
|
||||
|
||||
await Server.WaitAssertion(() =>
|
||||
{
|
||||
Assert.That(InvokeCommand("cmd:list where { cmd:descloc loc:tryloc isnull }", out var res));
|
||||
Assert.That((IEnumerable<CommandSpec>)res!, Is.Empty, "All commands must have localized descriptions.");
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
foreach (var cmd in toolMan.DefaultEnvironment.AllCommands())
|
||||
{
|
||||
if (ignored.Contains(cmd.Cmd.GetType().Assembly))
|
||||
continue;
|
||||
|
||||
var descLoc = cmd.DescLocStr();
|
||||
Assert.That(locStrings.Add(descLoc), $"Duplicate command description key: {descLoc}");
|
||||
Assert.That(locMan.TryGetString(descLoc, out _), $"Failed to get command description for command {cmd.FullName()}");
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user