add a test for jobs with setPreference: false (#13182)

This commit is contained in:
Nemanja
2023-01-28 12:39:14 -05:00
committed by GitHub
parent 52c371994d
commit 3d270bbb3e

View File

@@ -5,6 +5,7 @@ using System.Threading.Tasks;
using Content.Server.Maps;
using Content.Server.Station.Systems;
using Content.Shared.Preferences;
using Content.Shared.Roles;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Log;
@@ -188,6 +189,40 @@ public sealed class StationJobsTest
});
await pairTracker.CleanReturnAsync();
}
[Test]
public async Task InvalidRoundstartJobsTest()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
var server = pairTracker.Pair.Server;
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
await server.WaitAssertion(() =>
{
// invalidJobs contains all the jobs which can't be set for preference:
// i.e. all the jobs that shouldn't be available round-start.
var invalidJobs = new HashSet<string>();
foreach (var job in prototypeManager.EnumeratePrototypes<JobPrototype>())
{
if (!job.SetPreference)
invalidJobs.Add(job.ID);
}
foreach (var gameMap in prototypeManager.EnumeratePrototypes<GameMapPrototype>())
{
foreach (var (stationId, station) in gameMap.Stations)
{
foreach (var job in station.AvailableJobs.Keys)
{
Assert.That(invalidJobs.Contains(job), Is.False, $"Station {stationId} contains job prototype {job} which cannot be present roundstart.");
}
}
}
});
await pairTracker.CleanReturnAsync();
}
}
internal static class JobExtensions