Files
crystall-punk-14/Content.IntegrationTests/Tests/ShuttleTest.cs

49 lines
1.6 KiB
C#
Raw Normal View History

#nullable enable
using System.Threading.Tasks;
2021-11-21 17:09:49 +11:00
using Content.Server.Shuttles.Components;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Maths;
using Robust.Shared.Physics;
namespace Content.IntegrationTests.Tests
{
[TestFixture]
public sealed class ShuttleTest : ContentIntegrationTest
{
[Test]
public async Task Test()
{
var server = StartServer();
await server.WaitIdleAsync();
var mapMan = server.ResolveDependency<IMapManager>();
2021-12-05 18:09:01 +01:00
var sEntities = server.ResolveDependency<IEntityManager>();
EntityUid gridEnt = default;
await server.WaitAssertion(() =>
{
var mapId = mapMan.CreateMap();
var grid = mapMan.CreateGrid(mapId);
2021-12-05 18:09:01 +01:00
gridEnt = grid.GridEntityId;
2021-12-05 18:09:01 +01:00
Assert.That(sEntities.TryGetComponent(gridEnt, out ShuttleComponent? shuttleComponent));
Assert.That(sEntities.TryGetComponent(gridEnt, out PhysicsComponent? physicsComponent));
Assert.That(physicsComponent!.BodyType, Is.EqualTo(BodyType.Dynamic));
2021-12-05 18:09:01 +01:00
Assert.That(sEntities.GetComponent<TransformComponent>(gridEnt).LocalPosition, Is.EqualTo(Vector2.Zero));
physicsComponent.ApplyLinearImpulse(Vector2.One);
});
await server.WaitRunTicks(1);
await server.WaitAssertion(() =>
{
2021-12-05 18:09:01 +01:00
Assert.That<Vector2?>(sEntities.GetComponent<TransformComponent>(gridEnt).LocalPosition, Is.Not.EqualTo(Vector2.Zero));
});
}
}
}