Make ClickableTest go brrt (#3792)

This commit is contained in:
metalgearsloth
2021-04-02 21:10:06 +11:00
committed by GitHub
parent f7aba5f701
commit 52736bbd9e

View File

@@ -12,12 +12,21 @@ namespace Content.IntegrationTests.Tests
[TestFixture] [TestFixture]
public sealed class ClickableTest : ContentIntegrationTest public sealed class ClickableTest : ContentIntegrationTest
{ {
private ClientIntegrationInstance _client;
private ServerIntegrationInstance _server;
private const double DirSouth = 0; private const double DirSouth = 0;
private const double DirNorth = Math.PI; private const double DirNorth = Math.PI;
private const double DirEast = Math.PI / 2; private const double DirEast = Math.PI / 2;
private const double DirSouthEast = Math.PI / 4; private const double DirSouthEast = Math.PI / 4;
private const double DirSouthEastJustShy = Math.PI / 4 - 0.1; private const double DirSouthEastJustShy = Math.PI / 4 - 0.1;
[OneTimeSetUp]
public async Task Setup()
{
(_client, _server) = await StartConnectedServerClientPair();
}
[Parallelizable(ParallelScope.None)] [Parallelizable(ParallelScope.None)]
[Test] [Test]
[TestCase("ClickTestRotatingCornerVisible", 0.25f, 0.25f, DirSouth, 1, ExpectedResult = true)] [TestCase("ClickTestRotatingCornerVisible", 0.25f, 0.25f, DirSouth, 1, ExpectedResult = true)]
@@ -48,11 +57,9 @@ namespace Content.IntegrationTests.Tests
[TestCase("ClickTestRotatingCornerInvisibleNoRot", 0.25f, 0.25f, DirSouthEastJustShy, 1, ExpectedResult = true)] [TestCase("ClickTestRotatingCornerInvisibleNoRot", 0.25f, 0.25f, DirSouthEastJustShy, 1, ExpectedResult = true)]
public async Task<bool> Test(string prototype, float clickPosX, float clickPosY, double angle, float scale) public async Task<bool> Test(string prototype, float clickPosX, float clickPosY, double angle, float scale)
{ {
var (client, server) = await StartConnectedServerClientPair();
EntityUid entity = default; EntityUid entity = default;
await server.WaitPost(() => await _server.WaitPost(() =>
{ {
var entMgr = IoCManager.Resolve<IEntityManager>(); var entMgr = IoCManager.Resolve<IEntityManager>();
var ent = entMgr.SpawnEntity(prototype, new MapCoordinates(0, 0, new MapId(1))); var ent = entMgr.SpawnEntity(prototype, new MapCoordinates(0, 0, new MapId(1)));
@@ -62,11 +69,11 @@ namespace Content.IntegrationTests.Tests
}); });
// Let client sync up. // Let client sync up.
await RunTicksSync(client, server, 5); await RunTicksSync(_client, _server, 5);
var hit = false; var hit = false;
await client.WaitPost(() => await _client.WaitPost(() =>
{ {
var entMgr = IoCManager.Resolve<IEntityManager>(); var entMgr = IoCManager.Resolve<IEntityManager>();
var ent = entMgr.GetEntity(entity); var ent = entMgr.GetEntity(entity);
@@ -75,6 +82,12 @@ namespace Content.IntegrationTests.Tests
hit = clickable.CheckClick((clickPosX, clickPosY), out _, out _); hit = clickable.CheckClick((clickPosX, clickPosY), out _, out _);
}); });
await _server.WaitPost(() =>
{
var entMgr = IoCManager.Resolve<IEntityManager>();
entMgr.DeleteEntity(entity);
});
return hit; return hit;
} }
} }