-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Trait Localization Integration Test (#1408)
- Loading branch information
1 parent
6586b62
commit 0c0ac31
Showing
1 changed file
with
54 additions
and
0 deletions.
There are no files selected for viewing
54 changes: 54 additions & 0 deletions
54
Content.IntegrationTests/Tests/Traits/TraitLocalizationTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using Robust.Shared.Prototypes; | ||
using Robust.Shared.Localization; | ||
using Content.Shared.Traits; | ||
using System.Linq; | ||
using System.Collections.Generic; | ||
|
||
namespace Content.IntegrationTests.Tests.Traits; | ||
|
||
/// <summary> | ||
/// Checks if every trait has a valid desc and name localization string. | ||
/// </summary> | ||
[TestFixture] | ||
[TestOf(typeof(TraitPrototype))] | ||
public sealed class TraitLocalizationTest | ||
{ | ||
|
||
[Test] | ||
public async Task TestTraitLocalization() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(); | ||
var server = pair.Server; | ||
|
||
var locale = server.ResolveDependency<ILocalizationManager>(); | ||
var proto = server.ResolveDependency<IPrototypeManager>(); | ||
|
||
await server.WaitAssertion(() => | ||
{ | ||
var passed = true; | ||
var missingStrings = new List<string>(); | ||
|
||
foreach (var traitProto in proto.EnumeratePrototypes<TraitPrototype>().OrderBy(a => a.ID)) | ||
{ | ||
var name = "trait-name-" + traitProto.ID; | ||
var desc = "trait-description-" + traitProto.ID; | ||
|
||
if (!locale.HasString(name)) | ||
{ | ||
missingStrings.Add($"\"{traitProto.ID}\", \"{name}\""); | ||
passed = false; | ||
} | ||
if (!locale.HasString(desc)) | ||
{ | ||
missingStrings.Add($"\"{traitProto.ID}\", \"{desc}\""); | ||
passed = false; | ||
} | ||
} | ||
|
||
Assert.That(passed, Is.True, $"The following traits are missing localization strings:\n {string.Join("\n ", missingStrings)}"); | ||
}); | ||
|
||
await pair.CleanReturnAsync(); | ||
} | ||
} | ||
|