2021-02-01 16:49:43 -08:00
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-08-25 15:26:33 +02:00
|
|
|
using Content.Server.GameTicking;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Server.GameTicking.Commands;
|
2020-11-07 01:15:56 +01:00
|
|
|
using Content.Shared;
|
2021-06-13 14:52:40 +02:00
|
|
|
using Content.Shared.CCVar;
|
2020-08-25 15:26:33 +02:00
|
|
|
using NUnit.Framework;
|
2021-02-11 01:13:03 -08:00
|
|
|
using Robust.Shared.Configuration;
|
|
|
|
|
using Robust.Shared.GameObjects;
|
2020-08-25 15:26:33 +02:00
|
|
|
using Robust.Shared.Timing;
|
|
|
|
|
|
|
|
|
|
namespace Content.IntegrationTests.Tests.Commands
|
|
|
|
|
{
|
|
|
|
|
[TestFixture]
|
2021-10-09 13:18:20 -05:00
|
|
|
[TestOf(typeof(RestartRoundNowCommand))]
|
2022-02-16 00:23:23 -07:00
|
|
|
public sealed class RestartRoundNowTest : ContentIntegrationTest
|
2020-08-25 15:26:33 +02:00
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
[TestCase(true)]
|
|
|
|
|
[TestCase(false)]
|
|
|
|
|
public async Task RestartRoundAfterStart(bool lobbyEnabled)
|
|
|
|
|
{
|
2021-07-06 16:41:57 +02:00
|
|
|
var (_, server) = await StartConnectedServerClientPair(serverOptions: new ServerContentIntegrationOption
|
|
|
|
|
{
|
|
|
|
|
CVarOverrides =
|
|
|
|
|
{
|
2021-11-20 12:32:07 -06:00
|
|
|
[CCVars.GameMap.Name] = "saltern"
|
2021-07-06 16:41:57 +02:00
|
|
|
}
|
|
|
|
|
});
|
2020-08-25 15:26:33 +02:00
|
|
|
|
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
|
|
|
|
|
|
var configManager = server.ResolveDependency<IConfigurationManager>();
|
|
|
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
2021-06-20 10:09:24 +02:00
|
|
|
var gameTicker = entityManager.EntitySysManager.GetEntitySystem<GameTicker>();
|
2020-08-25 15:26:33 +02:00
|
|
|
|
|
|
|
|
await server.WaitRunTicks(30);
|
|
|
|
|
|
|
|
|
|
GameTick tickBeforeRestart = default;
|
|
|
|
|
|
|
|
|
|
server.Assert(() =>
|
|
|
|
|
{
|
2020-11-07 01:15:56 +01:00
|
|
|
configManager.SetCVar(CCVars.GameLobbyEnabled, lobbyEnabled);
|
2020-08-25 15:26:33 +02:00
|
|
|
|
|
|
|
|
Assert.That(gameTicker.RunLevel, Is.EqualTo(GameRunLevel.InRound));
|
|
|
|
|
|
|
|
|
|
tickBeforeRestart = entityManager.CurrentTick;
|
|
|
|
|
|
2021-10-09 13:18:20 -05:00
|
|
|
var command = new RestartRoundNowCommand();
|
2021-02-01 16:49:43 -08:00
|
|
|
command.Execute(null, string.Empty, Array.Empty<string>());
|
2020-08-25 15:26:33 +02:00
|
|
|
|
|
|
|
|
if (lobbyEnabled)
|
|
|
|
|
{
|
|
|
|
|
Assert.That(gameTicker.RunLevel, Is.Not.EqualTo(GameRunLevel.InRound));
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
|
await server.WaitRunTicks(5);
|
|
|
|
|
|
|
|
|
|
server.Assert(() =>
|
|
|
|
|
{
|
|
|
|
|
var tickAfterRestart = entityManager.CurrentTick;
|
|
|
|
|
|
|
|
|
|
Assert.That(tickBeforeRestart < tickAfterRestart);
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
await server.WaitRunTicks(60);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|