Fix content.integration tests warnings (#17817)

Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
TemporalOroboros
2023-07-05 21:54:25 -07:00
committed by GitHub
parent 20c1754abd
commit ba91023a85
121 changed files with 3658 additions and 1961 deletions

View File

@@ -1,11 +1,9 @@
#nullable enable
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Ghost.Roles;
using Content.Server.Ghost.Roles.Components;
using Content.Server.Mind;
using Content.Server.Players;
using NUnit.Framework;
using Robust.Shared.Console;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
@@ -31,7 +29,7 @@ public sealed class GhostRoleTests
[Test]
public async Task TakeRoleAndReturn()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings {ExtraPrototypes = Prototypes});
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { ExtraPrototypes = Prototypes });
var server = pairTracker.Pair.Server;
var client = pairTracker.Pair.Client;

View File

@@ -1,9 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Ghost.Components;
using Content.Server.Mind;
using Content.Server.Players;
using NUnit.Framework;
using Robust.Server.Console;
using Robust.Server.GameObjects;
using Robust.Server.Player;
@@ -45,17 +43,22 @@ public sealed partial class MindTests
mindSystem.TransferTo(mind, playerEnt);
mindSystem.Visit(mind, visitEnt);
Assert.That(player.AttachedEntity, Is.EqualTo(visitEnt));
Assert.That(mind.VisitingEntity, Is.EqualTo(visitEnt));
Assert.Multiple(() =>
{
Assert.That(player.AttachedEntity, Is.EqualTo(visitEnt));
Assert.That(mind.VisitingEntity, Is.EqualTo(visitEnt));
});
});
await PoolManager.RunTicksSync(pairTracker.Pair, 5);
await server.WaitPost(() => entMan.DeleteEntity(visitEnt));
await PoolManager.RunTicksSync(pairTracker.Pair, 5);
Assert.IsNull(mind.VisitingEntity);
#pragma warning disable NUnit2045 // Interdependent assertions.
Assert.That(mind.VisitingEntity, Is.Null);
Assert.That(entMan.EntityExists(mind.OwnedEntity));
Assert.That(mind.OwnedEntity, Is.EqualTo(playerEnt));
#pragma warning restore NUnit2045
// This used to throw so make sure it doesn't.
await server.WaitPost(() => entMan.DeleteEntity(mind.OwnedEntity!.Value));
@@ -97,8 +100,10 @@ public sealed partial class MindTests
await server.WaitAssertion(() =>
{
Assert.That(entMan.EntityExists(mind.CurrentEntity!.Value), Is.True);
#pragma warning disable NUnit2045 // Interdependent assertions.
Assert.That(entMan.EntityExists(mind.CurrentEntity), Is.True);
Assert.That(mind.CurrentEntity, Is.Not.EqualTo(playerEnt));
#pragma warning restore NUnit2045
});
await pairTracker.CleanReturnAsync();
@@ -119,7 +124,7 @@ public sealed partial class MindTests
var entMan = server.ResolveDependency<IServerEntityManager>();
var playerMan = server.ResolveDependency<IPlayerManager>();
IPlayerSession player = playerMan.ServerSessions.Single();
var player = playerMan.ServerSessions.Single();
Assert.That(!entMan.HasComponent<GhostComponent>(player.AttachedEntity), "Player was initially a ghost?");
@@ -154,8 +159,10 @@ public sealed partial class MindTests
var mind = GetMind(pairTracker.Pair);
var player = playerMan.ServerSessions.Single();
Assert.NotNull(player.AttachedEntity);
#pragma warning disable NUnit2045 // Interdependent assertions.
Assert.That(player.AttachedEntity, Is.Not.Null);
Assert.That(entMan.EntityExists(player.AttachedEntity));
#pragma warning restore NUnit2045
var originalEntity = player.AttachedEntity.Value;
EntityUid ghost = default!;
@@ -165,10 +172,13 @@ public sealed partial class MindTests
mindSystem.Visit(mind, ghost);
});
Assert.That(player.AttachedEntity, Is.EqualTo(ghost));
Assert.That(entMan.HasComponent<GhostComponent>(player.AttachedEntity), "player is not a ghost");
Assert.That(mind.VisitingEntity, Is.EqualTo(player.AttachedEntity));
Assert.That(mind.OwnedEntity, Is.EqualTo(originalEntity));
Assert.Multiple(() =>
{
Assert.That(player.AttachedEntity, Is.EqualTo(ghost));
Assert.That(entMan.HasComponent<GhostComponent>(player.AttachedEntity), "player is not a ghost");
Assert.That(mind.VisitingEntity, Is.EqualTo(player.AttachedEntity));
Assert.That(mind.OwnedEntity, Is.EqualTo(originalEntity));
});
await PoolManager.RunTicksSync(pairTracker.Pair, 5);
await server.WaitAssertion(() => entMan.DeleteEntity(originalEntity));
@@ -178,10 +188,13 @@ public sealed partial class MindTests
// Check that the player is still in control of the ghost
mind = GetMind(pairTracker.Pair);
Assert.That(!entMan.Deleted(ghost), "ghost has been deleted");
Assert.That(player.AttachedEntity, Is.EqualTo(ghost));
Assert.That(entMan.HasComponent<GhostComponent>(player.AttachedEntity));
Assert.IsNull(mind.VisitingEntity);
Assert.That(mind.OwnedEntity, Is.EqualTo(ghost));
Assert.Multiple(() =>
{
Assert.That(player.AttachedEntity, Is.EqualTo(ghost));
Assert.That(entMan.HasComponent<GhostComponent>(player.AttachedEntity));
Assert.That(mind.VisitingEntity, Is.Null);
Assert.That(mind.OwnedEntity, Is.EqualTo(ghost));
});
await pairTracker.CleanReturnAsync();
}
@@ -213,13 +226,16 @@ public sealed partial class MindTests
await PoolManager.RunTicksSync(pairTracker.Pair, 5);
Assert.That(entMan.Deleted(ghost), "old ghost was not deleted");
Assert.That(player.AttachedEntity, Is.Not.EqualTo(ghost), "Player is still attached to the old ghost");
Assert.That(entMan.HasComponent<GhostComponent>(player.AttachedEntity!.Value), "Player did not become a new ghost");
Assert.That(entMan.GetComponent<MetaDataComponent>(player.AttachedEntity.Value).EntityPrototype?.ID, Is.EqualTo("AdminObserver"));
Assert.Multiple(() =>
{
Assert.That(player.AttachedEntity, Is.Not.EqualTo(ghost), "Player is still attached to the old ghost");
Assert.That(entMan.HasComponent<GhostComponent>(player.AttachedEntity), "Player did not become a new ghost");
Assert.That(entMan.GetComponent<MetaDataComponent>(player.AttachedEntity!.Value).EntityPrototype?.ID, Is.EqualTo("AdminObserver"));
});
var mind = player.ContentData()?.Mind;
Assert.NotNull(mind);
Assert.Null(mind.VisitingEntity);
Assert.That(mind, Is.Not.Null);
Assert.That(mind.VisitingEntity, Is.Null);
await pairTracker.CleanReturnAsync();
}
@@ -241,7 +257,7 @@ public sealed partial class MindTests
var playerMan = server.ResolveDependency<IPlayerManager>();
var serverConsole = server.ResolveDependency<IServerConsoleHost>();
IPlayerSession player = playerMan.ServerSessions.Single();
var player = playerMan.ServerSessions.Single();
EntityUid ghost = default!;
@@ -272,9 +288,11 @@ public sealed partial class MindTests
await server.WaitAssertion(() =>
{
#pragma warning disable NUnit2045 // Interdependent assertions.
Assert.That(entMan.Deleted(ghost));
Assert.That(player.AttachedEntity, Is.Not.EqualTo(ghost));
Assert.That(entMan.HasComponent<GhostComponent>(player.AttachedEntity!.Value));
#pragma warning restore NUnit2045
});
await pairTracker.CleanReturnAsync();

View File

@@ -1,9 +1,7 @@
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Ghost.Components;
using Content.Server.Mind;
using Content.Server.Players;
using NUnit.Framework;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.Enums;
@@ -25,7 +23,7 @@ public sealed partial class MindTests
/// the player's mind's current entity, likely because some previous test directly changed the players attached
/// entity.
/// </remarks>
public async Task<PairTracker> SetupPair()
private static async Task<PairTracker> SetupPair()
{
var pairTracker = await PoolManager.GetServerClient();
var pair = pairTracker.Pair;
@@ -47,15 +45,18 @@ public sealed partial class MindTests
await PoolManager.RunTicksSync(pair, 5);
Assert.That(player.ContentData()?.Mind, Is.EqualTo(mind));
Assert.That(player.AttachedEntity, Is.EqualTo(entity));
Assert.That(player.AttachedEntity, Is.EqualTo(mind.CurrentEntity), "Player is not attached to the mind's current entity.");
Assert.That(entMan.EntityExists(mind.OwnedEntity), "The mind's current entity does not exist");
Assert.That(mind.VisitingEntity == null || entMan.EntityExists(mind.VisitingEntity), "The minds visited entity does not exist.");
Assert.Multiple(() =>
{
Assert.That(player.ContentData()?.Mind, Is.EqualTo(mind));
Assert.That(player.AttachedEntity, Is.EqualTo(entity));
Assert.That(player.AttachedEntity, Is.EqualTo(mind.CurrentEntity), "Player is not attached to the mind's current entity.");
Assert.That(entMan.EntityExists(mind.OwnedEntity), "The mind's current entity does not exist");
Assert.That(mind.VisitingEntity == null || entMan.EntityExists(mind.VisitingEntity), "The minds visited entity does not exist.");
});
return pairTracker;
}
public async Task<EntityUid> BecomeGhost(Pair pair, bool visit = false)
private static async Task<EntityUid> BecomeGhost(Pair pair, bool visit = false)
{
var entMan = pair.Server.ResolveDependency<IServerEntityManager>();
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
@@ -69,7 +70,7 @@ public sealed partial class MindTests
var oldUid = player.AttachedEntity;
ghostUid = entMan.SpawnEntity("MobObserver", MapCoordinates.Nullspace);
mind = mindSys.GetMind(player.UserId);
Assert.NotNull(mind);
Assert.That(mind, Is.Not.Null);
if (visit)
{
@@ -84,17 +85,20 @@ public sealed partial class MindTests
});
await PoolManager.RunTicksSync(pair, 5);
Assert.That(entMan.HasComponent<GhostComponent>(ghostUid));
Assert.That(player.AttachedEntity == ghostUid);
Assert.That(mind.CurrentEntity == ghostUid);
Assert.Multiple(() =>
{
Assert.That(entMan.HasComponent<GhostComponent>(ghostUid));
Assert.That(player.AttachedEntity, Is.EqualTo(ghostUid));
Assert.That(mind.CurrentEntity, Is.EqualTo(ghostUid));
});
if (!visit)
Assert.Null(mind.VisitingEntity);
Assert.That(mind.VisitingEntity, Is.Null);
return ghostUid;
}
public async Task<EntityUid> VisitGhost(Pair pair, bool visit = false)
private static async Task<EntityUid> VisitGhost(Pair pair, bool _ = false)
{
return await BecomeGhost(pair, visit: true);
}
@@ -102,23 +106,26 @@ public sealed partial class MindTests
/// <summary>
/// Get the player's current mind and check that the entities exists.
/// </summary>
public Mind GetMind(Pair pair)
private static Mind GetMind(Pair pair)
{
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var entMan = pair.Server.ResolveDependency<IEntityManager>();
var player = playerMan.ServerSessions.SingleOrDefault();
Assert.NotNull(player);
Assert.That(player, Is.Not.Null);
var mind = player.ContentData()!.Mind;
Assert.NotNull(mind);
Assert.That(player.AttachedEntity, Is.EqualTo(mind.CurrentEntity), "Player is not attached to the mind's current entity.");
Assert.That(entMan.EntityExists(mind.OwnedEntity), "The mind's current entity does not exist");
Assert.That(mind.VisitingEntity == null || entMan.EntityExists(mind.VisitingEntity), "The minds visited entity does not exist.");
Assert.That(mind, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(player.AttachedEntity, Is.EqualTo(mind.CurrentEntity), "Player is not attached to the mind's current entity.");
Assert.That(entMan.EntityExists(mind.OwnedEntity), "The mind's current entity does not exist");
Assert.That(mind.VisitingEntity == null || entMan.EntityExists(mind.VisitingEntity), "The minds visited entity does not exist.");
});
return mind;
}
public async Task Disconnect(Pair pair)
private static async Task Disconnect(Pair pair)
{
var netManager = pair.Client.ResolveDependency<IClientNetManager>();
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
@@ -131,12 +138,15 @@ public sealed partial class MindTests
});
await PoolManager.RunTicksSync(pair, 5);
Assert.That(player.Status == SessionStatus.Disconnected);
Assert.NotNull(mind.UserId);
Assert.Null(mind.Session);
Assert.Multiple(() =>
{
Assert.That(player.Status, Is.EqualTo(SessionStatus.Disconnected));
Assert.That(mind.UserId, Is.Not.Null);
Assert.That(mind.Session, Is.Null);
});
}
public async Task Connect(Pair pair, string username)
private static async Task Connect(Pair pair, string username)
{
var netManager = pair.Client.ResolveDependency<IClientNetManager>();
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
@@ -148,10 +158,10 @@ public sealed partial class MindTests
await PoolManager.RunTicksSync(pair, 5);
var player = playerMan.ServerSessions.Single();
Assert.That(player.Status == SessionStatus.InGame);
Assert.That(player.Status, Is.EqualTo(SessionStatus.InGame));
}
public async Task<IPlayerSession> DisconnectReconnect(Pair pair)
private static async Task<IPlayerSession> DisconnectReconnect(Pair pair)
{
var playerMan = pair.Server.ResolveDependency<IPlayerManager>();
var player = playerMan.ServerSessions.Single();
@@ -163,8 +173,11 @@ public sealed partial class MindTests
// Session has changed
var newSession = playerMan.ServerSessions.Single();
Assert.That(newSession != player);
Assert.That(newSession.UserId == id);
Assert.Multiple(() =>
{
Assert.That(newSession, Is.Not.EqualTo(player));
Assert.That(newSession.UserId, Is.EqualTo(id));
});
return newSession;
}

View File

@@ -1,8 +1,6 @@
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Ghost.Components;
using Content.Server.Mind;
using NUnit.Framework;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
@@ -28,10 +26,13 @@ public sealed partial class MindTests
await DisconnectReconnect(pair);
// Player in control of a new ghost, but with the same mind
Assert.That(GetMind(pair) == mind);
Assert.That(entMan.Deleted(ghost));
Assert.That(entMan.HasComponent<GhostComponent>(mind.OwnedEntity));
Assert.Null(mind.VisitingEntity);
Assert.Multiple(() =>
{
Assert.That(GetMind(pair), Is.EqualTo(mind));
Assert.That(entMan.Deleted(ghost));
Assert.That(entMan.HasComponent<GhostComponent>(mind.OwnedEntity));
Assert.That(mind.VisitingEntity, Is.Null);
});
await pairTracker.CleanReturnAsync();
}
@@ -53,7 +54,7 @@ public sealed partial class MindTests
var player = playerMan.ServerSessions.Single();
var name = player.Name;
var user = player.UserId;
Assert.NotNull(mind.OwnedEntity);
Assert.That(mind.OwnedEntity, Is.Not.Null);
var entity = mind.OwnedEntity.Value;
// Player is not a ghost
@@ -65,18 +66,24 @@ public sealed partial class MindTests
// Delete entity
Assert.That(entMan.EntityExists(entity));
await pair.Server.WaitPost(() => entMan.DeleteEntity(entity));
Assert.That(entMan.Deleted(entity));
Assert.IsNull(mind.OwnedEntity);
Assert.Multiple(() =>
{
Assert.That(entMan.Deleted(entity));
Assert.That(mind.OwnedEntity, Is.Null);
});
// Reconnect
await Connect(pair, name);
player = playerMan.ServerSessions.Single();
Assert.That(user, Is.EqualTo(player.UserId));
Assert.Multiple(() =>
{
Assert.That(user, Is.EqualTo(player.UserId));
// Player is now a new ghost entity
Assert.That(GetMind(pair), Is.EqualTo(mind));
Assert.That(mind.OwnedEntity, Is.Not.EqualTo(entity));
Assert.That(entMan.HasComponent<GhostComponent>(mind.OwnedEntity));
// Player is now a new ghost entity
Assert.That(GetMind(pair), Is.EqualTo(mind));
Assert.That(mind.OwnedEntity, Is.Not.EqualTo(entity));
Assert.That(entMan.HasComponent<GhostComponent>(mind.OwnedEntity));
});
await pairTracker.CleanReturnAsync();
}
@@ -99,10 +106,13 @@ public sealed partial class MindTests
await DisconnectReconnect(pair);
// Player now controls their original mob, mind was preserved
Assert.That(mind, Is.EqualTo(GetMind(pair)));
Assert.That(mind.CurrentEntity, Is.EqualTo(original));
Assert.That(!entMan.Deleted(original));
Assert.That(entMan.Deleted(ghost));
Assert.Multiple(() =>
{
Assert.That(mind, Is.EqualTo(GetMind(pair)));
Assert.That(mind.CurrentEntity, Is.EqualTo(original));
Assert.That(entMan.Deleted(original), Is.False);
Assert.That(entMan.Deleted(ghost));
});
await pairTracker.CleanReturnAsync();
}
@@ -134,11 +144,13 @@ public sealed partial class MindTests
await DisconnectReconnect(pair);
// Player is back in control of the visited mob, mind was preserved
Assert.That(mind == GetMind(pair));
Assert.That(!entMan.Deleted(original));
Assert.That(!entMan.Deleted(visiting));
Assert.That(mind.CurrentEntity == visiting);
Assert.That(mind.CurrentEntity == visiting);
Assert.Multiple(() =>
{
Assert.That(GetMind(pair), Is.EqualTo(mind));
Assert.That(entMan.Deleted(original), Is.False);
Assert.That(entMan.Deleted(visiting), Is.False);
Assert.That(mind.CurrentEntity, Is.EqualTo(visiting));
});
await pairTracker.CleanReturnAsync();
}

View File

@@ -1,7 +1,5 @@
#nullable enable
using System;
using System.Linq;
using System.Threading.Tasks;
using Content.Server.Ghost;
using Content.Server.Ghost.Roles;
using Content.Server.Mind;
@@ -9,19 +7,15 @@ using Content.Server.Mind.Commands;
using Content.Server.Mind.Components;
using Content.Server.Players;
using Content.Server.Roles;
using Content.Server.Traitor;
using Content.Shared.Damage;
using Content.Shared.Damage.Prototypes;
using Content.Shared.FixedPoint;
using Content.Shared.Roles;
using NUnit.Framework;
using Robust.Server.Console;
using Robust.Server.GameObjects;
using Robust.Server.Player;
using Robust.Shared.GameObjects;
using Robust.Shared.IoC;
using Robust.Shared.Map;
using Robust.Shared.Network;
using Robust.Shared.Prototypes;
using IPlayerManager = Robust.Server.Player.IPlayerManager;
@@ -59,7 +53,7 @@ public sealed partial class MindTests
[Test]
public async Task TestCreateAndTransferMindToNewEntity()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{ NoClient = true });
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server;
var entMan = server.ResolveDependency<IServerEntityManager>();
@@ -85,7 +79,7 @@ public sealed partial class MindTests
[Test]
public async Task TestReplaceMind()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{ NoClient = true });
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server;
var entMan = server.ResolveDependency<IServerEntityManager>();
@@ -103,8 +97,11 @@ public sealed partial class MindTests
var mind2 = mindSystem.CreateMind(null);
mindSystem.TransferTo(mind2, entity);
Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(mind2));
Assert.That(mind.OwnedEntity != entity);
Assert.Multiple(() =>
{
Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(mind2));
Assert.That(mind.OwnedEntity, Is.Not.EqualTo(entity));
});
});
await pairTracker.CleanReturnAsync();
@@ -113,7 +110,7 @@ public sealed partial class MindTests
[Test]
public async Task TestEntityDeadWhenGibbed()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{ NoClient = true, ExtraPrototypes = Prototypes });
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true, ExtraPrototypes = Prototypes });
var server = pairTracker.Pair.Server;
var entMan = server.ResolveDependency<IServerEntityManager>();
@@ -133,8 +130,11 @@ public sealed partial class MindTests
mind = mindSystem.CreateMind(null);
mindSystem.TransferTo(mind, entity);
Assert.That(mindSystem.GetMind(entity, mindContainerComp), Is.EqualTo(mind));
Assert.That(!mindSystem.IsCharacterDeadPhysically(mind));
Assert.Multiple(() =>
{
Assert.That(mindSystem.GetMind(entity, mindContainerComp), Is.EqualTo(mind));
Assert.That(!mindSystem.IsCharacterDeadPhysically(mind));
});
});
await PoolManager.RunTicksSync(pairTracker.Pair, 5);
@@ -164,7 +164,7 @@ public sealed partial class MindTests
[Test]
public async Task TestMindTransfersToOtherEntity()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{ NoClient = true });
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server;
var entMan = server.ResolveDependency<IServerEntityManager>();
@@ -185,8 +185,11 @@ public sealed partial class MindTests
Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(mind));
mindSystem.TransferTo(mind, targetEntity);
Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(null));
Assert.That(mindSystem.GetMind(targetEntity), Is.EqualTo(mind));
Assert.Multiple(() =>
{
Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(null));
Assert.That(mindSystem.GetMind(targetEntity), Is.EqualTo(mind));
});
});
await pairTracker.CleanReturnAsync();
@@ -214,8 +217,11 @@ public sealed partial class MindTests
mind = mindSystem.CreateMind(null);
mindSystem.TransferTo(mind, entity);
Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(mind));
Assert.That(mindComp.HasMind);
Assert.Multiple(() =>
{
Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(mind));
Assert.That(mindComp.HasMind);
});
});
await PoolManager.RunTicksSync(pairTracker.Pair, 5);
@@ -223,12 +229,18 @@ public sealed partial class MindTests
await server.WaitAssertion(() =>
{
mindSystem.SetUserId(mind, userId);
Assert.That(mind.UserId, Is.EqualTo(userId));
Assert.That(originalMind.UserId, Is.EqualTo(null));
Assert.Multiple(() =>
{
Assert.That(mind.UserId, Is.EqualTo(userId));
Assert.That(originalMind.UserId, Is.EqualTo(null));
});
mindSystem.SetUserId(originalMind, userId);
Assert.That(mind.UserId, Is.EqualTo(null));
Assert.That(originalMind.UserId, Is.EqualTo(userId));
Assert.Multiple(() =>
{
Assert.That(mind.UserId, Is.EqualTo(null));
Assert.That(originalMind.UserId, Is.EqualTo(userId));
});
});
await PoolManager.RunTicksSync(pairTracker.Pair, 5);
@@ -239,7 +251,7 @@ public sealed partial class MindTests
[Test]
public async Task TestAddRemoveHasRoles()
{
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings{ NoClient = true });
await using var pairTracker = await PoolManager.GetServerClient(new PoolSettings { NoClient = true });
var server = pairTracker.Pair.Server;
var entMan = server.ResolveDependency<IServerEntityManager>();
@@ -258,32 +270,47 @@ public sealed partial class MindTests
mindSystem.TransferTo(mind, entity);
Assert.That(mindSystem.GetMind(entity, mindComp), Is.EqualTo(mind));
Assert.That(!mindSystem.HasRole<TraitorRole>(mind));
Assert.That(!mindSystem.HasRole<Job>(mind));
Assert.Multiple(() =>
{
Assert.That(mindSystem.HasRole<TraitorRole>(mind), Is.False);
Assert.That(mindSystem.HasRole<Job>(mind), Is.False);
});
var traitorRole = new TraitorRole(mind, new AntagPrototype());
mindSystem.AddRole(mind, traitorRole);
Assert.That(mindSystem.HasRole<TraitorRole>(mind));
Assert.That(!mindSystem.HasRole<Job>(mind));
Assert.Multiple(() =>
{
Assert.That(mindSystem.HasRole<TraitorRole>(mind));
Assert.That(mindSystem.HasRole<Job>(mind), Is.False);
});
var jobRole = new Job(mind, new JobPrototype());
mindSystem.AddRole(mind, jobRole);
Assert.That(mindSystem.HasRole<TraitorRole>(mind));
Assert.That(mindSystem.HasRole<Job>(mind));
Assert.Multiple(() =>
{
Assert.That(mindSystem.HasRole<TraitorRole>(mind));
Assert.That(mindSystem.HasRole<Job>(mind));
});
mindSystem.RemoveRole(mind, traitorRole);
Assert.That(!mindSystem.HasRole<TraitorRole>(mind));
Assert.That(mindSystem.HasRole<Job>(mind));
Assert.Multiple(() =>
{
Assert.That(mindSystem.HasRole<TraitorRole>(mind), Is.False);
Assert.That(mindSystem.HasRole<Job>(mind));
});
mindSystem.RemoveRole(mind, jobRole);
Assert.That(!mindSystem.HasRole<TraitorRole>(mind));
Assert.That(!mindSystem.HasRole<Job>(mind));
Assert.Multiple(() =>
{
Assert.That(mindSystem.HasRole<TraitorRole>(mind), Is.False);
Assert.That(mindSystem.HasRole<Job>(mind), Is.False);
});
});
await pairTracker.CleanReturnAsync();
@@ -304,7 +331,7 @@ public sealed partial class MindTests
EntityUid entity = default!;
Mind mind = default!;
IPlayerSession player = playerMan.ServerSessions.Single();
var player = playerMan.ServerSessions.Single();
await server.WaitAssertion(() =>
{
@@ -333,7 +360,7 @@ public sealed partial class MindTests
await server.WaitAssertion(() =>
{
Assert.That(mind.OwnedEntity != null);
Assert.That(mind.OwnedEntity, Is.Not.Null);
mob = entMan.SpawnEntity(null, new MapCoordinates());
@@ -349,9 +376,12 @@ public sealed partial class MindTests
await server.WaitAssertion(() =>
{
var m = player.ContentData()?.Mind;
Assert.That(m, Is.Not.EqualTo(null));
Assert.That(m!.OwnedEntity, Is.EqualTo(mob));
Assert.That(m, Is.Not.EqualTo(mind));
Assert.That(m, Is.Not.Null);
Assert.Multiple(() =>
{
Assert.That(m!.OwnedEntity, Is.EqualTo(mob));
Assert.That(m, Is.Not.EqualTo(mind));
});
});
await pairTracker.CleanReturnAsync();
@@ -376,11 +406,11 @@ public sealed partial class MindTests
var mindSystem = entMan.EntitySysManager.GetEntitySystem<MindSystem>();
EntityUid entity = default!;
//EntityUid entity = default!;
EntityUid mouse = default!;
EntityUid ghost = default!;
Mind mind = default!;
IPlayerSession player = playerMan.ServerSessions.Single();
var player = playerMan.ServerSessions.Single();
await server.WaitAssertion(() =>
{
@@ -399,7 +429,7 @@ public sealed partial class MindTests
Assert.That(data?.Mind, Is.Not.EqualTo(null));
mind = data!.Mind!;
Assert.That(mind.OwnedEntity != null);
Assert.That(mind.OwnedEntity, Is.Not.Null);
mouse = entMan.SpawnEntity("MobMouse", new MapCoordinates());
});
@@ -423,10 +453,10 @@ public sealed partial class MindTests
await server.WaitAssertion(() =>
{
var data = player.ContentData()!;
Assert.That(data.Mind!.OwnedEntity == mouse);
Assert.That(data.Mind!.OwnedEntity, Is.EqualTo(mouse));
serverConsole.ExecuteCommand(player, "aghost");
Assert.That(player.AttachedEntity != null);
Assert.That(player.AttachedEntity, Is.Not.Null);
ghost = player.AttachedEntity!.Value;
});
@@ -434,8 +464,8 @@ public sealed partial class MindTests
await server.WaitAssertion(() =>
{
Assert.That(player.AttachedEntity != null);
Assert.That(ghost == player.AttachedEntity!.Value);
Assert.That(player.AttachedEntity, Is.Not.Null);
Assert.That(player.AttachedEntity!.Value, Is.EqualTo(ghost));
});
await pairTracker.CleanReturnAsync();