diff --git a/Content.IntegrationTests/Pair/TestPair.Helpers.cs b/Content.IntegrationTests/Pair/TestPair.Helpers.cs index 1b4825cc9c..5e7ba0dcc8 100644 --- a/Content.IntegrationTests/Pair/TestPair.Helpers.cs +++ b/Content.IntegrationTests/Pair/TestPair.Helpers.cs @@ -111,9 +111,16 @@ public sealed partial class TestPair HashSet? ignored = null, bool ignoreAbstract = true, bool ignoreTestPrototypes = true) - where T : IComponent + where T : IComponent, new() { - var id = Server.ResolveDependency().GetComponentName(typeof(T)); + if (!Server.ResolveDependency().TryGetRegistration(out var reg) + && !Client.ResolveDependency().TryGetRegistration(out reg)) + { + Assert.Fail($"Unknown component: {typeof(T).Name}"); + return new(); + } + + var id = reg.Name; var list = new List<(EntityPrototype, T)>(); foreach (var proto in Server.ProtoMan.EnumeratePrototypes()) { diff --git a/Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs b/Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs index fb0c67afd7..be608c374b 100644 --- a/Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs +++ b/Content.IntegrationTests/Tests/MagazineVisualsSpriteTest.cs @@ -18,33 +18,32 @@ public sealed class MagazineVisualsSpriteTest { await using var pair = await PoolManager.GetServerClient(); var client = pair.Client; - var protoMan = client.ResolveDependency(); - var componentFactory = client.ResolveDependency(); + var toTest = new List<(int, string)>(); + var protos = pair.GetPrototypesWithComponent(); await client.WaitAssertion(() => { Assert.Multiple(() => { - foreach (var proto in protoMan.EnumeratePrototypes()) + foreach (var (proto, _) in protos) { - if (proto.Abstract || pair.IsTestPrototype(proto)) - continue; + var uid = client.EntMan.Spawn(proto.ID); + var visuals = client.EntMan.GetComponent(uid); - if (!proto.TryGetComponent(out var visuals, componentFactory)) - continue; - - Assert.That(proto.TryGetComponent(out var sprite, componentFactory), + Assert.That(client.EntMan.TryGetComponent(uid, out SpriteComponent sprite), @$"{proto.ID} has MagazineVisualsComponent but no SpriteComponent."); - Assert.That(proto.HasComponent(componentFactory), + Assert.That(client.EntMan.HasComponent(uid), @$"{proto.ID} has MagazineVisualsComponent but no AppearanceComponent."); - var toTest = new List<(int, string)>(); + toTest.Clear(); if (sprite.LayerMapTryGet(GunVisualLayers.Mag, out var magLayerId)) toTest.Add((magLayerId, "")); if (sprite.LayerMapTryGet(GunVisualLayers.MagUnshaded, out var magUnshadedLayerId)) toTest.Add((magUnshadedLayerId, "-unshaded")); - Assert.That(toTest, Is.Not.Empty, + Assert.That( + toTest, + Is.Not.Empty, @$"{proto.ID} has MagazineVisualsComponent but no Mag or MagUnshaded layer map."); var start = visuals.ZeroVisible ? 0 : 1; @@ -63,6 +62,8 @@ public sealed class MagazineVisualsSpriteTest var extraState = $"{visuals.MagState}{midfix}-{visuals.MagSteps}"; Assert.That(rsi.TryGetState(extraState, out _), Is.False, @$"{proto.ID} has MagazineVisualsComponent with MagSteps = {visuals.MagSteps}, but more states exist!"); + + client.EntMan.DeleteEntity(uid); } } });