From 81ff9bdda0c0ea8771b2346b8cc333a730dbfb03 Mon Sep 17 00:00:00 2001 From: ElectroJr Date: Mon, 17 Feb 2025 01:33:05 +1300 Subject: [PATCH] Fix merge conflict --- .../Tests/PostMapInitTest.cs | 49 ++++++++++++------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/Content.IntegrationTests/Tests/PostMapInitTest.cs b/Content.IntegrationTests/Tests/PostMapInitTest.cs index dcb2e222a4..e76ca2b5de 100644 --- a/Content.IntegrationTests/Tests/PostMapInitTest.cs +++ b/Content.IntegrationTests/Tests/PostMapInitTest.cs @@ -198,6 +198,10 @@ namespace Content.IntegrationTests.Tests var meta = root["meta"]; var version = meta["format"].AsInt(); + // TODO MAP TESTS + // Move this to some separate test? + CheckDoNotMap(map, root, protoManager); + if (version >= 7) { v7Maps.Add(map); @@ -206,23 +210,6 @@ namespace Content.IntegrationTests.Tests var postMapInit = meta["postmapinit"].AsBool(); Assert.That(postMapInit, Is.False, $"Map {map.Filename} was saved postmapinit"); - - // testing that maps have nothing with the DoNotMap entity category - // I do it here because it's basically copy-paste code for the most part - var yamlEntities = root["entities"]; - if (!protoManager.TryIndex("DoNotMap", out var dnmCategory)) - return; - foreach (var yamlEntity in (YamlSequenceNode)yamlEntities) - { - var protoId = yamlEntity["proto"].AsString(); - protoManager.TryIndex(protoId, out var proto, false); - if (proto is null || proto.EditorSuffix is null) - continue; - if (proto.Categories.Contains(dnmCategory) && !DoNotMapWhitelist.Contains(map.ToString())) - { - Assert.Fail($"\nMap {map} has the DO NOT MAP category in prototype {proto.Name}"); - } - } } var deps = server.ResolveDependency().DependencyCollection; @@ -251,6 +238,34 @@ namespace Content.IntegrationTests.Tests await pair.CleanReturnAsync(); } + /// + /// Check that maps do not have any entities that belong to the DoNotMap entity category + /// + private void CheckDoNotMap(ResPath map, YamlNode node, IPrototypeManager protoManager) + { + if (DoNotMapWhitelist.Contains(map.ToString())) + return; + + var yamlEntities = node["entities"]; + if (!protoManager.TryIndex("DoNotMap", out var dnmCategory)) + return; + + Assert.Multiple(() => + { + foreach (var yamlEntity in (YamlSequenceNode)yamlEntities) + { + var protoId = yamlEntity["proto"].AsString(); + + // This doesn't properly handle prototype migrations, but thats not a significant issue. + if (!protoManager.TryIndex(protoId, out var proto, false)) + continue; + + Assert.That(!proto.Categories.Contains(dnmCategory), + $"\nMap {map} contains entities in the DO NOT MAP category ({proto.Name})"); + } + }); + } + private bool IsPreInit(ResPath map, MapLoaderSystem loader, IDependencyCollection deps) { if (!loader.TryReadFile(map, out var data))