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