* Add test pooling * WIP test pooling changes * Fix Destructible tests * Don't pool unpooled or dummy ticker instances * Change ServerPathfindingDebugSystem to replace existing entries * Fix SaveLoadSaveTest comment * Don't pool StartTest * Comment out global setup * Fix puddle tests * Move SolarPanelComponent initialize to PowerSolarSystem OnMapInit * Update RobustToolbox * Finish fixing tests, make test threads background threads * Bring back pooling * Fix nullable * Update RobustToolbox * Set cvars on server return * Un-pool tests with custom cvars * Update RobustToolbox * Update RobustToolbox * Change where the main tile coordinates are * Remove DisposalUnitTest grid check * Fix test pooling being a fickle bitch * Fix EntitySystemExtensionsTest * Update RobustToolbox * Update RobustToolbox * Make nullable pool settings true * Update RobustToolbox * Wait other way around * We are unitystation now * Update RobustToolbox * Create global setup * Pool some more tests * Fix not properly disconnecting clients before restarting the round * Give more info on ran tests * Standardize default test cvars * Update RobustToolbox * Update RobustToolbox * Pool clients * Fix test order issue * Fix cvars in character creation test not being set properly * Update RobustToolbox * Update RobustToolbox * Rider shut * Update RobustToolbox * Format tests ran better * Update RobustToolbox * Reset RobustToolbox * Reset RobustToolbox harder * Fix one instance of test order causing destructible tests to fail
95 lines
3.7 KiB
C#
95 lines
3.7 KiB
C#
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Content.Server.Destructible.Thresholds;
|
|
using Content.Server.Destructible.Thresholds.Behaviors;
|
|
using Content.Shared.Damage;
|
|
using Content.Shared.Damage.Prototypes;
|
|
using NUnit.Framework;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Map;
|
|
using Robust.Shared.Prototypes;
|
|
using static Content.IntegrationTests.Tests.Destructible.DestructibleTestPrototypes;
|
|
|
|
namespace Content.IntegrationTests.Tests.Destructible
|
|
{
|
|
public class DestructibleDestructionTest : ContentIntegrationTest
|
|
{
|
|
[Test]
|
|
public async Task Test()
|
|
{
|
|
var server = StartServer(new ServerContentIntegrationOption
|
|
{
|
|
ExtraPrototypes = Prototypes
|
|
});
|
|
|
|
await server.WaitIdleAsync();
|
|
|
|
var sEntityManager = server.ResolveDependency<IEntityManager>();
|
|
var sMapManager = server.ResolveDependency<IMapManager>();
|
|
var sPrototypeManager = server.ResolveDependency<IPrototypeManager>();
|
|
var sEntitySystemManager = server.ResolveDependency<IEntitySystemManager>();
|
|
|
|
IEntity sDestructibleEntity = null;
|
|
DamageableComponent sDamageableComponent = null;
|
|
TestDestructibleListenerSystem sTestThresholdListenerSystem = null;
|
|
|
|
await server.WaitPost(() =>
|
|
{
|
|
var gridId = GetMainGrid(sMapManager).GridEntityId;
|
|
var coordinates = new EntityCoordinates(gridId, 0, 0);
|
|
|
|
sDestructibleEntity = sEntityManager.SpawnEntity(DestructibleDestructionEntityId, coordinates);
|
|
sDamageableComponent = sDestructibleEntity.GetComponent<DamageableComponent>();
|
|
sTestThresholdListenerSystem = sEntitySystemManager.GetEntitySystem<TestDestructibleListenerSystem>();
|
|
});
|
|
|
|
await server.WaitAssertion(() =>
|
|
{
|
|
var coordinates = sDestructibleEntity.Transform.Coordinates;
|
|
var bruteDamageGroup = sPrototypeManager.Index<DamageGroupPrototype>("TestBrute");
|
|
DamageSpecifier bruteDamage = new(bruteDamageGroup,50);
|
|
|
|
Assert.DoesNotThrow(() =>
|
|
{
|
|
EntitySystem.Get<DamageableSystem>().TryChangeDamage(sDestructibleEntity.Uid, bruteDamage, true);
|
|
});
|
|
|
|
Assert.That(sTestThresholdListenerSystem.ThresholdsReached.Count, Is.EqualTo(1));
|
|
|
|
var threshold = sTestThresholdListenerSystem.ThresholdsReached[0].Threshold;
|
|
|
|
Assert.That(threshold.Triggered, Is.True);
|
|
Assert.That(threshold.Behaviors.Count, Is.EqualTo(3));
|
|
|
|
var spawnEntitiesBehavior = (SpawnEntitiesBehavior) threshold.Behaviors.Single(b => b is SpawnEntitiesBehavior);
|
|
|
|
Assert.That(spawnEntitiesBehavior.Spawn.Count, Is.EqualTo(1));
|
|
Assert.That(spawnEntitiesBehavior.Spawn.Keys.Single(), Is.EqualTo(SpawnedEntityId));
|
|
Assert.That(spawnEntitiesBehavior.Spawn.Values.Single(), Is.EqualTo(new MinMax {Min = 1, Max = 1}));
|
|
|
|
var entitiesInRange = IoCManager.Resolve<IEntityLookup>().GetEntitiesInRange(coordinates, 2);
|
|
var found = false;
|
|
|
|
foreach (var entity in entitiesInRange)
|
|
{
|
|
if (entity.Prototype == null)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
if (entity.Prototype.Name != SpawnedEntityId)
|
|
{
|
|
continue;
|
|
}
|
|
|
|
found = true;
|
|
break;
|
|
}
|
|
|
|
Assert.That(found, Is.True);
|
|
});
|
|
}
|
|
}
|
|
}
|