Machine-code cleanup (#28489)
This commit is contained in:
@@ -2,6 +2,8 @@
|
||||
using System.Linq;
|
||||
using Content.Server.Construction.Components;
|
||||
using Content.Shared.Construction.Components;
|
||||
using Content.Shared.Prototypes;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.IntegrationTests.Tests;
|
||||
@@ -49,12 +51,11 @@ public sealed class MachineBoardTest
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(mId, Is.Not.Null, $"Machine board {p.ID} does not have a corresponding machine.");
|
||||
Assert.That(protoMan.TryIndex<EntityPrototype>(mId, out var mProto),
|
||||
$"Machine board {p.ID}'s corresponding machine has an invalid prototype.");
|
||||
Assert.That(mProto.TryGetComponent<MachineComponent>(out var mComp),
|
||||
$"Machine board {p.ID}'s corresponding machine {mId} does not have MachineComponent");
|
||||
Assert.That(mComp.BoardPrototype, Is.EqualTo(p.ID),
|
||||
Assert.That(mComp.Board, Is.EqualTo(p.ID),
|
||||
$"Machine {mId}'s BoardPrototype is not equal to it's corresponding machine board, {p.ID}");
|
||||
});
|
||||
}
|
||||
@@ -101,4 +102,40 @@ public sealed class MachineBoardTest
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures that every single computer board's corresponding entity
|
||||
/// is a computer that can be properly deconstructed to the correct board
|
||||
/// </summary>
|
||||
[Test]
|
||||
public async Task TestValidateBoardComponentRequirements()
|
||||
{
|
||||
await using var pair = await PoolManager.GetServerClient();
|
||||
var server = pair.Server;
|
||||
|
||||
var entMan = server.ResolveDependency<IEntityManager>();
|
||||
var protoMan = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>()
|
||||
.Where(p => !p.Abstract)
|
||||
.Where(p => !pair.IsTestPrototype(p))
|
||||
.Where(p => !_ignoredPrototypes.Contains(p.ID)))
|
||||
{
|
||||
if (!p.TryGetComponent<MachineBoardComponent>(out var board, entMan.ComponentFactory))
|
||||
continue;
|
||||
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
foreach (var component in board.ComponentRequirements.Keys)
|
||||
{
|
||||
Assert.That(entMan.ComponentFactory.TryGetRegistration(component, out _), $"Invalid component requirement {component} specified on machine board entity {p}");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
await pair.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user