]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Make test EntitySpecifiers ignore entities with null prototypes (#22174)
authorTemporalOroboros <TemporalOroboros@gmail.com>
Thu, 7 Dec 2023 01:09:44 +0000 (17:09 -0800)
committerGitHub <noreply@github.com>
Thu, 7 Dec 2023 01:09:44 +0000 (20:09 -0500)
Content.IntegrationTests/Tests/Interaction/InteractionTest.EntitySpecifier.cs
Content.IntegrationTests/Tests/Interaction/InteractionTest.EntitySpecifierCollection.cs
Content.IntegrationTests/Tests/Interaction/InteractionTest.Helpers.cs

index 86aaa68c8228c4596dcb51cb5dd9ec79d0c00fcd..414cf4bb56f21c9c4dc12ebd295cdcd695395ce2 100644 (file)
@@ -112,17 +112,19 @@ public abstract partial class InteractionTest
     }
 
     /// <summary>
-    /// Convert an entity-uid to a matching entity specifier. Usefull when doing entity lookups & checking that the
-    /// right quantity of entities/materials werre produced.
+    /// Convert an entity-uid to a matching entity specifier. Useful when doing entity lookups & checking that the
+    /// right quantity of entities/materials werre produced. Returns null if passed an entity with a null prototype.
     /// </summary>
-    protected EntitySpecifier ToEntitySpecifier(EntityUid uid)
+    protected EntitySpecifier? ToEntitySpecifier(EntityUid uid)
     {
         if (SEntMan.TryGetComponent(uid, out StackComponent? stack))
             return new EntitySpecifier(stack.StackTypeId, stack.Count) { Converted = true };
 
         var meta = SEntMan.GetComponent<MetaDataComponent>(uid);
-        Assert.That(meta.EntityPrototype, Is.Not.Null);
 
-        return new(meta.EntityPrototype!.ID, 1) { Converted = true };
+        if (meta.EntityPrototype is null)
+            return null;
+
+        return new(meta.EntityPrototype.ID, 1) { Converted = true };
     }
 }
index 0af2747662cb3805d12bb52361e3d961051d2d12..520d2699c14a3778f7a8053a228781f20913b0c4 100644 (file)
@@ -156,7 +156,9 @@ public abstract partial class InteractionTest
 
     protected EntitySpecifierCollection ToEntityCollection(IEnumerable<EntityUid> entities)
     {
-        var collection = new EntitySpecifierCollection(entities.Select(uid => ToEntitySpecifier(uid)));
+        var collection = new EntitySpecifierCollection(entities
+            .Select(ToEntitySpecifier)
+            .OfType<EntitySpecifier>());
         Assert.That(collection.Converted);
         return collection;
     }
index f59952afecdc874090533021c395dec338fb7620..6c842f00827c8b6a2e155ed02f6db50ef87afcc0 100644 (file)
@@ -598,7 +598,7 @@ public abstract partial class InteractionTest
 
     /// <summary>
     /// Performs an entity lookup and asserts that only the listed entities exist and that they are all present.
-    /// Ignores the grid, map, player, target and contained entities.
+    /// Ignores the grid, map, player, target, contained entities, and entities with null prototypes.
     /// </summary>
     protected async Task AssertEntityLookup(
         EntitySpecifierCollection collection,
@@ -652,6 +652,9 @@ public abstract partial class InteractionTest
         foreach (var uid in entities)
         {
             var found = ToEntitySpecifier(uid);
+            if (found is null)
+                continue;
+
             if (spec.Prototype != found.Prototype)
                 continue;