2021-02-01 16:49:43 -08:00
|
|
|
using System;
|
|
|
|
|
using System.Threading.Tasks;
|
2020-12-03 03:40:47 +01:00
|
|
|
using Content.Server.Commands.GameTicking;
|
2020-08-25 15:26:33 +02:00
|
|
|
using Content.Server.GameTicking;
|
|
|
|
|
using Content.Server.Interfaces.GameTicking;
|
2020-11-07 01:15:56 +01:00
|
|
|
using Content.Shared;
|
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]
|
|
|
|
|
[TestOf(typeof(NewRoundCommand))]
|
|
|
|
|
public class RestartRoundTest : ContentIntegrationTest
|
|
|
|
|
{
|
|
|
|
|
[Test]
|
|
|
|
|
[TestCase(true)]
|
|
|
|
|
[TestCase(false)]
|
|
|
|
|
public async Task RestartRoundAfterStart(bool lobbyEnabled)
|
|
|
|
|
{
|
2020-12-03 01:52:34 +01:00
|
|
|
var (_, server) = await StartConnectedServerClientPair();
|
2020-08-25 15:26:33 +02:00
|
|
|
|
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
|
|
|
|
|
|
var gameTicker = server.ResolveDependency<IGameTicker>();
|
|
|
|
|
var configManager = server.ResolveDependency<IConfigurationManager>();
|
|
|
|
|
var entityManager = server.ResolveDependency<IEntityManager>();
|
|
|
|
|
|
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
var command = new NewRoundCommand();
|
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);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|