NEO-29: align hotbar persistence test to AAA style

Refactor the Postgres hotbar persistence integration test to explicit Arrange/Act/Assert structure so it matches the team testing style guide.
pull/54/head
VinPropane 2026-04-25 22:47:44 -04:00
parent d25d7d0211
commit 4dc9f76f79
1 changed files with 25 additions and 18 deletions

View File

@ -15,13 +15,9 @@ public sealed class HotbarLoadoutPersistenceIntegrationTests(PostgresIntegration
[RequirePostgresFact] [RequirePostgresFact]
public async Task PostThenGetAcrossNewFactory_ShouldPersistHotbarBindings() public async Task PostThenGetAcrossNewFactory_ShouldPersistHotbarBindings()
{ {
// Arrange
await ResetHotbarTableAsync(); await ResetHotbarTableAsync();
var update = new HotbarLoadoutUpdateRequest
using (var firstClient = Factory.CreateClient())
{
var post = await firstClient.PostAsJsonAsync(
"/game/players/dev-local-1/hotbar-loadout",
new HotbarLoadoutUpdateRequest
{ {
SchemaVersion = HotbarLoadoutUpdateRequest.CurrentSchemaVersion, SchemaVersion = HotbarLoadoutUpdateRequest.CurrentSchemaVersion,
Slots = Slots =
@ -37,14 +33,25 @@ public sealed class HotbarLoadoutPersistenceIntegrationTests(PostgresIntegration
AbilityId = PrototypeAbilityRegistry.PrototypeGuard, AbilityId = PrototypeAbilityRegistry.PrototypeGuard,
}, },
], ],
}); };
Assert.Equal(HttpStatusCode.OK, post.StatusCode); HttpStatusCode postStatus;
// Act
using (var firstClient = Factory.CreateClient())
{
var post = await firstClient.PostAsJsonAsync(
"/game/players/dev-local-1/hotbar-loadout",
update);
postStatus = post.StatusCode;
} }
await using var secondFactory = new PostgresWebApplicationFactory(); await using var secondFactory = new PostgresWebApplicationFactory();
using var secondClient = secondFactory.CreateClient(); using var secondClient = secondFactory.CreateClient();
var loadout = await secondClient.GetFromJsonAsync<HotbarLoadoutResponse>( var loadout = await secondClient.GetFromJsonAsync<HotbarLoadoutResponse>(
"/game/players/dev-local-1/hotbar-loadout"); "/game/players/dev-local-1/hotbar-loadout");
// Assert
Assert.Equal(HttpStatusCode.OK, postStatus);
Assert.NotNull(loadout); Assert.NotNull(loadout);
Assert.Equal(PrototypeAbilityRegistry.PrototypePulse, loadout!.Slots[1].AbilityId); Assert.Equal(PrototypeAbilityRegistry.PrototypePulse, loadout!.Slots[1].AbilityId);
Assert.Equal(PrototypeAbilityRegistry.PrototypeGuard, loadout.Slots[4].AbilityId); Assert.Equal(PrototypeAbilityRegistry.PrototypeGuard, loadout.Slots[4].AbilityId);