CatStation/Content.IntegrationTests/Tests/Preferences/LoadoutTests.cs
Princess Cheeseballs 2c6ffecf62
Move GameTicker to Shared (#45834)
* Scope creep my ass

* why was this shit not pushed????

* gone...

* fix that

* review plus buildd

* asfsafsafsafsafas

* grug

* burber

* I'll fix this later

* shrimply die

* also this

* it's snerf or snuthin

* assaads

* round snend

* aaaa

* fix this shit for real

* actually, don't start GameRules until MapInit now that I think aboot it.

* forgot u

* don't actually need this part nullable

* Deffer comp removal

* one liner

* do that too

* chungus

* Honestly makes more sense here, plus WHY are we doing all that shit on "GameRuleAdded" rather than GameRuleStarted(?)

* deferred removal :V

* aaaaaaaaaaaaaaa

* whhop

* Whoop

* better

* landmine that I placed for myself then forgot about lmao

* cleanup

* FUCKING `!`

* gotovo

* amogus

* please don't check by metadata I beg

* waawsasfdfsasfa

* sfafsasfafsas

* fdsaasffsasfa

* code

* fix

* fasasffasfasfsad

* chungaas

* I may be stupid

* gra

* graaaaaaaaaaaaaaaaa

* comment

* gra

* clearing is not predicted and would require major refactors, so don't cache on client.

* lame shit :P

* last holes

* nukeopsfsafsasafsfafsa

* why  was that shit public bruh

* bubrbgwahrghfaka

* dynamic

* revert change that did nothing lmao
2026-09-16 19:34:19 +00:00

95 lines
2.9 KiB
C#

using System.Collections.Generic;
using Content.IntegrationTests.Fixtures;
using Content.Server.Station.Systems;
using Content.Shared.Inventory;
using Content.Shared.Preferences;
using Content.Shared.Preferences.Loadouts;
using Content.Shared.Station.Systems;
using Robust.Shared.GameObjects;
using Robust.Shared.Prototypes;
namespace Content.IntegrationTests.Tests.Preferences;
[TestFixture]
public sealed class LoadoutTests : GameTest
{
[TestPrototypes]
private const string Prototypes = @"
- type: playTimeTracker
id: PlayTimeLoadoutTester
- type: loadout
id: TestJumpsuit
equipment:
jumpsuit: ClothingUniformJumpsuitColorGrey
- type: loadoutGroup
id: LoadoutTesterJumpsuit
name: generic-unknown
loadouts:
- TestJumpsuit
- type: roleLoadout
id: JobLoadoutTester
groups:
- LoadoutTesterJumpsuit
- type: job
id: LoadoutTester
playTimeTracker: PlayTimeLoadoutTester
";
private readonly Dictionary<string, EntProtoId> _expectedEquipment = new()
{
["jumpsuit"] = "ClothingUniformJumpsuitColorGrey"
};
public override PoolSettings PoolSettings => new()
{
Dirty = true,
};
/// <summary>
/// Checks that an empty loadout still spawns with default gear and not naked.
/// </summary>
[Test]
public async Task TestEmptyLoadout()
{
var pair = Pair;
var server = pair.Server;
var entManager = server.ResolveDependency<IEntityManager>();
// Check that an empty role loadout spawns gear
var stationSystem = entManager.System<StationSpawningSystem>();
var inventorySystem = entManager.System<InventorySystem>();
var testMap = await pair.CreateTestMap();
await server.WaitAssertion(() =>
{
var profile = new HumanoidCharacterProfile();
profile.SetLoadout(new RoleLoadout("LoadoutTester"));
var tester = stationSystem.SpawnPlayerMob(testMap.GridCoords, job: "LoadoutTester", profile, station: null);
var slotQuery = inventorySystem.GetSlotEnumerator(tester);
var checkedCount = 0;
while (slotQuery.NextItem(out var item, out var slot))
{
// Make sure the slot is valid
Assert.That(_expectedEquipment.TryGetValue(slot.Name, out var expectedItem), $"Spawned item in unexpected slot: {slot.Name}");
// Make sure that the item is the right one
var meta = entManager.GetComponent<MetaDataComponent>(item);
Assert.That(meta.EntityPrototype.ID, Is.EqualTo(expectedItem.Id), $"Spawned wrong item in slot {slot.Name}!");
checkedCount++;
}
// Make sure the number of items is the same
Assert.That(checkedCount, Is.EqualTo(_expectedEquipment.Count), "Number of items does not match expected!");
entManager.DeleteEntity(tester);
});
}
}