Files
tbd-station-14/Content.IntegrationTests/Tests/ShuttleTest.cs
2022-09-14 17:26:26 +10:00

50 lines
1.8 KiB
C#

#nullable enable
using System.Threading.Tasks;
using Content.Server.Shuttles.Components;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
using Robust.Shared.Physics.Components;
namespace Content.IntegrationTests.Tests
{
[TestFixture]
public sealed class ShuttleTest
{
[Test]
public async Task Test()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
var server = pairTracker.Pair.Server;
var mapMan = server.ResolveDependency<IMapManager>();
var sEntities = server.ResolveDependency<IEntityManager>();
EntityUid gridEnt = default;
await server.WaitAssertion(() =>
{
var mapId = mapMan.CreateMap();
var grid = mapMan.CreateGrid(mapId);
gridEnt = grid.GridEntityId;
Assert.That(sEntities.TryGetComponent(gridEnt, out ShuttleComponent? shuttleComponent));
Assert.That(sEntities.TryGetComponent(gridEnt, out PhysicsComponent? physicsComponent));
Assert.That(physicsComponent!.BodyType, Is.EqualTo(BodyType.Dynamic));
Assert.That(sEntities.GetComponent<TransformComponent>(gridEnt).LocalPosition, Is.EqualTo(Vector2.Zero));
physicsComponent.ApplyLinearImpulse(Vector2.One);
});
await server.WaitRunTicks(1);
await server.WaitAssertion(() =>
{
Assert.That<Vector2?>(sEntities.GetComponent<TransformComponent>(gridEnt).LocalPosition, Is.Not.EqualTo(Vector2.Zero));
});
await pairTracker.CleanReturnAsync();
}
}
}