Fix content.integration tests warnings (#17817)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
TemporalOroboros
2023-07-05 21:54:25 -07:00
committed by GitHub
parent 20c1754abd
commit ba91023a85
121 changed files with 3658 additions and 1961 deletions

View File

@@ -1,16 +1,16 @@
using System.Threading.Tasks;
using Content.Server.Atmos.Components;
using Content.Server.Atmos.EntitySystems;
using Content.Server.Body.Components;
using Content.Server.Body.Systems;
using Content.Shared.Body.Components;
using NUnit.Framework;
using Robust.Server.GameObjects;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Maths;
using System.Linq;
namespace Content.IntegrationTests.Tests.Body
{
@@ -52,7 +52,10 @@ namespace Content.IntegrationTests.Tests.Body
{
// --- Setup
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{NoClient = true, ExtraPrototypes = Prototypes});
{
NoClient = true,
ExtraPrototypes = Prototypes
});
var server = pairTracker.Pair.Server;
await server.WaitIdleAsync();
@@ -68,17 +71,22 @@ namespace Content.IntegrationTests.Tests.Body
BodyComponent body = default;
EntityUid human = default;
GridAtmosphereComponent relevantAtmos = default;
float startingMoles = 0.0f;
var startingMoles = 0.0f;
var testMapName = "Maps/Test/Breathing/3by3-20oxy-80nit.yml";
await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
grid = mapLoader.LoadGrid(mapId, testMapName);
Assert.That(mapLoader.TryLoad(mapId, testMapName, out var roots));
var query = entityManager.GetEntityQuery<MapGridComponent>();
var grids = roots.Where(x => query.HasComponent(x));
Assert.That(grids, Is.Not.Empty);
grid = grids.First();
});
Assert.NotNull(grid, $"Test blueprint {testMapName} not found.");
Assert.That(grid, Is.Not.Null, $"Test blueprint {testMapName} not found.");
float GetMapMoles()
{
@@ -96,13 +104,15 @@ namespace Content.IntegrationTests.Tests.Body
var coords = new Vector2(0.5f, -1f);
var coordinates = new EntityCoordinates(grid.Value, coords);
human = entityManager.SpawnEntity("HumanBodyDummy", coordinates);
respSys = EntitySystem.Get<RespiratorSystem>();
metaSys = EntitySystem.Get<MetabolizerSystem>();
respSys = entityManager.System<RespiratorSystem>();
metaSys = entityManager.System<MetabolizerSystem>();
relevantAtmos = entityManager.GetComponent<GridAtmosphereComponent>(grid.Value);
startingMoles = GetMapMoles();
Assert.True(entityManager.TryGetComponent(human, out body));
Assert.True(entityManager.HasComponent<RespiratorComponent>(human));
#pragma warning disable NUnit2045
Assert.That(entityManager.TryGetComponent(human, out body), Is.True);
Assert.That(entityManager.HasComponent<RespiratorComponent>(human), Is.True);
#pragma warning restore NUnit2045
});
// --- End setup
@@ -131,7 +141,10 @@ namespace Content.IntegrationTests.Tests.Body
public async Task NoSuffocationTest()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{NoClient = true, ExtraPrototypes = Prototypes});
{
NoClient = true,
ExtraPrototypes = Prototypes
});
var server = pairTracker.Pair.Server;
var mapManager = server.ResolveDependency<IMapManager>();
@@ -149,10 +162,16 @@ namespace Content.IntegrationTests.Tests.Body
await server.WaitPost(() =>
{
mapId = mapManager.CreateMap();
grid = mapLoader.LoadGrid(mapId, testMapName);
Assert.That(mapLoader.TryLoad(mapId, testMapName, out var ents), Is.True);
var query = entityManager.GetEntityQuery<MapGridComponent>();
grid = ents
.Select<EntityUid, EntityUid?>(x => x)
.FirstOrDefault((uid) => uid.HasValue && query.HasComponent(uid.Value), null);
Assert.That(grid, Is.Not.Null);
});
Assert.NotNull(grid, $"Test blueprint {testMapName} not found.");
Assert.That(grid, Is.Not.Null, $"Test blueprint {testMapName} not found.");
await server.WaitAssertion(() =>
{
@@ -162,11 +181,12 @@ namespace Content.IntegrationTests.Tests.Body
human = entityManager.SpawnEntity("HumanBodyDummy", coordinates);
var mixture = entityManager.System<AtmosphereSystem>().GetContainingMixture(human);
#pragma warning disable NUnit2045
Assert.That(mixture.TotalMoles, Is.GreaterThan(0));
Assert.True(entityManager.HasComponent<BodyComponent>(human));
Assert.True(entityManager.TryGetComponent(human, out respirator));
Assert.False(respirator.SuffocationCycles > respirator.SuffocationCycleThreshold);
Assert.That(entityManager.HasComponent<BodyComponent>(human), Is.True);
Assert.That(entityManager.TryGetComponent(human, out respirator), Is.True);
Assert.That(respirator.SuffocationCycles, Is.LessThanOrEqualTo(respirator.SuffocationCycleThreshold));
#pragma warning restore NUnit2045
});
var increment = 10;
@@ -179,7 +199,7 @@ namespace Content.IntegrationTests.Tests.Body
await server.WaitRunTicks(increment);
await server.WaitAssertion(() =>
{
Assert.False(respirator.SuffocationCycles > respirator.SuffocationCycleThreshold,
Assert.That(respirator.SuffocationCycles, Is.LessThanOrEqualTo(respirator.SuffocationCycleThreshold),
$"Entity {entityManager.GetComponent<MetaDataComponent>(human).EntityName} is suffocating on tick {tick}");
});
}