* Give .props files 2-space indents.
* Move to Central Package Management.
Allows us to store NuGet package versions all in one place. Yay!
* Update NuGet packages and fix code for changes.
Notable:
Changes to ILVerify.
Npgsql doesn't need hacks for inet anymore, now we need hacks to make the old code work with this new reality.
NUnit's analyzers are already complaining and I didn't even update it to 4.x yet.
TerraFX changed to GetLastSystemError so error handling had to be changed.
Buncha APIs have more NRT annotations.
* Remove dotnet-eng NuGet package source.
I genuinely don't know what this was for, and Central Package Management starts throwing warnings about it, so YEET.
* Remove Robust.Physics project.
Never used.
* Remove erroneous NVorbis reference.
Should be VorbisPizza and otherwise wasn't used.
* Sandbox fixes
* Remove unused unit test package references.
Castle.Core and NUnit.ConsoleRunner.
* Update NUnit to 4.0.1
This requires replacing all the old assertion methods because they removed them 🥲
* Oh so that's what dotnet-eng was used for. Yeah ok that makes sense.
* Add Robust.Analyzers.Test
* Update submodule
* commit to re-run CI
71 lines
3.1 KiB
C#
71 lines
3.1 KiB
C#
using System.Linq;
|
|
using Content.Shared.Actions;
|
|
using Content.Shared.CombatMode;
|
|
using Robust.Server.Player;
|
|
using Robust.Shared.GameObjects;
|
|
|
|
namespace Content.IntegrationTests.Tests.Actions;
|
|
|
|
/// <summary>
|
|
/// This tests checks that actions properly get added to an entity's actions component..
|
|
/// </summary>
|
|
[TestFixture]
|
|
public sealed class ActionsAddedTest
|
|
{
|
|
// TODO add magboot test (inventory action)
|
|
// TODO add ghost toggle-fov test (client-side action)
|
|
|
|
[Test]
|
|
public async Task TestCombatActionsAdded()
|
|
{
|
|
await using var pair = await PoolManager.GetServerClient(new PoolSettings { Connected = true, DummyTicker = false});
|
|
var server = pair.Server;
|
|
var client = pair.Client;
|
|
var sEntMan = server.ResolveDependency<IEntityManager>();
|
|
var cEntMan = client.ResolveDependency<IEntityManager>();
|
|
var clientSession = client.ResolveDependency<Robust.Client.Player.IPlayerManager>().LocalPlayer?.Session;
|
|
var serverSession = server.ResolveDependency<IPlayerManager>().Sessions.Single();
|
|
var sActionSystem = server.System<SharedActionsSystem>();
|
|
var cActionSystem = client.System<SharedActionsSystem>();
|
|
|
|
// Dummy ticker is disabled - client should be in control of a normal mob.
|
|
Assert.That(serverSession.AttachedEntity, Is.Not.Null);
|
|
var serverEnt = serverSession.AttachedEntity!.Value;
|
|
var clientEnt = clientSession!.AttachedEntity!.Value;
|
|
Assert.That(sEntMan.EntityExists(serverEnt));
|
|
Assert.That(cEntMan.EntityExists(clientEnt));
|
|
Assert.That(sEntMan.HasComponent<ActionsComponent>(serverEnt));
|
|
Assert.That(cEntMan.HasComponent<ActionsComponent>(clientEnt));
|
|
Assert.That(sEntMan.HasComponent<CombatModeComponent>(serverEnt));
|
|
Assert.That(cEntMan.HasComponent<CombatModeComponent>(clientEnt));
|
|
|
|
var sComp = sEntMan.GetComponent<ActionsComponent>(serverEnt);
|
|
var cComp = cEntMan.GetComponent<ActionsComponent>(clientEnt);
|
|
|
|
// Mob should have a combat-mode action.
|
|
// This action should have a non-null event both on the server & client.
|
|
var evType = typeof(ToggleCombatActionEvent);
|
|
|
|
var sActions = sActionSystem.GetActions(serverEnt).Where(
|
|
x => x.Comp is InstantActionComponent act && act.Event?.GetType() == evType).ToArray();
|
|
var cActions = cActionSystem.GetActions(clientEnt).Where(
|
|
x => x.Comp is InstantActionComponent act && act.Event?.GetType() == evType).ToArray();
|
|
|
|
Assert.That(sActions.Length, Is.EqualTo(1));
|
|
Assert.That(cActions.Length, Is.EqualTo(1));
|
|
|
|
var sAct = sActions[0].Comp;
|
|
var cAct = cActions[0].Comp;
|
|
|
|
Assert.That(sAct, Is.Not.Null);
|
|
Assert.That(cAct, Is.Not.Null);
|
|
|
|
// Finally, these two actions are not the same object
|
|
// required, because integration tests do not respect the [NonSerialized] attribute and will simply events by reference.
|
|
Assert.That(ReferenceEquals(sAct, cAct), Is.False);
|
|
Assert.That(ReferenceEquals(sAct.BaseEvent, cAct.BaseEvent), Is.False);
|
|
|
|
await pair.CleanReturnAsync();
|
|
}
|
|
}
|