Add storage fill test (#3352)
Validates amounts (useful) and prototypes (less useful given SpawnEntityTest exists) Co-authored-by: Metal Gear Sloth <metalgearsloth@gmail.com>
This commit is contained in:
42
Content.IntegrationTests/Tests/StorageFillTest.cs
Normal file
42
Content.IntegrationTests/Tests/StorageFillTest.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
#nullable enable
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Utility;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
[TestFixture]
|
||||
public sealed class StorageFillTest : ContentIntegrationTest
|
||||
{
|
||||
[Test]
|
||||
public async Task TestStorageFillPrototypes()
|
||||
{
|
||||
var server = StartServerDummyTicker();
|
||||
await server.WaitIdleAsync();
|
||||
var protoManager = server.ResolveDependency<IPrototypeManager>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
foreach (var proto in protoManager.EnumeratePrototypes<EntityPrototype>())
|
||||
{
|
||||
if (!proto.Components.TryGetValue("StorageFill", out var storageNode) ||
|
||||
!storageNode.TryGetNode("contents", out YamlSequenceNode? contentsNode)) continue;
|
||||
|
||||
foreach (var child in contentsNode)
|
||||
{
|
||||
if (child is not YamlMappingNode mapping) continue;
|
||||
var name = mapping.GetNode("name").AsString();
|
||||
Assert.That(protoManager.HasIndex<EntityPrototype>(name), $"Unable to find StorageFill prototype of {name} in prototype {proto.ID}");
|
||||
|
||||
if (mapping.TryGetNode("amount", out var amount))
|
||||
{
|
||||
Assert.That(amount.AsInt() > 0, $"Specified invalid amount of {amount} for prototype {proto.ID}");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user