Probably fix roundend test in debug (#9193)

This commit is contained in:
metalgearsloth
2022-06-27 01:38:40 +10:00
committed by GitHub
parent 34aabc97c3
commit 0d5291ff89

View File

@@ -17,19 +17,26 @@ namespace Content.IntegrationTests.Tests
[Test] [Test]
public async Task Test() public async Task Test()
{ {
await using var pairTracker = await PoolManager.GetServerClient(); await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings()
{
NoClient = true,
});
var server = pairTracker.Pair.Server; var server = pairTracker.Pair.Server;
var config = server.ResolveDependency<IConfigurationManager>();
var sysManager = server.ResolveDependency<IEntitySystemManager>();
var ticker = sysManager.GetEntitySystem<GameTicker>();
var roundEndSystem = sysManager.GetEntitySystem<RoundEndSystem>();
var eventCount = 0; var eventCount = 0;
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var ticker = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<GameTicker>();
ticker.RestartRound(); ticker.RestartRound();
var config = IoCManager.Resolve<IConfigurationManager>();
config.SetCVar(CCVars.GameLobbyEnabled, true); config.SetCVar(CCVars.GameLobbyEnabled, true);
config.SetCVar(CCVars.EmergencyShuttleTransitTime, 1f);
config.SetCVar(CCVars.EmergencyShuttleDockTime, 1f);
var roundEndSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<RoundEndSystem>();
roundEndSystem.DefaultCooldownDuration = TimeSpan.FromMilliseconds(250); roundEndSystem.DefaultCooldownDuration = TimeSpan.FromMilliseconds(250);
roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMilliseconds(500); roundEndSystem.DefaultCountdownDuration = TimeSpan.FromMilliseconds(500);
roundEndSystem.DefaultRestartRoundDuration = TimeSpan.FromMilliseconds(250); roundEndSystem.DefaultRestartRoundDuration = TimeSpan.FromMilliseconds(250);
@@ -41,7 +48,7 @@ namespace Content.IntegrationTests.Tests
bus.SubscribeEvent<RoundEndSystemChangedEvent>(EventSource.Local, this, _ => { bus.SubscribeEvent<RoundEndSystemChangedEvent>(EventSource.Local, this, _ => {
Interlocked.Increment(ref eventCount); Interlocked.Increment(ref eventCount);
}); });
var roundEndSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<RoundEndSystem>();
// Press the shuttle call button // Press the shuttle call button
roundEndSystem.RequestRoundEnd(); roundEndSystem.RequestRoundEnd();
Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "Shuttle was called, but countdown time was not set"); Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "Shuttle was called, but countdown time was not set");
@@ -55,8 +62,6 @@ namespace Content.IntegrationTests.Tests
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var roundEndSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<RoundEndSystem>();
Assert.That(roundEndSystem.CanCall(), Is.True, "We waited a while, but the cooldown is not expired"); Assert.That(roundEndSystem.CanCall(), Is.True, "We waited a while, but the cooldown is not expired");
Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "We were waiting for the cooldown, but the round also ended"); Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "We were waiting for the cooldown, but the round also ended");
// Recall the shuttle, which should trigger the cooldown again // Recall the shuttle, which should trigger the cooldown again
@@ -69,7 +74,6 @@ namespace Content.IntegrationTests.Tests
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var roundEndSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<RoundEndSystem>();
Assert.That(roundEndSystem.CanCall(), Is.True, "We waited a while, but the cooldown is not expired"); Assert.That(roundEndSystem.CanCall(), Is.True, "We waited a while, but the cooldown is not expired");
// Press the shuttle call button // Press the shuttle call button
roundEndSystem.RequestRoundEnd(); roundEndSystem.RequestRoundEnd();
@@ -79,7 +83,6 @@ namespace Content.IntegrationTests.Tests
await server.WaitAssertion(() => await server.WaitAssertion(() =>
{ {
var roundEndSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<RoundEndSystem>();
Assert.That(roundEndSystem.CanCall(), Is.True, "We waited a while, but the cooldown is not expired"); Assert.That(roundEndSystem.CanCall(), Is.True, "We waited a while, but the cooldown is not expired");
Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "The countdown ended, but we just wanted the cooldown to end"); Assert.That(roundEndSystem.ExpectedCountdownEnd, Is.Not.Null, "The countdown ended, but we just wanted the cooldown to end");
}); });
@@ -96,14 +99,13 @@ namespace Content.IntegrationTests.Tests
{ {
return server.WaitAssertion(() => return server.WaitAssertion(() =>
{ {
var ticker = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<GameTicker>();
Assert.That(ticker.RunLevel, Is.EqualTo(level)); Assert.That(ticker.RunLevel, Is.EqualTo(level));
}); });
} }
async Task WaitForEvent() async Task WaitForEvent()
{ {
var timeout = Task.Delay(TimeSpan.FromSeconds(60)); var timeout = Task.Delay(TimeSpan.FromSeconds(10));
var currentCount = Thread.VolatileRead(ref eventCount); var currentCount = Thread.VolatileRead(ref eventCount);
while (currentCount == Thread.VolatileRead(ref eventCount) && !timeout.IsCompleted) while (currentCount == Thread.VolatileRead(ref eventCount) && !timeout.IsCompleted)
{ {