-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add localizationTest and improve fallbackTest
- Loading branch information
1 parent
4f5652f
commit f746110
Showing
2 changed files
with
80 additions
and
4 deletions.
There are no files selected for viewing
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
66 changes: 66 additions & 0 deletions
66
Content.IntegrationTests/Tests/Parkstation/Announcers/AnnouncerLocalizationTest.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,66 @@ | ||
using System.Collections.Generic; | ||
using Content.Server.Parkstation.Announcements.Systems; | ||
using Content.Server.StationEvents; | ||
using Content.Shared.Parkstation.Announcements.Prototypes; | ||
using Robust.Shared.GameObjects; | ||
using Robust.Shared.Localization; | ||
|
||
namespace Content.IntegrationTests.Tests.Parkstation.Announcers; | ||
|
||
[TestFixture] | ||
[TestOf(typeof(AnnouncerPrototype))] | ||
public sealed class AnnouncerLocalizationTest | ||
{ | ||
[Test] | ||
public async Task TestEventLocalization() | ||
{ | ||
// Checks if every station event wanting the announcerSystem to send messages has a localization string | ||
// If an event doesn't have startAnnouncement or endAnnouncement set to true | ||
// it will be expected for that system to handle the announcements if it wants them | ||
|
||
await using var pair = await PoolManager.GetServerClient(); | ||
var server = pair.Server; | ||
|
||
var locale = server.ResolveDependency<ILocalizationManager>(); | ||
var entSysMan = server.ResolveDependency<IEntitySystemManager>(); | ||
var announcer = entSysMan.GetEntitySystem<AnnouncerSystem>(); | ||
var events = entSysMan.GetEntitySystem<EventManagerSystem>(); | ||
|
||
await server.WaitAssertion(() => | ||
{ | ||
var succeeded = true; | ||
var why = new List<string>(); | ||
foreach (var ev in events.AllEvents()) | ||
{ | ||
if (ev.Value.StartAnnouncement) | ||
{ | ||
var announcementId = announcer.GetAnnouncementId(ev.Key.ID); | ||
var eventLocaleString = announcer.GetEventLocaleString(announcementId); | ||
if (locale.GetString(eventLocaleString) == eventLocaleString) | ||
{ | ||
succeeded = false; | ||
why.Add($"\"{announcementId}\": \"{eventLocaleString}\""); | ||
} | ||
} | ||
if (ev.Value.EndAnnouncement) | ||
{ | ||
var announcementId = announcer.GetAnnouncementId(ev.Key.ID, true); | ||
var eventLocaleString = announcer.GetEventLocaleString(announcementId); | ||
if (locale.GetString(eventLocaleString) == eventLocaleString) | ||
{ | ||
succeeded = false; | ||
why.Add($"\"{announcementId}\": \"{eventLocaleString}\""); | ||
} | ||
} | ||
} | ||
Assert.That(succeeded, Is.True, $"The following announcements do not have a localization string:\n {string.Join("\n ", why)}"); | ||
}); | ||
|
||
await pair.CleanReturnAsync(); | ||
} | ||
} |