Files
ss14-wega/Content.IntegrationTests/Tests/Commands/ObjectiveCommandsTest.cs
T
Moony d42adbf05d Gametest Part 2: Preliminary refactor every test to use GameTest as the framework. (#43207)
* Pass 1.

* i'm FREE

* Prevent hangups.

* okay fine here's an attribute for settings, will polish later and prolly remove the overridable thing.

* sigh.

* fix singular trigger bug so LatheTest doesn't flake.

* Remove SystemAttribute usage.

* Poke

* I used the shotgun. You know why? Cause the shot gun doesn’t miss, and unlike the shitty hybrid taser it stops a criminal in their tracks in two hits. Bang, bang, and they’re fucking done. I use four shots just to make damn sure. Because, once again, I’m not there to coddle a buncha criminal scum sucking f------, I’m there to 1) Survive the fucking round. 2) Guard the armory. So you can absolutely get fucked. If I get unbanned, which I won’t, you can guarantee I will continue to use the shotgun to apprehend criminals. Because it’s quick, clean and effective as fuck. Why in the seven hells would I fuck around with the disabler shots, which take half a clip just to bring someone down, or with the tazer bolts which are slow as balls, impossible to aim and do about next to jack shit, fuck all. The shotgun is the superior law enforcement weapon. Because it stops crime. And it stops crime by reducing the number of criminals roaming the fucking halls.

* Change the faulty store test into two tests, one of which is ignored for failing.
2026-04-01 16:06:26 +00:00

77 lines
2.3 KiB
C#

#nullable enable
using System.Linq;
using Content.IntegrationTests.Fixtures;
using Content.Server.Objectives;
using Content.Shared.Mind;
using Robust.Shared.GameObjects;
using Robust.Shared.Player;
namespace Content.IntegrationTests.Tests.Commands;
public sealed class ObjectiveCommandsTest : GameTest
{
private const string ObjectiveProtoId = "MindCommandsTestObjective";
private const string DummyUsername = "MindCommandsTestUser";
[TestPrototypes]
private const string Prototypes = $"""
- type: entity
id: {ObjectiveProtoId}
components:
- type: Objective
difficulty: 1
issuer: objective-issuer-syndicate
icon:
sprite: error.rsi
state: error
- type: DieCondition
""";
public override PoolSettings PoolSettings => new ()
{
Connected = false
};
/// <summary>
/// Creates a dummy session, and assigns it a mind, then
/// tests using <c>addobjective</c>, <c>lsobjectives</c>,
/// and <c>rmobjective</c> on it.
/// </summary>
[Test]
public async Task AddListRemoveObjectiveTest()
{
var pair = Pair;
var server = pair.Server;
var entMan = server.EntMan;
var playerMan = server.ResolveDependency<ISharedPlayerManager>();
var mindSys = server.System<SharedMindSystem>();
var objectivesSystem = server.System<ObjectivesSystem>();
await server.AddDummySession(DummyUsername);
await server.WaitRunTicks(5);
var playerSession = playerMan.Sessions.Single();
Entity<MindComponent>? mindEnt = null;
await server.WaitPost(() =>
{
mindEnt = mindSys.CreateMind(playerSession.UserId);
});
Assert.That(mindEnt, Is.Not.Null);
var mindComp = mindEnt!.Value.Comp;
Assert.That(mindComp.Objectives, Is.Empty, "Dummy player started with objectives.");
await pair.WaitCommand($"addobjective {playerSession.Name} {ObjectiveProtoId}");
Assert.That(mindComp.Objectives, Has.Count.EqualTo(1), "addobjective failed to increase Objectives count.");
await pair.WaitCommand($"lsobjectives {playerSession.Name}");
await pair.WaitCommand($"rmobjective {playerSession.Name} 0");
Assert.That(mindComp.Objectives, Is.Empty, "rmobjective failed to remove objective");
}
}