Skip to content

Commit

Permalink
Update MetempsychosisTest.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
VMSolidus committed Feb 9, 2024
1 parent eaa031e commit f8a306b
Showing 1 changed file with 15 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System.Linq;
using Content.Server.Nyanotrasen.Cloning;
using Content.Shared.Humanoid.Prototypes;
using Content.Shared.Random;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;

namespace Content.IntegrationTests.Tests.DeltaV;
Expand All @@ -11,8 +9,6 @@ namespace Content.IntegrationTests.Tests.DeltaV;
[TestOf(typeof(MetempsychoticMachineSystem))]
public sealed class MetempsychosisTest
{
private readonly IPrototypeManager _prototypeManager = default!;

[Test]
public async Task AllHumanoidPoolSpeciesExist()
{
Expand All @@ -21,47 +17,36 @@ public async Task AllHumanoidPoolSpeciesExist()
// Per RobustIntegrationTest.cs, wait until state is settled to access it.
await server.WaitIdleAsync();

var mapManager = server.ResolveDependency<IMapManager>();
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
var entityManager = server.ResolveDependency<IEntityManager>();
var entitySystemManager = server.ResolveDependency<IEntitySystemManager>();

var metemSystem = entitySystemManager.GetEntitySystem<MetempsychoticMachineSystem>();
var metemComponent = new MetempsychoticMachineComponent();

var testMap = await pair.CreateTestMap();

await server.WaitAssertion(() =>
{
_prototypeManager.TryIndex<WeightedRandomPrototype>(metemComponent.MetempsychoticHumanoidPool, out var humanoidPool);
_prototypeManager.TryIndex<WeightedRandomPrototype>(metemComponent.MetempsychoticNonHumanoidPool, out var nonHumanoidPool);
prototypeManager.TryIndex<WeightedRandomPrototype>(metemComponent.MetempsychoticHumanoidPool,
out var humanoidPool);
prototypeManager.TryIndex<WeightedRandomPrototype>(metemComponent.MetempsychoticNonHumanoidPool,
out var nonHumanoidPool);
var coordinates = testMap.GridCoords;
Assert.That(humanoidPool, Is.Not.Null, "MetempsychoticHumanoidPool is null!");
Assert.That(nonHumanoidPool, Is.Not.Null, "MetempsychoticNonHumanoidPool is null!");
Assert.That(humanoidPool.Weights.Any(), "MetempsychoticHumanoidPool has no valid prototypes!");
Assert.That(nonHumanoidPool.Weights.Any(), "MetempsychoticNonHumanoidPool has no valid prototypes!");
Assert.That(humanoidPool.Weights, Is.Not.Empty,
"MetempsychoticHumanoidPool has no valid prototypes!");
Assert.That(nonHumanoidPool.Weights, Is.Not.Empty,
"MetempsychoticNonHumanoidPool has no valid prototypes!");
foreach (var (key, weight) in humanoidPool.Weights)
foreach (var key in humanoidPool.Weights.Keys)
{
Assert.That(prototypeManager.TryIndex(key, out var _),
Assert.That(prototypeManager.TryIndex<SpeciesPrototype>(key, out _),
$"MetempsychoticHumanoidPool has invalid prototype {key}!");
var spawned = entityManager.SpawnEntity(key, coordinates);
}
foreach (var (key, weight) in nonHumanoidPool.Weights)
foreach (var key in nonHumanoidPool.Weights.Keys)
{
Assert.That(prototypeManager.TryIndex(key, out var _),
Assert.That(prototypeManager.TryIndex<EntityPrototype>(key, out _),
$"MetempsychoticNonHumanoidPool has invalid prototype {key}!");
var spawned = entityManager.SpawnEntity(key, coordinates);
}
// Because Server/Client pairs can be re-used between Tests, we
// need to clean up anything that might affect other tests,
// otherwise this pair cannot be considered clean, and the
// CleanReturnAsync call would need to be removed.
mapManager.DeleteMap(testMap.MapId);
});
await pair.CleanReturnAsync();
}
Expand Down

0 comments on commit f8a306b

Please sign in to comment.