Fix content.integration tests warnings (#17817)
Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -1,13 +1,10 @@
|
||||
#nullable enable
|
||||
using System.Threading.Tasks;
|
||||
using Content.Server.Cuffs;
|
||||
using Content.Shared.Body.Components;
|
||||
using Content.Shared.Cuffs.Components;
|
||||
using Content.Shared.Hands.Components;
|
||||
using NUnit.Framework;
|
||||
using Robust.Server.Console;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
@@ -39,15 +36,18 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
public async Task Test()
|
||||
{
|
||||
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings
|
||||
{NoClient = true, ExtraPrototypes = Prototypes});
|
||||
{
|
||||
NoClient = true,
|
||||
ExtraPrototypes = Prototypes
|
||||
});
|
||||
var server = pairTracker.Pair.Server;
|
||||
|
||||
EntityUid human;
|
||||
EntityUid otherHuman;
|
||||
EntityUid cuffs;
|
||||
EntityUid secondCuffs;
|
||||
CuffableComponent cuffed;
|
||||
HandsComponent hands;
|
||||
CuffableComponent cuffed = default!;
|
||||
HandsComponent hands = default!;
|
||||
|
||||
var entityManager = server.ResolveDependency<IEntityManager>();
|
||||
var mapManager = server.ResolveDependency<IMapManager>();
|
||||
@@ -59,6 +59,8 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
var coordinates = new MapCoordinates(Vector2.Zero, mapId);
|
||||
|
||||
var cuffableSys = entityManager.System<CuffableSystem>();
|
||||
var xformSys = entityManager.System<SharedTransformSystem>();
|
||||
var xformQuery = entityManager.GetEntityQuery<TransformComponent>();
|
||||
|
||||
// Spawn the entities
|
||||
human = entityManager.SpawnEntity("HumanDummy", coordinates);
|
||||
@@ -66,38 +68,42 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.ActionBlocking
|
||||
cuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);
|
||||
secondCuffs = entityManager.SpawnEntity("HandcuffsDummy", coordinates);
|
||||
|
||||
entityManager.GetComponent<TransformComponent>(human).WorldPosition =
|
||||
entityManager.GetComponent<TransformComponent>(otherHuman).WorldPosition;
|
||||
var coords = xformSys.GetWorldPosition(otherHuman, xformQuery);
|
||||
xformSys.SetWorldPosition(human, coords, xformQuery);
|
||||
|
||||
// Test for components existing
|
||||
Assert.True(entityManager.TryGetComponent(human, out cuffed!),
|
||||
$"Human has no {nameof(CuffableComponent)}");
|
||||
Assert.True(entityManager.TryGetComponent(human, out hands!), $"Human has no {nameof(HandsComponent)}");
|
||||
Assert.True(entityManager.TryGetComponent(human, out BodyComponent? _), $"Human has no {nameof(BodyComponent)}");
|
||||
Assert.True(entityManager.TryGetComponent(cuffs, out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}");
|
||||
Assert.True(entityManager.TryGetComponent(secondCuffs, out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(entityManager.TryGetComponent(human, out cuffed!), $"Human has no {nameof(CuffableComponent)}");
|
||||
Assert.That(entityManager.TryGetComponent(human, out hands!), $"Human has no {nameof(HandsComponent)}");
|
||||
Assert.That(entityManager.TryGetComponent(human, out BodyComponent? _), $"Human has no {nameof(BodyComponent)}");
|
||||
Assert.That(entityManager.TryGetComponent(cuffs, out HandcuffComponent? _), $"Handcuff has no {nameof(HandcuffComponent)}");
|
||||
Assert.That(entityManager.TryGetComponent(secondCuffs, out HandcuffComponent? _), $"Second handcuffs has no {nameof(HandcuffComponent)}");
|
||||
});
|
||||
|
||||
// Test to ensure cuffed players register the handcuffs
|
||||
cuffableSys.TryAddNewCuffs(human, human, cuffs, cuffed);
|
||||
Assert.True(cuffed.CuffedHandCount > 0,
|
||||
"Handcuffing a player did not result in their hands being cuffed");
|
||||
Assert.That(cuffed.CuffedHandCount, Is.GreaterThan(0), "Handcuffing a player did not result in their hands being cuffed");
|
||||
|
||||
// Test to ensure a player with 4 hands will still only have 2 hands cuffed
|
||||
AddHand(human, host);
|
||||
AddHand(human, host);
|
||||
|
||||
Assert.That(cuffed.CuffedHandCount, Is.EqualTo(2));
|
||||
Assert.That(hands.SortedHands.Count, Is.EqualTo(4));
|
||||
Assert.Multiple(() =>
|
||||
{
|
||||
Assert.That(cuffed.CuffedHandCount, Is.EqualTo(2));
|
||||
Assert.That(hands.SortedHands, Has.Count.EqualTo(4));
|
||||
});
|
||||
|
||||
// Test to give a player with 4 hands 2 sets of cuffs
|
||||
cuffableSys.TryAddNewCuffs(human, human, secondCuffs, cuffed);
|
||||
Assert.True(cuffed.CuffedHandCount == 4, "Player doesn't have correct amount of hands cuffed");
|
||||
Assert.That(cuffed.CuffedHandCount, Is.EqualTo(4), "Player doesn't have correct amount of hands cuffed");
|
||||
});
|
||||
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
|
||||
private void AddHand(EntityUid to, IServerConsoleHost host)
|
||||
private static void AddHand(EntityUid to, IServerConsoleHost host)
|
||||
{
|
||||
host.ExecuteCommand(null, $"addhand {to}");
|
||||
}
|
||||
|
||||
@@ -1,10 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using NUnit.Framework;
|
||||
using Robust.Shared.ContentPack;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.Utility;
|
||||
@@ -103,16 +100,16 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components
|
||||
|
||||
var message = new StringBuilder();
|
||||
|
||||
foreach (var unknownComponent in unknownComponentsClient)
|
||||
foreach (var (entityId, component) in unknownComponentsClient)
|
||||
{
|
||||
message.Append(
|
||||
$"CLIENT: Unknown component {unknownComponent.component} in prototype {unknownComponent.entityId}\n");
|
||||
$"CLIENT: Unknown component {component} in prototype {entityId}\n");
|
||||
}
|
||||
|
||||
foreach (var unknownComponent in unknownComponentsServer)
|
||||
foreach (var (entityId, component) in unknownComponentsServer)
|
||||
{
|
||||
message.Append(
|
||||
$"SERVER: Unknown component {unknownComponent.component} in prototype {unknownComponent.entityId}\n");
|
||||
$"SERVER: Unknown component {component} in prototype {entityId}\n");
|
||||
}
|
||||
|
||||
Assert.Fail(message.ToString());
|
||||
@@ -140,7 +137,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components
|
||||
failureMessages = $"{failureMessages}\nComponent {serverIgnored} was ignored on server, but does not exist on client";
|
||||
}
|
||||
}
|
||||
Assert.IsEmpty(failureMessages);
|
||||
Assert.That(failureMessages, Is.Empty);
|
||||
await pairTracker.CleanReturnAsync();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using Content.Client.UserInterface.Systems.Alerts.Controls;
|
||||
using Content.Client.UserInterface.Systems.Alerts.Widgets;
|
||||
using Content.Shared.Alert;
|
||||
using NUnit.Framework;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.GameObjects;
|
||||
@@ -34,12 +32,14 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
await server.WaitAssertion(() =>
|
||||
{
|
||||
playerUid = serverPlayerManager.Sessions.Single().AttachedEntity.GetValueOrDefault();
|
||||
Assert.That(playerUid != default);
|
||||
#pragma warning disable NUnit2045 // Interdependent assertions.
|
||||
Assert.That(playerUid, Is.Not.EqualTo(default));
|
||||
// Making sure it exists
|
||||
Assert.That(entManager.HasComponent<AlertsComponent>(playerUid));
|
||||
#pragma warning restore NUnit2045
|
||||
|
||||
var alerts = alertsSystem.GetActiveAlerts(playerUid);
|
||||
Assert.IsNotNull(alerts);
|
||||
Assert.That(alerts, Is.Not.Null);
|
||||
var alertCount = alerts.Count;
|
||||
|
||||
alertsSystem.ShowAlert(playerUid, AlertType.Debug1);
|
||||
@@ -54,18 +54,20 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
await client.WaitAssertion(() =>
|
||||
{
|
||||
var local = clientPlayerMgr.LocalPlayer;
|
||||
Assert.NotNull(local);
|
||||
Assert.That(local, Is.Not.Null);
|
||||
var controlled = local.ControlledEntity;
|
||||
Assert.NotNull(controlled);
|
||||
#pragma warning disable NUnit2045 // Interdependent assertions.
|
||||
Assert.That(controlled, Is.Not.Null);
|
||||
// Making sure it exists
|
||||
Assert.That(clientEntManager.HasComponent<AlertsComponent>(controlled.Value));
|
||||
#pragma warning restore Nunit2045
|
||||
|
||||
// find the alertsui
|
||||
|
||||
clientAlertsUI = FindAlertsUI(clientUIMgr.ActiveScreen);
|
||||
Assert.NotNull(clientAlertsUI);
|
||||
Assert.That(clientAlertsUI, Is.Not.Null);
|
||||
|
||||
AlertsUI FindAlertsUI(Control control)
|
||||
static AlertsUI FindAlertsUI(Control control)
|
||||
{
|
||||
if (control is AlertsUI alertUI)
|
||||
return alertUI;
|
||||
@@ -83,7 +85,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
Assert.That(clientAlertsUI.AlertContainer.ChildCount, Is.GreaterThanOrEqualTo(3));
|
||||
var alertControls = clientAlertsUI.AlertContainer.Children.Select(c => (AlertControl) c);
|
||||
var alertIDs = alertControls.Select(ac => ac.Alert.AlertType).ToArray();
|
||||
var expectedIDs = new [] {AlertType.HumanHealth, AlertType.Debug1, AlertType.Debug2};
|
||||
var expectedIDs = new[] { AlertType.HumanHealth, AlertType.Debug1, AlertType.Debug2 };
|
||||
Assert.That(alertIDs, Is.SupersetOf(expectedIDs));
|
||||
});
|
||||
|
||||
@@ -100,7 +102,7 @@ namespace Content.IntegrationTests.Tests.GameObjects.Components.Mobs
|
||||
Assert.That(clientAlertsUI.AlertContainer.ChildCount, Is.GreaterThanOrEqualTo(2));
|
||||
var alertControls = clientAlertsUI.AlertContainer.Children.Select(c => (AlertControl) c);
|
||||
var alertIDs = alertControls.Select(ac => ac.Alert.AlertType).ToArray();
|
||||
var expectedIDs = new [] {AlertType.HumanHealth, AlertType.Debug2};
|
||||
var expectedIDs = new[] { AlertType.HumanHealth, AlertType.Debug2 };
|
||||
Assert.That(alertIDs, Is.SupersetOf(expectedIDs));
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user