using NUnit.Framework; using Robust.Shared.GameObjects; using Robust.Shared.Map; using Robust.UnitTesting.Server; namespace Robust.UnitTesting.Shared.GameObjects { [TestFixture, Parallelizable] sealed class EntityManagerTests { private static readonly MapId TestMapId = new(1); const string PROTOTYPE = @" - type: entity name: dummy id: dummy components: - type: Transform "; private static ISimulation SimulationFactory() { var sim = RobustServerSimulation .NewSimulation() .RegisterPrototypes(protoMan => protoMan.LoadString(PROTOTYPE)) .InitializeInstance(); var mapManager = sim.Resolve(); // Adds the map with id 1, and spawns entity 1 as the map entity. mapManager.CreateMap(TestMapId); return sim; } /// /// The entity prototype can define field on the TransformComponent, just like any other component. /// [Test] public void SpawnEntity_PrototypeTransform_Works() { var sim = SimulationFactory(); var entMan = sim.Resolve(); var newEnt = entMan.SpawnEntity("dummy", new MapCoordinates(0, 0, TestMapId)); Assert.That(newEnt, Is.Not.EqualTo(EntityUid.Invalid)); } } }