From 0ded865ee72f2736048cf58897f5d67f8297e820 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:32:59 +1100 Subject: [PATCH] Use PoolManager testmap for EntityTest (#21968) --- Content.IntegrationTests/Tests/EntityTest.cs | 43 +++++++++++++------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/Content.IntegrationTests/Tests/EntityTest.cs b/Content.IntegrationTests/Tests/EntityTest.cs index 5414164f27..36a75acc0a 100644 --- a/Content.IntegrationTests/Tests/EntityTest.cs +++ b/Content.IntegrationTests/Tests/EntityTest.cs @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Linq; +using System.Numerics; using Content.Server.Humanoid.Components; using Content.Shared.Coordinates; using Content.Shared.Prototypes; @@ -244,16 +245,11 @@ namespace Content.IntegrationTests.Tests .Select(p => p.ID) .ToList(); - MapCoordinates coords = default; - await server.WaitPost(() => - { - var map = server.MapMan.CreateMap(); - coords = new MapCoordinates(default, map); - }); + var mapId = await pair.CreateTestMap(); + var coords = mapId.MapCoords; await pair.RunTicksSync(3); - List badPrototypes = new(); foreach (var protoId in protoIds) { // TODO fix ninja @@ -270,27 +266,44 @@ namespace Content.IntegrationTests.Tests // If the entity deleted itself, check that it didn't spawn other entities if (!server.EntMan.EntityExists(uid)) { - if (server.EntMan.EntityCount != count || client.EntMan.EntityCount != clientCount) - badPrototypes.Add(protoId); + if (server.EntMan.EntityCount != count) + { + Assert.Fail($"Server prototype {protoId} failed on deleting itself"); + } + + if (client.EntMan.EntityCount != clientCount) + { + Assert.Fail($"Client prototype {protoId} failed on deleting itself"); + } continue; } // Check that the number of entities has increased. - if (server.EntMan.EntityCount <= count || client.EntMan.EntityCount <= clientCount) + if (server.EntMan.EntityCount <= count) { - badPrototypes.Add(protoId); - continue; + Assert.Fail($"Server prototype {protoId} failed on spawning as entity count didn't increase"); + } + + if (client.EntMan.EntityCount <= clientCount) + { + Assert.Fail($"Client prototype {protoId} failed on spawning as entity count didn't increase"); } await server.WaitPost(() => server.EntMan.DeleteEntity(uid)); await pair.RunTicksSync(3); // Check that the number of entities has gone back to the original value. - if (server.EntMan.EntityCount != count || client.EntMan.EntityCount != clientCount) - badPrototypes.Add(protoId); + if (server.EntMan.EntityCount != count) + { + Assert.Fail($"Server prototype {protoId} failed on deletion count didn't reset properly"); + } + + if (client.EntMan.EntityCount != clientCount) + { + Assert.Fail($"Client prototype {protoId} failed on deletion count didn't reset properly"); + } } - Assert.That(badPrototypes, Is.Empty); await pair.CleanReturnAsync(); } -- 2.51.2