From c98d6fbc56aaf9a86e0ebb6fa719b51e962a0fa8 Mon Sep 17 00:00:00 2001 From: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Date: Wed, 27 Oct 2021 01:15:26 +1100 Subject: [PATCH] Add test for construction start and target nodes (#5037) * Add test for construction start and target nodes * Adjust names * Adjust message slightly * Also add path test --- .../Construction/ConstructionPrototypeTest.cs | 66 +++++++++++++++++++ 1 file changed, 66 insertions(+) create mode 100644 Content.IntegrationTests/Tests/Construction/ConstructionPrototypeTest.cs diff --git a/Content.IntegrationTests/Tests/Construction/ConstructionPrototypeTest.cs b/Content.IntegrationTests/Tests/Construction/ConstructionPrototypeTest.cs new file mode 100644 index 0000000000..9eea03ee70 --- /dev/null +++ b/Content.IntegrationTests/Tests/Construction/ConstructionPrototypeTest.cs @@ -0,0 +1,66 @@ +using System.Collections.Generic; +using System.Threading.Tasks; +using Content.Shared.Construction.Prototypes; +using NUnit.Framework; +using Robust.Shared.Prototypes; + +namespace Content.IntegrationTests.Tests.Construction +{ + [TestFixture] + public sealed class ConstructionPrototypeTest : ContentIntegrationTest + { + [Test] + public async Task TestStartIsValid() + { + var server = StartServerDummyTicker(); + + await server.WaitIdleAsync(); + + var protoMan = server.ResolveDependency(); + + foreach (var proto in protoMan.EnumeratePrototypes()) + { + var start = proto.StartNode; + var graph = protoMan.Index(proto.Graph); + + Assert.That(graph.Nodes.ContainsKey(start), $"Found no startNode \"{start}\" on graph \"{graph.ID}\" for construction prototype \"{proto.ID}\"!"); + } + } + + [Test] + public async Task TestTargetIsValid() + { + var server = StartServerDummyTicker(); + + await server.WaitIdleAsync(); + + var protoMan = server.ResolveDependency(); + + foreach (var proto in protoMan.EnumeratePrototypes()) + { + var target = proto.TargetNode; + var graph = protoMan.Index(proto.Graph); + + Assert.That(graph.Nodes.ContainsKey(target), $"Found no targetNode \"{target}\" on graph \"{graph.ID}\" for construction prototype \"{proto.ID}\"!"); + } + } + + [Test] + public async Task TestStartReachesTarget() + { + var server = StartServerDummyTicker(); + + await server.WaitIdleAsync(); + + var protoMan = server.ResolveDependency(); + + foreach (var proto in protoMan.EnumeratePrototypes()) + { + var start = proto.StartNode; + var target = proto.TargetNode; + var graph = protoMan.Index(proto.Graph); + Assert.That(graph.TryPath(start, target, out _), $"Unable to find path from \"{start}\" to \"{target}\" on graph \"{graph.ID}\""); + } + } + } +}