Files
tbd-station-14/Content.IntegrationTests/Tests/StationEvents/StationEventsSystemTest.cs
wrexbe 81e3b2da88 Make tests faster (#8737)
* Test changes

* Make finding the test tile a little smarter
2022-06-19 20:22:28 -07:00

50 lines
1.7 KiB
C#

using System.Threading.Tasks;
using Content.Server.StationEvents;
using Content.Shared.GameTicking;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Timing;
namespace Content.IntegrationTests.Tests.StationEvents
{
[TestFixture]
public sealed class StationEventsSystemTest
{
[Test]
public async Task Test()
{
await using var pairTracker = await PoolManager.GetServerClient();
var server = pairTracker.Pair.Server;
await server.WaitAssertion(() =>
{
// Idle each event
var stationEventsSystem = EntitySystem.Get<StationEventSystem>();
var dummyFrameTime = (float) IoCManager.Resolve<IGameTiming>().TickPeriod.TotalSeconds;
foreach (var stationEvent in stationEventsSystem.StationEvents)
{
stationEvent.Announce();
stationEvent.Update(dummyFrameTime);
stationEvent.Startup();
stationEvent.Update(dummyFrameTime);
stationEvent.Running = false;
stationEvent.Shutdown();
// Due to timings some events might startup twice when in reality they wouldn't.
Assert.That(stationEvent.Occurrences > 0);
}
stationEventsSystem.Reset(new RoundRestartCleanupEvent());
foreach (var stationEvent in stationEventsSystem.StationEvents)
{
Assert.That(stationEvent.Occurrences, Is.EqualTo(0));
}
});
await pairTracker.CleanReturnAsync();
}
}
}