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,12 +1,7 @@
#nullable enable
using System.Threading.Tasks;
using Content.Shared.Physics;
using Content.Shared.Spawning;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Systems;
namespace Content.IntegrationTests.Tests.Utility
@@ -36,7 +31,11 @@ namespace Content.IntegrationTests.Tests.Utility
[Test]
public async Task Test()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
{
NoClient = true,
ExtraPrototypes = Prototypes
});
var server = pairTracker.Pair.Server;
var testMap = await PoolManager.CreateTestMap(pairTracker);
@@ -50,36 +49,54 @@ namespace Content.IntegrationTests.Tests.Utility
{
// Nothing blocking it, only entity is the grid
Assert.NotNull(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable));
Assert.True(sEntityManager.TrySpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable, out var entity));
Assert.NotNull(entity);
Assert.Multiple(() =>
{
Assert.That(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable), Is.Not.Null);
Assert.That(sEntityManager.TrySpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable, out var entity));
Assert.That(entity, Is.Not.Null);
});
// Nothing blocking it, only entity is the grid
Assert.NotNull(sEntityManager.SpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.Impassable));
Assert.True(sEntityManager.TrySpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.Impassable, out entity));
Assert.NotNull(entity);
Assert.Multiple(() =>
{
Assert.That(sEntityManager.SpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.Impassable), Is.Not.Null);
Assert.That(sEntityManager.TrySpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.Impassable, out var entity));
Assert.That(entity, Is.Not.Null);
});
// Spawn a blocker with an Impassable mask
sEntityManager.SpawnEntity(BlockerDummyId, entityCoordinates);
broady.Update(0.016f);
// Cannot spawn something with an Impassable layer
Assert.Null(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable));
Assert.False(sEntityManager.TrySpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable, out entity));
Assert.Null(entity);
Assert.Multiple(() =>
{
Assert.That(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable), Is.Null);
Assert.That(sEntityManager.TrySpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.Impassable, out var entity), Is.False);
Assert.That(entity, Is.Null);
});
Assert.Null(sEntityManager.SpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.Impassable));
Assert.False(sEntityManager.TrySpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.Impassable, out entity));
Assert.Null(entity);
Assert.Multiple(() =>
{
Assert.That(sEntityManager.SpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.Impassable), Is.Null);
Assert.That(sEntityManager.TrySpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.Impassable, out var entity), Is.False);
Assert.That(entity, Is.Null);
});
// Other layers are fine
Assert.NotNull(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.MidImpassable));
Assert.True(sEntityManager.TrySpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.MidImpassable, out entity));
Assert.NotNull(entity);
Assert.Multiple(() =>
{
Assert.That(sEntityManager.SpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.MidImpassable), Is.Not.Null);
Assert.That(sEntityManager.TrySpawnIfUnobstructed(null, entityCoordinates, CollisionGroup.MidImpassable, out var entity));
Assert.That(entity, Is.Not.Null);
});
Assert.NotNull(sEntityManager.SpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.MidImpassable));
Assert.True(sEntityManager.TrySpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.MidImpassable, out entity));
Assert.NotNull(entity);
Assert.Multiple(() =>
{
Assert.That(sEntityManager.SpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.MidImpassable), Is.Not.Null);
Assert.That(sEntityManager.TrySpawnIfUnobstructed(null, mapCoordinates, CollisionGroup.MidImpassable, out var entity));
Assert.That(entity, Is.Not.Null);
});
});
await pairTracker.CleanReturnAsync();
}

View File

@@ -1,10 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Content.Shared.Containers.ItemSlots;
using Content.Shared.Whitelist;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
namespace Content.IntegrationTests.Tests.Utility
{
@@ -60,7 +57,7 @@ namespace Content.IntegrationTests.Tests.Utility
[Test]
public async Task Test()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true, ExtraPrototypes = Prototypes});
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
var server = pairTracker.Pair.Server;
var testMap = await PoolManager.CreateTestMap(pairTracker);
@@ -79,34 +76,46 @@ namespace Content.IntegrationTests.Tests.Utility
// Test instantiated on its own
var whitelistInst = new EntityWhitelist
{
Components = new[] { $"{ValidComponent}"},
Tags = new() {"ValidTag"}
Components = new[] { $"{ValidComponent}" },
Tags = new() { "ValidTag" }
};
whitelistInst.UpdateRegistrations();
Assert.That(whitelistInst, Is.Not.Null);
Assert.That(whitelistInst.Components, Is.Not.Null);
Assert.That(whitelistInst.Tags, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(whitelistInst.Components, Is.Not.Null);
Assert.That(whitelistInst.Tags, Is.Not.Null);
});
Assert.That(whitelistInst.IsValid(validComponent), Is.True);
Assert.That(whitelistInst.IsValid(validTag), Is.True);
Assert.Multiple(() =>
{
Assert.That(whitelistInst.IsValid(validComponent), Is.True);
Assert.That(whitelistInst.IsValid(validTag), Is.True);
Assert.That(whitelistInst.IsValid(invalidComponent), Is.False);
Assert.That(whitelistInst.IsValid(invalidTag), Is.False);
Assert.That(whitelistInst.IsValid(invalidComponent), Is.False);
Assert.That(whitelistInst.IsValid(invalidTag), Is.False);
});
// Test from serialized
var dummy = sEntities.SpawnEntity("WhitelistDummy", mapCoordinates);
var whitelistSer = sEntities.GetComponent<ItemSlotsComponent>(dummy).Slots.Values.First().Whitelist;
Assert.That(whitelistSer, Is.Not.Null);
Assert.That(whitelistSer.Components, Is.Not.Null);
Assert.That(whitelistSer.Tags, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(whitelistSer.Components, Is.Not.Null);
Assert.That(whitelistSer.Tags, Is.Not.Null);
});
Assert.That(whitelistSer.IsValid(validComponent), Is.True);
Assert.That(whitelistSer.IsValid(validTag), Is.True);
Assert.Multiple(() =>
{
Assert.That(whitelistSer.IsValid(validComponent), Is.True);
Assert.That(whitelistSer.IsValid(validTag), Is.True);
Assert.That(whitelistSer.IsValid(invalidComponent), Is.False);
Assert.That(whitelistSer.IsValid(invalidTag), Is.False);
Assert.That(whitelistSer.IsValid(invalidComponent), Is.False);
Assert.That(whitelistSer.IsValid(invalidTag), Is.False);
});
});
await pairTracker.CleanReturnAsync();
}

View File

@@ -1,5 +1,3 @@
using System.Threading.Tasks;
using NUnit.Framework;
namespace Content.IntegrationTests.Tests.Utility;
@@ -8,7 +6,7 @@ public sealed class SandboxTest
[Test]
public async Task Test()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoServer = true, Destructive = true});
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoServer = true, Destructive = true });
var client = pairTracker.Pair.Client;
await client.CheckSandboxed(typeof(Client.Entry.EntryPoint).Assembly);
await pairTracker.CleanReturnAsync();