2023-07-05 21:54:25 -07:00
|
|
|
|
using Content.Server.GameTicking;
|
2020-11-18 14:24:13 +01:00
|
|
|
|
using Content.Shared.GameTicking;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-11-25 16:23:51 +01:00
|
|
|
|
using Robust.Shared.Reflection;
|
2020-11-18 14:24:13 +01:00
|
|
|
|
|
|
|
|
|
|
namespace Content.IntegrationTests.Tests
|
|
|
|
|
|
{
|
|
|
|
|
|
[TestFixture]
|
2021-06-29 15:56:07 +02:00
|
|
|
|
[TestOf(typeof(RoundRestartCleanupEvent))]
|
2022-06-19 20:22:28 -07:00
|
|
|
|
public sealed class ResettingEntitySystemTests
|
2020-11-18 14:24:13 +01:00
|
|
|
|
{
|
2022-06-19 20:22:28 -07:00
|
|
|
|
public sealed class TestRoundRestartCleanupEvent : EntitySystem
|
2020-11-18 14:24:13 +01:00
|
|
|
|
{
|
|
|
|
|
|
public bool HasBeenReset { get; set; }
|
|
|
|
|
|
|
2021-06-29 15:56:07 +02:00
|
|
|
|
public override void Initialize()
|
|
|
|
|
|
{
|
|
|
|
|
|
base.Initialize();
|
|
|
|
|
|
|
|
|
|
|
|
SubscribeLocalEvent<RoundRestartCleanupEvent>(Reset);
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void Reset(RoundRestartCleanupEvent ev)
|
2020-11-18 14:24:13 +01:00
|
|
|
|
{
|
|
|
|
|
|
HasBeenReset = true;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Test]
|
|
|
|
|
|
public async Task ResettingEntitySystemResetTest()
|
|
|
|
|
|
{
|
2023-08-25 02:56:51 +02:00
|
|
|
|
await using var pair = await PoolManager.GetServerClient(new PoolSettings
|
2023-08-06 14:30:28 +12:00
|
|
|
|
{
|
|
|
|
|
|
DummyTicker = false,
|
2023-11-01 19:56:07 -07:00
|
|
|
|
Connected = true,
|
|
|
|
|
|
Dirty = true
|
2023-08-06 14:30:28 +12:00
|
|
|
|
});
|
2023-08-25 02:56:51 +02:00
|
|
|
|
var server = pair.Server;
|
2020-11-18 14:24:13 +01:00
|
|
|
|
|
|
|
|
|
|
var entitySystemManager = server.ResolveDependency<IEntitySystemManager>();
|
2021-06-20 10:09:24 +02:00
|
|
|
|
var gameTicker = entitySystemManager.GetEntitySystem<GameTicker>();
|
2020-11-18 14:24:13 +01:00
|
|
|
|
|
|
|
|
|
|
await server.WaitAssertion(() =>
|
|
|
|
|
|
{
|
|
|
|
|
|
Assert.That(gameTicker.RunLevel, Is.EqualTo(GameRunLevel.InRound));
|
|
|
|
|
|
|
2021-06-29 15:56:07 +02:00
|
|
|
|
var system = entitySystemManager.GetEntitySystem<TestRoundRestartCleanupEvent>();
|
2020-11-18 14:24:13 +01:00
|
|
|
|
|
|
|
|
|
|
system.HasBeenReset = false;
|
|
|
|
|
|
|
|
|
|
|
|
gameTicker.RestartRound();
|
|
|
|
|
|
|
2023-07-05 21:54:25 -07:00
|
|
|
|
Assert.That(system.HasBeenReset);
|
2020-11-18 14:24:13 +01:00
|
|
|
|
});
|
2023-08-25 02:56:51 +02:00
|
|
|
|
await pair.CleanReturnAsync();
|
2020-11-18 14:24:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|