2021-01-18 18:14:53 +08:00
|
|
|
|
using System.Threading.Tasks;
|
2021-06-09 22:19:39 +02:00
|
|
|
|
using Content.Server.StationEvents;
|
2021-06-29 15:56:07 +02:00
|
|
|
|
using Content.Shared.GameTicking;
|
2020-08-14 06:52:17 +10:00
|
|
|
|
using NUnit.Framework;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-08-14 06:52:17 +10:00
|
|
|
|
using Robust.Shared.IoC;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.Timing;
|
2020-08-14 06:52:17 +10:00
|
|
|
|
|
|
|
|
|
|
namespace Content.IntegrationTests.Tests.StationEvents
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
public sealed class StationEventsSystemTest : ContentIntegrationTest
|
2020-08-14 06:52:17 +10:00
|
|
|
|
{
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public async Task Test()
|
|
|
|
|
|
{
|
2021-11-06 11:49:59 +01:00
|
|
|
|
var server = StartServer();
|
2020-10-14 23:15:49 +02:00
|
|
|
|
|
2020-08-14 06:52:17 +10:00
|
|
|
|
server.Assert(() =>
|
|
|
|
|
|
{
|
2021-01-18 18:14:53 +08:00
|
|
|
|
// Idle each event
|
2020-08-14 06:52:17 +10:00
|
|
|
|
var stationEventsSystem = EntitySystem.Get<StationEventSystem>();
|
|
|
|
|
|
var dummyFrameTime = (float) IoCManager.Resolve<IGameTiming>().TickPeriod.TotalSeconds;
|
|
|
|
|
|
|
|
|
|
|
|
foreach (var stationEvent in stationEventsSystem.StationEvents)
|
|
|
|
|
|
{
|
2021-01-18 18:14:53 +08:00
|
|
|
|
stationEvent.Announce();
|
|
|
|
|
|
stationEvent.Update(dummyFrameTime);
|
2020-08-14 06:52:17 +10:00
|
|
|
|
stationEvent.Startup();
|
|
|
|
|
|
stationEvent.Update(dummyFrameTime);
|
2021-01-18 18:14:53 +08:00
|
|
|
|
stationEvent.Running = false;
|
2020-08-14 06:52:17 +10:00
|
|
|
|
stationEvent.Shutdown();
|
2021-01-18 18:14:53 +08:00
|
|
|
|
// Due to timings some events might startup twice when in reality they wouldn't.
|
|
|
|
|
|
Assert.That(stationEvent.Occurrences > 0);
|
2020-08-14 06:52:17 +10:00
|
|
|
|
}
|
2020-10-14 23:15:49 +02:00
|
|
|
|
|
2021-06-29 15:56:07 +02:00
|
|
|
|
stationEventsSystem.Reset(new RoundRestartCleanupEvent());
|
2020-08-14 06:52:17 +10:00
|
|
|
|
|
|
|
|
|
|
foreach (var stationEvent in stationEventsSystem.StationEvents)
|
|
|
|
|
|
{
|
2021-01-18 18:14:53 +08:00
|
|
|
|
Assert.That(stationEvent.Occurrences, Is.EqualTo(0));
|
2020-08-14 06:52:17 +10:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2020-10-14 23:15:49 +02:00
|
|
|
|
}
|