1
0

LocTest.cs 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. using System.Collections.Generic;
  2. using System.Globalization;
  3. using System.Reflection;
  4. using Robust.Shared.Localization;
  5. using Robust.Shared.Toolshed;
  6. namespace Content.IntegrationTests.Tests.Toolshed;
  7. // this is an EXACT DUPLICATE of LocTest from robust. If you modify this, modify that too.
  8. // Anyone who fails to heed these instructions consents to being scrungled to death.
  9. [TestFixture]
  10. public sealed class LocTest : ToolshedTest
  11. {
  12. [Test]
  13. public async Task AllCommandsHaveDescriptions()
  14. {
  15. var locMan = Server.ResolveDependency<ILocalizationManager>();
  16. var toolMan = Server.ResolveDependency<ToolshedManager>();
  17. var locStrings = new HashSet<string>();
  18. var ignored = new HashSet<Assembly>()
  19. {typeof(LocTest).Assembly, typeof(Robust.UnitTesting.Shared.Toolshed.LocTest).Assembly};
  20. await Server.WaitAssertion(() =>
  21. {
  22. Assert.Multiple(() =>
  23. {
  24. foreach (var cmd in toolMan.DefaultEnvironment.AllCommands())
  25. {
  26. if (ignored.Contains(cmd.Cmd.GetType().Assembly))
  27. continue;
  28. var descLoc = cmd.DescLocStr();
  29. Assert.That(locStrings.Add(descLoc), $"Duplicate command description key: {descLoc}");
  30. Assert.That(locMan.TryGetString(descLoc, out _), $"Failed to get command description for command {cmd.FullName()}");
  31. }
  32. });
  33. });
  34. }
  35. }