Change WaitUntil tickstep default to 1, fix going over the max, better async and fix rejuvenate test not being async (#2439)
This commit is contained in:
@@ -129,19 +129,26 @@ namespace Content.IntegrationTests
|
|||||||
return grid;
|
return grid;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected async Task WaitUntil(IntegrationInstance instance, Func<bool> func, int tickStep = 10, int maxTicks = 600)
|
protected async Task WaitUntil(IntegrationInstance instance, Func<bool> func, int maxTicks = 600, int tickStep = 1)
|
||||||
{
|
{
|
||||||
var ticksAwaited = 0;
|
var ticksAwaited = 0;
|
||||||
bool passed;
|
bool passed;
|
||||||
|
|
||||||
|
await instance.WaitIdleAsync();
|
||||||
|
|
||||||
while (!(passed = func()) && ticksAwaited < maxTicks)
|
while (!(passed = func()) && ticksAwaited < maxTicks)
|
||||||
{
|
{
|
||||||
await instance.WaitIdleAsync();
|
var ticksToRun = tickStep;
|
||||||
instance.RunTicks(tickStep);
|
|
||||||
ticksAwaited += tickStep;
|
|
||||||
}
|
|
||||||
|
|
||||||
await instance.WaitIdleAsync();
|
if (ticksAwaited + tickStep > maxTicks)
|
||||||
|
{
|
||||||
|
ticksToRun = maxTicks - ticksAwaited;
|
||||||
|
}
|
||||||
|
|
||||||
|
await instance.WaitRunTicks(ticksToRun);
|
||||||
|
|
||||||
|
ticksAwaited += ticksToRun;
|
||||||
|
}
|
||||||
|
|
||||||
Assert.That(passed);
|
Assert.That(passed);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using Content.Server.GlobalVerbs;
|
using System.Threading.Tasks;
|
||||||
|
using Content.Server.GlobalVerbs;
|
||||||
using Content.Shared.Damage;
|
using Content.Shared.Damage;
|
||||||
using Content.Shared.GameObjects.Components.Damage;
|
using Content.Shared.GameObjects.Components.Damage;
|
||||||
using NUnit.Framework;
|
using NUnit.Framework;
|
||||||
@@ -14,14 +15,11 @@ namespace Content.IntegrationTests.Tests.Commands
|
|||||||
public class RejuvenateTest : ContentIntegrationTest
|
public class RejuvenateTest : ContentIntegrationTest
|
||||||
{
|
{
|
||||||
[Test]
|
[Test]
|
||||||
public void RejuvenateDeadTest()
|
public async Task RejuvenateDeadTest()
|
||||||
{
|
{
|
||||||
var server = StartServerDummyTicker();
|
var server = StartServerDummyTicker();
|
||||||
|
|
||||||
IEntity human = null;
|
await server.WaitAssertion(() =>
|
||||||
IDamageableComponent damageable = null;
|
|
||||||
|
|
||||||
server.Assert(() =>
|
|
||||||
{
|
{
|
||||||
var mapManager = IoCManager.Resolve<IMapManager>();
|
var mapManager = IoCManager.Resolve<IMapManager>();
|
||||||
|
|
||||||
@@ -29,10 +27,10 @@ namespace Content.IntegrationTests.Tests.Commands
|
|||||||
|
|
||||||
var entityManager = IoCManager.Resolve<IEntityManager>();
|
var entityManager = IoCManager.Resolve<IEntityManager>();
|
||||||
|
|
||||||
human = entityManager.SpawnEntity("HumanMob_Content", MapCoordinates.Nullspace);
|
var human = entityManager.SpawnEntity("HumanMob_Content", MapCoordinates.Nullspace);
|
||||||
|
|
||||||
// Sanity check
|
// Sanity check
|
||||||
Assert.True(human.TryGetComponent(out damageable));
|
Assert.True(human.TryGetComponent(out IDamageableComponent damageable));
|
||||||
Assert.That(damageable.CurrentState, Is.EqualTo(DamageState.Alive));
|
Assert.That(damageable.CurrentState, Is.EqualTo(DamageState.Alive));
|
||||||
|
|
||||||
// Kill the entity
|
// Kill the entity
|
||||||
|
|||||||
Reference in New Issue
Block a user