mirror of
https://github.com/space-wizards/RobustToolbox.git
synced 2026-09-06 17:58:05 +02:00
* 2 warnings in JointDeletion_Test * 1 warning in Collision_Test * 2 warnings in Color_Test (deleted test of deprecated HCY color space) * 1 warning in MapVelocity_Test * 2 warnings in MapManager_Tests * 2 warnings in MapPauseTests * 1 warning in NetDisconnectMessageTest * 1 warning in ContainerTests * Suppress 1 warning in EntityEventBusTests.ComponentEvent * 4 warnings in MapGridMap_Tests * 1 warning in GridDeletion_Test * Remove TryGetContainingContainer foolishness --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
61 lines
1.9 KiB
C#
61 lines
1.9 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using NUnit.Framework;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Map.Components;
|
|
using Robust.Shared.Maths;
|
|
using Robust.UnitTesting.Server;
|
|
|
|
namespace Robust.UnitTesting.Shared.Map;
|
|
|
|
[TestFixture]
|
|
public sealed class MapGridMap_Tests
|
|
{
|
|
/// <summary>
|
|
/// Asserts FindGrids only returns the map once.
|
|
/// </summary>
|
|
[Test]
|
|
public void FindGrids()
|
|
{
|
|
var sim = RobustServerSimulation.NewSimulation().InitializeInstance();
|
|
|
|
var entManager = sim.Resolve<IEntityManager>();
|
|
var mapManager = sim.Resolve<IMapManager>();
|
|
var mapSystem = entManager.System<SharedMapSystem>();
|
|
|
|
var mapId = sim.CreateMap().MapId;
|
|
List<Entity<MapGridComponent>> grids = [];
|
|
mapManager.FindGridsIntersecting(mapId, Box2.UnitCentered, ref grids);
|
|
Assert.That(grids, Is.Empty);
|
|
|
|
entManager.AddComponent<MapGridComponent>(mapSystem.GetMapOrInvalid(mapId));
|
|
mapManager.FindGridsIntersecting(mapId, Box2.UnitCentered, ref grids);
|
|
Assert.That(grids, Has.Count.EqualTo(1));
|
|
}
|
|
|
|
/// <summary>
|
|
/// Asserts that adding <see cref="MapGridComponent"/> to an existing map with a grid on it doesn't explode.
|
|
/// </summary>
|
|
[Test]
|
|
public void AddGridCompToMap()
|
|
{
|
|
var sim = RobustServerSimulation.NewSimulation().InitializeInstance();
|
|
|
|
var entManager = sim.Resolve<IEntityManager>();
|
|
var mapManager = sim.Resolve<IMapManager>();
|
|
var mapSystem = entManager.System<SharedMapSystem>();
|
|
|
|
var mapId = sim.CreateMap().MapId;
|
|
mapManager.CreateGridEntity(mapId);
|
|
|
|
Assert.DoesNotThrow(() =>
|
|
{
|
|
entManager.AddComponent<MapGridComponent>(mapSystem.GetMapOrInvalid(mapId));
|
|
entManager.TickUpdate(0.016f, false);
|
|
});
|
|
|
|
mapSystem.DeleteMap(mapId);
|
|
}
|
|
}
|