Files
tbd-station-14/Content.IntegrationTests/Tests/GameRules/RuleMaxTimeRestartTest.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

67 lines
2.1 KiB
C#

using System;
using System.Threading.Tasks;
using Content.Server.GameTicking;
using Content.Server.GameTicking.GameRules;
using Content.Server.Interfaces.GameTicking;
using NUnit.Framework;
using Robust.Shared.Timing;
namespace Content.IntegrationTests.Tests.GameRules
{
[TestFixture]
[TestOf(typeof(RuleMaxTimeRestart))]
public class RuleMaxTimeRestartTest : ContentIntegrationTest
{
[Test]
public async Task RestartTest()
{
var options = new ServerContentIntegrationOption
{
CVarOverrides =
{
["game.lobbyenabled"] = "true"
}
};
var server = StartServer(options);
await server.WaitIdleAsync();
var sGameTicker = server.ResolveDependency<IGameTicker>();
var sGameTiming = server.ResolveDependency<IGameTiming>();
RuleMaxTimeRestart maxTimeRule = null;
await server.WaitAssertion(() =>
{
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby));
maxTimeRule = sGameTicker.AddGameRule<RuleMaxTimeRestart>();
maxTimeRule.RoundMaxTime = TimeSpan.FromSeconds(3);
sGameTicker.StartRound();
});
await server.WaitAssertion(() =>
{
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.InRound));
});
var ticks = sGameTiming.TickRate * (int) Math.Ceiling(maxTimeRule.RoundMaxTime.TotalSeconds * 1.1f);
await server.WaitRunTicks(ticks);
await server.WaitAssertion(() =>
{
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.PostRound));
});
ticks = sGameTiming.TickRate * (int) Math.Ceiling(maxTimeRule.RoundEndDelay.TotalSeconds * 1.1f);
await server.WaitRunTicks(ticks);
await server.WaitAssertion(() =>
{
Assert.That(sGameTicker.RunLevel, Is.EqualTo(GameRunLevel.PreRoundLobby));
});
}
}
}