Add material arbitrage tests (#13315)

This commit is contained in:
Leon Friedrich
2023-01-15 21:57:59 +13:00
committed by GitHub
parent 9f3256730d
commit cf509c1e38
28 changed files with 415 additions and 34 deletions

View File

@@ -1,14 +1,11 @@
using System.Threading.Tasks;
using Content.Server.Construction.Components;
using Content.Server.Stack;
using Content.Shared.Construction.Prototypes;
using Content.Shared.Construction.Steps;
using Content.Shared.Prototypes;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Prototypes;
using System.Threading.Tasks;
namespace Content.IntegrationTests.Tests.Construction
{
@@ -90,6 +87,37 @@ namespace Content.IntegrationTests.Tests.Construction
await pairTracker.CleanReturnAsync();
}
[Test]
public async Task DeconstructionIsValid()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server;
var entMan = server.ResolveDependency<IEntityManager>();
var protoMan = server.ResolveDependency<IPrototypeManager>();
var compFact = server.ResolveDependency<IComponentFactory>();
var name = compFact.GetComponentName(typeof(ConstructionComponent));
Assert.Multiple(() =>
{
foreach (var proto in protoMan.EnumeratePrototypes<EntityPrototype>())
{
if (proto.Abstract || !proto.Components.TryGetValue(name, out var reg))
continue;
var comp = (ConstructionComponent) reg.Component;
var target = comp.DeconstructionNode;
if (target == null)
continue;
var graph = protoMan.Index<ConstructionGraphPrototype>(comp.Graph);
Assert.That(graph.Nodes.ContainsKey(target), $"Invalid deconstruction node \"{target}\" on graph \"{graph.ID}\" for construction entity \"{proto.ID}\"!");
}
});
await pairTracker.CleanReturnAsync();
}
[Test]
public async Task TestStartReachesValidTarget()
{