From 4faf819bc406c1ea9f9dec5d39997482bbca4d24 Mon Sep 17 00:00:00 2001 From: Nemanja <98561806+EmoGarbage404@users.noreply.github.com> Date: Mon, 19 Dec 2022 22:34:26 -0500 Subject: [PATCH] write a test to ensure all computers are constructible (#13096) --- .../Tests/MachineBoardTest.cs | 36 ++++++++++++++++++- .../Devices/Circuitboards/computer.yml | 10 ------ .../Machines/Computers/computers.yml | 2 ++ 3 files changed, 37 insertions(+), 11 deletions(-) diff --git a/Content.IntegrationTests/Tests/MachineBoardTest.cs b/Content.IntegrationTests/Tests/MachineBoardTest.cs index 25bfc34a44..b97c579e96 100644 --- a/Content.IntegrationTests/Tests/MachineBoardTest.cs +++ b/Content.IntegrationTests/Tests/MachineBoardTest.cs @@ -21,7 +21,8 @@ public sealed class MachineBoardTest "MachineParticleAcceleratorPowerBoxCircuitboard", "MachineParticleAcceleratorEmitterLeftCircuitboard", "MachineParticleAcceleratorEmitterCenterCircuitboard", - "MachineParticleAcceleratorEmitterRightCircuitboard" + "MachineParticleAcceleratorEmitterRightCircuitboard", + "ParticleAcceleratorComputerCircuitboard" }; /// @@ -56,4 +57,37 @@ public sealed class MachineBoardTest await pairTracker.CleanReturnAsync(); } + + /// + /// Ensures that every single computer board's corresponding entity + /// is a computer that can be properly deconstructed to the correct board + /// + [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(); + + await server.WaitAssertion(() => + { + foreach (var p in protoMan.EnumeratePrototypes().Where(p => !p.Abstract && !_ignoredPrototypes.Contains(p.ID))) + { + if (!p.TryGetComponent(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(cId, out var cProto), + $"Computer board \"{p.ID}\"'s corresponding computer has an invalid prototype."); + Assert.That(cProto.TryGetComponent(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(); + } } diff --git a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/computer.yml b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/computer.yml index 77fa621842..b1d37ffcc0 100644 --- a/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/computer.yml +++ b/Resources/Prototypes/Entities/Objects/Devices/Circuitboards/computer.yml @@ -124,16 +124,6 @@ - DroneUsable - ComputerTelevisionCircuitboard -- type: entity - parent: BaseComputerCircuitboard - id: PowerMonitoringComputerCircuitboard - name: power monitoring computer board - components: - - type: Sprite - state: cpu_engineering - - type: ComputerBoard - prototype: ComputerPowerMonitoring - - type: entity parent: BaseComputerCircuitboard id: ResearchComputerCircuitboard diff --git a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml index eda1798033..6dccbfc49e 100644 --- a/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml +++ b/Resources/Prototypes/Entities/Structures/Machines/Computers/computers.yml @@ -96,6 +96,8 @@ radius: 1.5 energy: 1.6 color: "#c94242" + - type: Computer + board: SyndicateShuttleConsoleCircuitboard - type: entity parent: BaseComputerShuttle