diff --git a/Content.IntegrationTests/Tests/DeviceLinking/DeviceLinkingTest.cs b/Content.IntegrationTests/Tests/DeviceLinking/DeviceLinkingTest.cs
index 6ce6d5d78e0..c62b46ab6d4 100644
--- a/Content.IntegrationTests/Tests/DeviceLinking/DeviceLinkingTest.cs
+++ b/Content.IntegrationTests/Tests/DeviceLinking/DeviceLinkingTest.cs
@@ -1,12 +1,9 @@
-using System.Collections.Generic;
-using System.Linq;
+using Content.IntegrationTests.Utility;
using Content.Server.DeviceLinking.Systems;
using Content.Shared.DeviceLinking;
-using Content.Shared.Prototypes;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
-using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.DeviceLinking;
@@ -24,69 +21,61 @@ public sealed class DeviceLinkingTest
- Output
";
- ///
- /// Spawns every entity that has a
- /// and sends a signal to every port to make sure nothing causes an error.
- ///
+ private static string[] _entitiesWithDeviceLinkSink = GameDataScrounger.EntitiesWithComponent("DeviceLinkSink");
+
[Test]
- public async Task AllDeviceLinkSinksWorkTest()
+ [TestOf(typeof(DeviceLinkSinkComponent))]
+ [TestCaseSource(nameof(_entitiesWithDeviceLinkSink))]
+ [Description("Ensures all devices that can sink signals will not cause exceptions when signaled.")]
+ public async Task DeviceLinkSinkAllPortsTest(string protoKey)
{
await using var pair = await PoolManager.GetServerClient();
var server = pair.Server;
+ var protoMan = server.ProtoMan;
var compFact = server.ResolveDependency();
var mapMan = server.ResolveDependency();
var mapSys = server.System();
var deviceLinkSys = server.System();
- var prototypes = server.ProtoMan.EnumeratePrototypes();
-
await server.WaitAssertion(() =>
{
- Assert.Multiple(() =>
+ using (Assert.EnterMultipleScope())
{
- foreach (var proto in prototypes)
+ var proto = protoMan.Index(protoKey);
+ Assert.That(proto.TryGetComponent(out var protoSinkComp, compFact));
+
+ foreach (var port in protoSinkComp!.Ports)
{
- if (proto.Abstract || pair.IsTestPrototype(proto))
- continue;
+ // Create a map for each entity/port combo so they can't interfere
+ mapSys.CreateMap(out var mapId);
+ var grid = mapMan.CreateGridEntity(mapId);
+ mapSys.SetTile(grid.Owner, grid.Comp, Vector2i.Zero, new Tile(1));
+ var coord = new EntityCoordinates(grid.Owner, 0, 0);
- if (!proto.TryGetComponent(out var protoSinkComp, compFact))
- continue;
+ // Spawn the sink entity
+ var sinkEnt = server.EntMan.SpawnEntity(proto.ID, coord);
+ // Get the actual sink component, since the one we got from the prototype isn't initialized.
+ var sinkComp = server.EntMan.GetComponent(sinkEnt);
- foreach (var port in protoSinkComp.Ports)
- {
- // Create a map for each entity/port combo so they can't interfere
- mapSys.CreateMap(out var mapId);
- var grid = mapMan.CreateGridEntity(mapId);
- mapSys.SetTile(grid.Owner, grid.Comp, Vector2i.Zero, new Tile(1));
- var coord = new EntityCoordinates(grid.Owner, 0, 0);
+ // Spawn the tester
+ var sourceEnt = server.EntMan.SpawnEntity(PortTesterProtoId, coord);
+ var sourceComp = server.EntMan.GetComponent(sourceEnt);
- // Spawn the sink entity
- var sinkEnt = server.EntMan.SpawnEntity(proto.ID, coord);
- // Get the actual sink component, since the one we got from the prototype doesn't have its owner set up
- Assert.That(server.EntMan.TryGetComponent(sinkEnt, out var sinkComp),
- $"{proto.ID} does not have a DeviceLinkSinkComponent!");
+ // Create a link from the tester's output to the target port on the sink
+ deviceLinkSys.SaveLinks(null,
+ sourceEnt,
+ sinkEnt,
+ [("Output", port.Id)],
+ sourceComp,
+ sinkComp);
- // Spawn the tester
- var sourceEnt = server.EntMan.SpawnEntity(PortTesterProtoId, coord);
- Assert.That(server.EntMan.TryGetComponent(sourceEnt, out var sourceComp),
- $"Tester prototype does not have a DeviceLinkSourceComponent!");
+ // Send a signal to the port
+ Assert.DoesNotThrow(() => { deviceLinkSys.InvokePort(sourceEnt, "Output", null, sourceComp); },
+ $"Exception thrown while triggering port {port.Id} of the sink device.");
- // Create a link from the tester's output to the target port on the sink
- deviceLinkSys.SaveLinks(null,
- sourceEnt,
- sinkEnt,
- [("Output", port.Id)],
- sourceComp,
- sinkComp);
-
- // Send a signal to the port
- Assert.DoesNotThrow(() => { deviceLinkSys.InvokePort(sourceEnt, "Output", null, sourceComp); },
- $"Exception thrown while triggering port {port.Id} of sink device {proto.ID}");
-
- mapSys.DeleteMap(mapId);
- }
+ mapSys.DeleteMap(mapId);
}
- });
+ }
});
await pair.CleanReturnAsync();