Fix content test warnings (#9865)
* Fix content test warnings * while I'm here * fix Co-authored-by: wrexbe <wrexbe@protonmail.com>
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.MobState;
|
||||
using Content.Server.Administration.Commands;
|
||||
using Content.Shared.Damage;
|
||||
using Content.Shared.Damage.Prototypes;
|
||||
@@ -7,7 +6,6 @@ using Content.Shared.FixedPoint;
|
||||
using Content.Shared.MobState.Components;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
@@ -39,6 +37,8 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
var entManager = server.ResolveDependency<IEntityManager>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var prototypeManager = server.ResolveDependency<IPrototypeManager>();
|
||||
var mobStateSystem = entManager.EntitySysManager.GetEntitySystem<Server.MobState.MobStateSystem>();
|
||||
var damSystem = entManager.EntitySysManager.GetEntitySystem<DamageableSystem>();
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
@@ -49,30 +49,31 @@ namespace Content.IntegrationTests.Tests.Commands
|
||||
// Sanity check
|
||||
Assert.True(entManager.TryGetComponent(human, out DamageableComponent damageable));
|
||||
Assert.True(entManager.TryGetComponent(human, out MobStateComponent mobState));
|
||||
Assert.That(mobState.IsAlive, Is.True);
|
||||
Assert.That(mobState.IsCritical, Is.False);
|
||||
Assert.That(mobState.IsDead, Is.False);
|
||||
Assert.That(mobState.IsIncapacitated, Is.False);
|
||||
Assert.That(mobStateSystem.IsAlive(human, mobState), Is.True);
|
||||
Assert.That(mobStateSystem.IsCritical(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsDead(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsIncapacitated(human, mobState), Is.False);
|
||||
|
||||
// Kill the entity
|
||||
DamageSpecifier damage = new(prototypeManager.Index<DamageGroupPrototype>("Toxin"),
|
||||
FixedPoint2.New(10000000));
|
||||
EntitySystem.Get<DamageableSystem>().TryChangeDamage(human, damage, true);
|
||||
|
||||
damSystem.TryChangeDamage(human, damage, true);
|
||||
|
||||
// Check that it is dead
|
||||
Assert.That(mobState.IsAlive, Is.False);
|
||||
Assert.That(mobState.IsCritical, Is.False);
|
||||
Assert.That(mobState.IsDead, Is.True);
|
||||
Assert.That(mobState.IsIncapacitated, Is.True);
|
||||
Assert.That(mobStateSystem.IsAlive(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsCritical(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsDead(human, mobState), Is.True);
|
||||
Assert.That(mobStateSystem.IsIncapacitated(human, mobState), Is.True);
|
||||
|
||||
// Rejuvenate them
|
||||
RejuvenateCommand.PerformRejuvenate(human);
|
||||
|
||||
// Check that it is alive and with no damage
|
||||
Assert.That(mobState.IsAlive, Is.True);
|
||||
Assert.That(mobState.IsCritical, Is.False);
|
||||
Assert.That(mobState.IsDead, Is.False);
|
||||
Assert.That(mobState.IsIncapacitated, Is.False);
|
||||
Assert.That(mobStateSystem.IsAlive(human, mobState), Is.True);
|
||||
Assert.That(mobStateSystem.IsCritical(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsDead(human, mobState), Is.False);
|
||||
Assert.That(mobStateSystem.IsIncapacitated(human, mobState), Is.False);
|
||||
|
||||
Assert.That(damageable.TotalDamage, Is.EqualTo(FixedPoint2.Zero));
|
||||
});
|
||||
|
||||
@@ -146,9 +146,10 @@ namespace Content.IntegrationTests.Tests
|
||||
foreach (var type in componentFactory.AllRegisteredTypes)
|
||||
{
|
||||
var component = (Component) componentFactory.GetComponent(type);
|
||||
var name = componentFactory.GetComponentName(type);
|
||||
|
||||
// If this component is ignored
|
||||
if (skipComponents.Contains(component.Name))
|
||||
if (skipComponents.Contains(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
@@ -166,13 +167,13 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
component.Owner = entity;
|
||||
|
||||
Logger.LogS(LogLevel.Debug, "EntityTest", $"Adding component: {component.Name}");
|
||||
Logger.LogS(LogLevel.Debug, "EntityTest", $"Adding component: {name}");
|
||||
|
||||
Assert.DoesNotThrow(() =>
|
||||
{
|
||||
entityManager.AddComponent(entity, component);
|
||||
}, "Component '{0}' threw an exception.",
|
||||
component.Name);
|
||||
name);
|
||||
|
||||
entityManager.DeleteEntity(entity);
|
||||
}
|
||||
@@ -282,15 +283,14 @@ namespace Content.IntegrationTests.Tests
|
||||
continue;
|
||||
}
|
||||
|
||||
var name = componentFactory.GetComponentName(component.GetType());
|
||||
|
||||
// If this component is ignored
|
||||
if (skipComponents.Contains(component.Name))
|
||||
{
|
||||
if (skipComponents.Contains(name))
|
||||
continue;
|
||||
}
|
||||
|
||||
component.Owner = entity;
|
||||
|
||||
Logger.LogS(LogLevel.Debug, "EntityTest", $"Adding component: {component.Name}");
|
||||
Logger.LogS(LogLevel.Debug, "EntityTest", $"Adding component: {name}");
|
||||
|
||||
// Note for the future coder: if an exception occurs where a component reference
|
||||
// was already occupied it might be because some component is ensuring another // initialize.
|
||||
@@ -300,7 +300,7 @@ namespace Content.IntegrationTests.Tests
|
||||
{
|
||||
entityManager.AddComponent(entity, component);
|
||||
}, "Component '{0}' threw an exception.",
|
||||
component.Name);
|
||||
name);
|
||||
}
|
||||
entityManager.DeleteEntity(entity);
|
||||
}
|
||||
|
||||
@@ -90,6 +90,7 @@ namespace Content.IntegrationTests.Tests.Fluids
|
||||
var sTileDefinitionManager = server.ResolveDependency<ITileDefinitionManager>();
|
||||
var sGameTiming = server.ResolveDependency<IGameTiming>();
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
var metaSystem = entityManager.EntitySysManager.GetEntitySystem<MetaDataSystem>();
|
||||
|
||||
MapId sMapId = default;
|
||||
IMapGrid sGrid;
|
||||
@@ -103,7 +104,7 @@ namespace Content.IntegrationTests.Tests.Fluids
|
||||
sMapManager.SetMapPaused(sMapId, true);
|
||||
sGrid = sMapManager.CreateGrid(sMapId);
|
||||
sGridId = sGrid.GridEntityId;
|
||||
entityManager.GetComponent<MetaDataComponent>(sGridId).EntityPaused = true; // See https://github.com/space-wizards/RobustToolbox/issues/1444
|
||||
metaSystem.SetEntityPaused(sGridId, true); // See https://github.com/space-wizards/RobustToolbox/issues/1444
|
||||
|
||||
var tileDefinition = sTileDefinitionManager["underplating"];
|
||||
var tile = new Tile(tileDefinition.TileId);
|
||||
@@ -140,8 +141,7 @@ namespace Content.IntegrationTests.Tests.Fluids
|
||||
Assert.NotNull(puddle);
|
||||
|
||||
evaporation = entityManager.GetComponent<EvaporationComponent>(puddle.Owner);
|
||||
|
||||
meta.EntityPaused = true; // See https://github.com/space-wizards/RobustToolbox/issues/1445
|
||||
metaSystem.SetEntityPaused(puddle.Owner, true, meta); // See https://github.com/space-wizards/RobustToolbox/issues/1445
|
||||
|
||||
Assert.True(meta.EntityPaused);
|
||||
|
||||
|
||||
@@ -307,6 +307,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var sysMan = server.ResolveDependency<IEntitySystemManager>();
|
||||
var handSys = sysMan.GetEntitySystem<SharedHandsSystem>();
|
||||
var conSystem = sysMan.GetEntitySystem<SharedContainerSystem>();
|
||||
|
||||
var mapId = MapId.Nullspace;
|
||||
var coords = MapCoordinates.Nullspace;
|
||||
@@ -332,7 +333,7 @@ namespace Content.IntegrationTests.Tests.Interaction.Click
|
||||
item = sEntities.SpawnEntity(null, coords);
|
||||
item.EnsureComponent<ItemComponent>();
|
||||
containerEntity = sEntities.SpawnEntity(null, coords);
|
||||
container = containerEntity.EnsureContainer<Container>("InteractionTestContainer");
|
||||
container = conSystem.EnsureContainer<Container>(containerEntity, "InteractionTestContainer");
|
||||
});
|
||||
|
||||
await server.WaitRunTicks(1);
|
||||
|
||||
@@ -30,12 +30,10 @@ namespace Content.IntegrationTests.Tests.Interaction
|
||||
|
||||
var sEntities = server.ResolveDependency<IEntityManager>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
var conSystem = sEntities.EntitySysManager.GetEntitySystem<SharedContainerSystem>();
|
||||
|
||||
EntityUid origin = default;
|
||||
EntityUid other = default;
|
||||
IContainer container = null;
|
||||
IComponent component = null;
|
||||
EntityCoordinates entityCoordinates = default;
|
||||
MapCoordinates mapCoordinates = default;
|
||||
|
||||
await server.WaitAssertion(() =>
|
||||
@@ -45,9 +43,7 @@ namespace Content.IntegrationTests.Tests.Interaction
|
||||
|
||||
origin = sEntities.SpawnEntity(HumanId, coordinates);
|
||||
other = sEntities.SpawnEntity(HumanId, coordinates);
|
||||
container = other.EnsureContainer<Container>("InRangeUnobstructedTestOtherContainer");
|
||||
component = sEntities.GetComponent<TransformComponent>(other);
|
||||
entityCoordinates = sEntities.GetComponent<TransformComponent>(other).Coordinates;
|
||||
conSystem.EnsureContainer<Container>(other, "InRangeUnobstructedTestOtherContainer");
|
||||
mapCoordinates = sEntities.GetComponent<TransformComponent>(other).MapPosition;
|
||||
});
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ namespace Content.IntegrationTests.Tests
|
||||
[TestFixture]
|
||||
public sealed class PostMapInitTest
|
||||
{
|
||||
public const bool SkipTestMaps = true;
|
||||
public const string TestMapsPath = "/Maps/Test/";
|
||||
private const bool SkipTestMaps = true;
|
||||
private const string TestMapsPath = "/Maps/Test/";
|
||||
|
||||
[Test]
|
||||
public async Task NoSavedPostMapInitTest()
|
||||
@@ -63,7 +63,7 @@ namespace Content.IntegrationTests.Tests
|
||||
|
||||
private static string[] GetMapNames()
|
||||
{
|
||||
Task<string[]> task = null;
|
||||
Task<string[]> task;
|
||||
using (ExecutionContext.SuppressFlow())
|
||||
{
|
||||
task = Task.Run(static async () =>
|
||||
@@ -99,7 +99,7 @@ namespace Content.IntegrationTests.Tests
|
||||
return task.GetAwaiter().GetResult();
|
||||
}
|
||||
|
||||
[Test, TestCaseSource("GetMapNames")]
|
||||
[Test, TestCaseSource(nameof(GetMapNames))]
|
||||
public async Task MapsLoadableTest(string mapName)
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{NoClient = true});
|
||||
|
||||
Reference in New Issue
Block a user