Fix ContentIntegrationTest.WaitUntil not checking if the condition is true afterwards (#2192)

* Fix ContentIntegrationTest.WaitUntil not checking if the condition is true afterwards

And remove TryLoadEntities

* Maybe put the assert last
This commit is contained in:
DrSmugleaf
2020-10-11 13:16:15 +02:00
committed by GitHub
parent 32876c78fe
commit d3d4f7ebe6
2 changed files with 7 additions and 23 deletions

View File

@@ -129,30 +129,12 @@ namespace Content.IntegrationTests
return grid;
}
protected async Task TryLoadEntities(IntegrationInstance instance, params string[] yamls)
{
await instance.WaitIdleAsync();
var prototypeManager = instance.ResolveDependency<IPrototypeManager>();
instance.Post(() =>
{
foreach (var yaml in yamls)
{
using var reader = new StringReader(yaml);
prototypeManager.LoadFromStream(reader);
}
});
await instance.WaitIdleAsync();
}
protected async Task WaitUntil(IntegrationInstance instance, Func<IntegrationInstance, bool> predicate, int tickStep = 10, int maxTicks = 600)
protected async Task WaitUntil(IntegrationInstance instance, Func<bool> func, int tickStep = 10, int maxTicks = 600)
{
var ticksAwaited = 0;
bool passed;
while (!predicate(instance) && ticksAwaited < maxTicks)
while (!(passed = func()) && ticksAwaited < maxTicks)
{
await instance.WaitIdleAsync();
instance.RunTicks(tickStep);
@@ -160,6 +142,8 @@ namespace Content.IntegrationTests
}
await instance.WaitIdleAsync();
Assert.That(passed);
}
private static async Task StartConnectedPairShared(ClientIntegrationInstance client, ServerIntegrationInstance server)

View File

@@ -47,7 +47,7 @@ namespace Content.IntegrationTests.Tests.Doors
await server.WaitIdleAsync();
await WaitUntil(server, _ => airlockComponent.State == DoorState.Open);
await WaitUntil(server, () => airlockComponent.State == DoorState.Open);
Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Open));
@@ -57,7 +57,7 @@ namespace Content.IntegrationTests.Tests.Doors
Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Closing));
});
await WaitUntil(server, _ => airlockComponent.State == DoorState.Closed);
await WaitUntil(server, () => airlockComponent.State == DoorState.Closed);
Assert.That(airlockComponent.State, Is.EqualTo(DoorState.Closed));