write a test to ensure all computers are constructible (#13096)

This commit is contained in:
Nemanja
2022-12-19 22:34:26 -05:00
committed by GitHub
parent 586864ee85
commit 4faf819bc4
3 changed files with 37 additions and 11 deletions

View File

@@ -21,7 +21,8 @@ public sealed class MachineBoardTest
"MachineParticleAcceleratorPowerBoxCircuitboard", "MachineParticleAcceleratorPowerBoxCircuitboard",
"MachineParticleAcceleratorEmitterLeftCircuitboard", "MachineParticleAcceleratorEmitterLeftCircuitboard",
"MachineParticleAcceleratorEmitterCenterCircuitboard", "MachineParticleAcceleratorEmitterCenterCircuitboard",
"MachineParticleAcceleratorEmitterRightCircuitboard" "MachineParticleAcceleratorEmitterRightCircuitboard",
"ParticleAcceleratorComputerCircuitboard"
}; };
/// <summary> /// <summary>
@@ -56,4 +57,37 @@ public sealed class MachineBoardTest
await pairTracker.CleanReturnAsync(); await pairTracker.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 TestComputerBoardHasValidComputer()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
var server = pairTracker.Pair.Server;
var protoMan = server.ResolveDependency<IPrototypeManager>();
await server.WaitAssertion(() =>
{
foreach (var p in protoMan.EnumeratePrototypes<EntityPrototype>().Where(p => !p.Abstract && !_ignoredPrototypes.Contains(p.ID)))
{
if (!p.TryGetComponent<ComputerBoardComponent>(out var cbc))
continue;
var cId = cbc.Prototype;
Assert.That(cId, Is.Not.Null, $"Computer board \"{p.ID}\" does not have a corresponding computer.");
Assert.That(protoMan.TryIndex<EntityPrototype>(cId, out var cProto),
$"Computer board \"{p.ID}\"'s corresponding computer has an invalid prototype.");
Assert.That(cProto.TryGetComponent<ComputerComponent>(out var cComp),
$"Computer board {p.ID}'s corresponding computer \"{cId}\" does not have ComputerComponent");
Assert.That(cComp.BoardPrototype, Is.EqualTo(p.ID),
$"Computer \"{cId}\"'s BoardPrototype is not equal to it's corresponding computer board, \"{p.ID}\"");
}
});
await pairTracker.CleanReturnAsync();
}
} }

View File

@@ -124,16 +124,6 @@
- DroneUsable - DroneUsable
- ComputerTelevisionCircuitboard - ComputerTelevisionCircuitboard
- type: entity
parent: BaseComputerCircuitboard
id: PowerMonitoringComputerCircuitboard
name: power monitoring computer board
components:
- type: Sprite
state: cpu_engineering
- type: ComputerBoard
prototype: ComputerPowerMonitoring
- type: entity - type: entity
parent: BaseComputerCircuitboard parent: BaseComputerCircuitboard
id: ResearchComputerCircuitboard id: ResearchComputerCircuitboard

View File

@@ -96,6 +96,8 @@
radius: 1.5 radius: 1.5
energy: 1.6 energy: 1.6
color: "#c94242" color: "#c94242"
- type: Computer
board: SyndicateShuttleConsoleCircuitboard
- type: entity - type: entity
parent: BaseComputerShuttle parent: BaseComputerShuttle