]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add integration test for LocalizedDatasets (#28485)
authorTayrtahn <tayrtahn@gmail.com>
Mon, 3 Jun 2024 19:40:46 +0000 (15:40 -0400)
committerGitHub <noreply@github.com>
Mon, 3 Jun 2024 19:40:46 +0000 (15:40 -0400)
Content.IntegrationTests/Tests/Localization/LocalizedDatasetPrototypeTest.cs [new file with mode: 0644]

diff --git a/Content.IntegrationTests/Tests/Localization/LocalizedDatasetPrototypeTest.cs b/Content.IntegrationTests/Tests/Localization/LocalizedDatasetPrototypeTest.cs
new file mode 100644 (file)
index 0000000..b30c0a3
--- /dev/null
@@ -0,0 +1,35 @@
+using System.Linq;
+using Content.Shared.Dataset;
+using Robust.Shared.Localization;
+using Robust.Shared.Prototypes;
+
+namespace Content.IntegrationTests.Tests.Localization;
+
+[TestFixture]
+public sealed class LocalizedDatasetPrototypeTest
+{
+    [Test]
+    public async Task ValidProtoIdsTest()
+    {
+        await using var pair = await PoolManager.GetServerClient();
+
+        var server = pair.Server;
+        var protoMan = server.ResolveDependency<IPrototypeManager>();
+        var localizationMan = server.ResolveDependency<ILocalizationManager>();
+
+        var protos = protoMan.EnumeratePrototypes<LocalizedDatasetPrototype>().OrderBy(p => p.ID);
+
+        // Check each prototype
+        foreach (var proto in protos)
+        {
+            // Check each value in the prototype
+            foreach (var locId in proto.Values)
+            {
+                // Make sure the localization manager has a string for the LocId
+                Assert.That(localizationMan.HasString(locId), $"LocalizedDataset {proto.ID} with prefix \"{proto.Values.Prefix}\" specifies {proto.Values.Count} entries, but no localized string was found matching {locId}!");
+            }
+        }
+
+        await pair.CleanReturnAsync();
+    }
+}