2020-11-18 14:24:13 +01:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using Content.Server.GameTicking;
|
|
|
|
|
|
using Content.Shared.GameTicking;
|
|
|
|
|
|
using NUnit.Framework;
|
2021-02-11 01:13:03 -08:00
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-11-18 14:24:13 +01:00
|
|
|
|
using Robust.Shared.IoC;
|
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-02-16 00:23:23 -07:00
|
|
|
|
public sealed class ResettingEntitySystemTests : ContentIntegrationTest
|
2020-11-18 14:24:13 +01:00
|
|
|
|
{
|
2020-11-25 16:23:51 +01:00
|
|
|
|
[Reflect(false)]
|
2022-02-16 00:23:23 -07:00
|
|
|
|
private 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()
|
|
|
|
|
|
{
|
|
|
|
|
|
var server = StartServer(new ServerContentIntegrationOption
|
|
|
|
|
|
{
|
|
|
|
|
|
ContentBeforeIoC = () =>
|
|
|
|
|
|
{
|
2021-06-29 15:56:07 +02:00
|
|
|
|
IoCManager.Resolve<IEntitySystemManager>().LoadExtraSystemType<TestRoundRestartCleanupEvent>();
|
2020-11-18 14:24:13 +01:00
|
|
|
|
}
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
|
|
Assert.False(system.HasBeenReset);
|
|
|
|
|
|
|
|
|
|
|
|
gameTicker.RestartRound();
|
|
|
|
|
|
|
|
|
|
|
|
Assert.True(system.HasBeenReset);
|
|
|
|
|
|
});
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|