Purge IoC resolves from integration tests (#17185)

This commit is contained in:
metalgearsloth
2023-06-07 21:08:52 +10:00
committed by GitHub
parent dfdab6c269
commit 559574ccb9
20 changed files with 83 additions and 71 deletions

View File

@@ -69,12 +69,11 @@ namespace Content.IntegrationTests.Tests
EntityUid pocketItem = default;
InventorySystem invSystem = default!;
var entityMan = server.ResolveDependency<IEntityManager>();
await server.WaitAssertion(() =>
{
invSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<InventorySystem>();
var mapMan = IoCManager.Resolve<IMapManager>();
var entityMan = IoCManager.Resolve<IEntityManager>();
invSystem = entityMan.System<InventorySystem>();
human = entityMan.SpawnEntity("HumanDummy", coordinates);
uniform = entityMan.SpawnEntity("UniformDummy", coordinates);
@@ -96,8 +95,8 @@ namespace Content.IntegrationTests.Tests
Assert.That(invSystem.CanEquip(human, tooBigItem, "pocket1", out _), Is.False); // Still failing!
Assert.That(invSystem.TryEquip(human, pocketItem, "pocket1"));
Assert.That(IsDescendant(idCard, human));
Assert.That(IsDescendant(pocketItem, human));
Assert.That(IsDescendant(idCard, human, entityMan));
Assert.That(IsDescendant(pocketItem, human, entityMan));
// Now drop the jumpsuit.
Assert.That(invSystem.TryUnequip(human, "jumpsuit"));
@@ -108,9 +107,9 @@ namespace Content.IntegrationTests.Tests
await server.WaitAssertion(() =>
{
// Items have been dropped!
Assert.That(IsDescendant(uniform, human), Is.False);
Assert.That(IsDescendant(idCard, human), Is.False);
Assert.That(IsDescendant(pocketItem, human), Is.False);
Assert.That(IsDescendant(uniform, human, entityMan), Is.False);
Assert.That(IsDescendant(idCard, human, entityMan), Is.False);
Assert.That(IsDescendant(pocketItem, human, entityMan), Is.False);
// Ensure everything null here.
Assert.That(!invSystem.TryGetSlotEntity(human, "jumpsuit", out _));
@@ -121,9 +120,9 @@ namespace Content.IntegrationTests.Tests
await pairTracker.CleanReturnAsync();
}
private static bool IsDescendant(EntityUid descendant, EntityUid parent)
private static bool IsDescendant(EntityUid descendant, EntityUid parent, IEntityManager entManager)
{
var xforms = IoCManager.Resolve<IEntityManager>().GetEntityQuery<TransformComponent>();
var xforms = entManager.GetEntityQuery<TransformComponent>();
var tmpParent = xforms.GetComponent(descendant).ParentUid;
while (tmpParent.IsValid())
{