Files
tbd-station-14/Content.IntegrationTests/Tests/GravityGridTest.cs
Acruid ca4fd649fe Massive Namespace Cleanup (#3120)
* Engine namespace changes.

* Automated remove redundant using statements.

* Simplified Graphics namespace.

* Apparently the container system stores full type names in the map file.😞 This updates those names.

* API Changes to LocalizationManager.LoadCulture.

* Update submodule to v0.3.2
2021-02-11 01:13:03 -08:00

73 lines
2.5 KiB
C#

using System.Threading.Tasks;
using Content.Server.GameObjects.Components.Gravity;
using Content.Server.GameObjects.Components.Power.ApcNetComponents;
using Content.Shared.GameObjects.Components.Gravity;
using Content.Shared.Utility;
using NUnit.Framework;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
namespace Content.IntegrationTests.Tests
{
/// Tests the behavior of GravityGeneratorComponent,
/// making sure that gravity is applied to the correct grids.
[TestFixture]
[TestOf(typeof(GravityGeneratorComponent))]
public class GravityGridTest : ContentIntegrationTest
{
private const string Prototypes = @"
- type: entity
name: GravityGeneratorDummy
id: GravityGeneratorDummy
components:
- type: GravityGenerator
- type: PowerReceiver
";
[Test]
public async Task Test()
{
var options = new ServerIntegrationOptions{ExtraPrototypes = Prototypes};
var server = StartServerDummyTicker(options);
IEntity generator = null;
IMapGrid grid1 = null;
IMapGrid grid2 = null;
// Create grids
server.Assert(() =>
{
var mapMan = IoCManager.Resolve<IMapManager>();
mapMan.CreateMap(new MapId(1));
grid1 = mapMan.CreateGrid(new MapId(1));
grid2 = mapMan.CreateGrid(new MapId(1));
var entityMan = IoCManager.Resolve<IEntityManager>();
generator = entityMan.SpawnEntity("GravityGeneratorDummy", grid2.ToCoordinates());
Assert.That(generator.HasComponent<GravityGeneratorComponent>());
Assert.That(generator.HasComponent<PowerReceiverComponent>());
var generatorComponent = generator.GetComponent<GravityGeneratorComponent>();
var powerComponent = generator.GetComponent<PowerReceiverComponent>();
Assert.That(generatorComponent.Status, Is.EqualTo(GravityGeneratorStatus.Unpowered));
powerComponent.NeedsPower = false;
});
server.RunTicks(1);
server.Assert(() =>
{
var generatorComponent = generator.GetComponent<GravityGeneratorComponent>();
Assert.That(generatorComponent.Status, Is.EqualTo(GravityGeneratorStatus.On));
Assert.That(!grid1.HasGravity);
Assert.That(grid2.HasGravity);
});
await server.WaitIdleAsync();
}
}
}