NEO-31: structure AbilityCastApiTests in explicit AAA sections
parent
b5b8c10d36
commit
7c327994eb
|
|
@ -23,10 +23,12 @@ public sealed class AbilityCastApiTests
|
|||
[Fact]
|
||||
public async Task PostAbilityCast_ShouldAccept_WhenLoadoutMatches()
|
||||
{
|
||||
// Arrange
|
||||
await using var factory = new InMemoryWebApplicationFactory();
|
||||
var client = factory.CreateClient();
|
||||
await BindSlot0PulseAsync(client);
|
||||
|
||||
// Act
|
||||
var response = await client.PostAsJsonAsync(
|
||||
"/game/players/dev-local-1/ability-cast",
|
||||
new AbilityCastRequest
|
||||
|
|
@ -38,6 +40,7 @@ public sealed class AbilityCastApiTests
|
|||
});
|
||||
var body = await response.Content.ReadFromJsonAsync<AbilityCastResponse>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(body);
|
||||
Assert.True(body!.Accepted);
|
||||
|
|
@ -47,10 +50,12 @@ public sealed class AbilityCastApiTests
|
|||
[Fact]
|
||||
public async Task PostAbilityCast_ShouldAccept_WithTargetId_WhenLoadoutMatches()
|
||||
{
|
||||
// Arrange
|
||||
await using var factory = new InMemoryWebApplicationFactory();
|
||||
var client = factory.CreateClient();
|
||||
await BindSlot0PulseAsync(client);
|
||||
|
||||
// Act
|
||||
var response = await client.PostAsJsonAsync(
|
||||
"/game/players/dev-local-1/ability-cast",
|
||||
new AbilityCastRequest
|
||||
|
|
@ -62,6 +67,7 @@ public sealed class AbilityCastApiTests
|
|||
});
|
||||
var body = await response.Content.ReadFromJsonAsync<AbilityCastResponse>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(body);
|
||||
Assert.True(body!.Accepted);
|
||||
|
|
@ -70,9 +76,11 @@ public sealed class AbilityCastApiTests
|
|||
[Fact]
|
||||
public async Task PostAbilityCast_ShouldDenySlotUnbound_WhenSlotEmpty()
|
||||
{
|
||||
// Arrange
|
||||
await using var factory = new InMemoryWebApplicationFactory();
|
||||
var client = factory.CreateClient();
|
||||
|
||||
// Act
|
||||
var response = await client.PostAsJsonAsync(
|
||||
"/game/players/dev-local-1/ability-cast",
|
||||
new AbilityCastRequest
|
||||
|
|
@ -84,6 +92,7 @@ public sealed class AbilityCastApiTests
|
|||
});
|
||||
var body = await response.Content.ReadFromJsonAsync<AbilityCastResponse>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(body);
|
||||
Assert.False(body!.Accepted);
|
||||
|
|
@ -93,10 +102,12 @@ public sealed class AbilityCastApiTests
|
|||
[Fact]
|
||||
public async Task PostAbilityCast_ShouldDenyLoadoutMismatch_WhenAbilityDoesNotMatchSlot()
|
||||
{
|
||||
// Arrange
|
||||
await using var factory = new InMemoryWebApplicationFactory();
|
||||
var client = factory.CreateClient();
|
||||
await BindSlot0PulseAsync(client);
|
||||
|
||||
// Act
|
||||
var response = await client.PostAsJsonAsync(
|
||||
"/game/players/dev-local-1/ability-cast",
|
||||
new AbilityCastRequest
|
||||
|
|
@ -108,6 +119,7 @@ public sealed class AbilityCastApiTests
|
|||
});
|
||||
var body = await response.Content.ReadFromJsonAsync<AbilityCastResponse>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(body);
|
||||
Assert.False(body!.Accepted);
|
||||
|
|
@ -117,10 +129,12 @@ public sealed class AbilityCastApiTests
|
|||
[Fact]
|
||||
public async Task PostAbilityCast_ShouldDenySlotOutOfBounds()
|
||||
{
|
||||
// Arrange
|
||||
await using var factory = new InMemoryWebApplicationFactory();
|
||||
var client = factory.CreateClient();
|
||||
await BindSlot0PulseAsync(client);
|
||||
|
||||
// Act
|
||||
var response = await client.PostAsJsonAsync(
|
||||
"/game/players/dev-local-1/ability-cast",
|
||||
new AbilityCastRequest
|
||||
|
|
@ -132,6 +146,7 @@ public sealed class AbilityCastApiTests
|
|||
});
|
||||
var body = await response.Content.ReadFromJsonAsync<AbilityCastResponse>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(body);
|
||||
Assert.False(body!.Accepted);
|
||||
|
|
@ -141,10 +156,12 @@ public sealed class AbilityCastApiTests
|
|||
[Fact]
|
||||
public async Task PostAbilityCast_ShouldDenyUnknownAbility_WhenAbilityIdNotInRegistry()
|
||||
{
|
||||
// Arrange
|
||||
await using var factory = new InMemoryWebApplicationFactory();
|
||||
var client = factory.CreateClient();
|
||||
await BindSlot0PulseAsync(client);
|
||||
|
||||
// Act
|
||||
var response = await client.PostAsJsonAsync(
|
||||
"/game/players/dev-local-1/ability-cast",
|
||||
new AbilityCastRequest
|
||||
|
|
@ -156,6 +173,7 @@ public sealed class AbilityCastApiTests
|
|||
});
|
||||
var body = await response.Content.ReadFromJsonAsync<AbilityCastResponse>();
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
||||
Assert.NotNull(body);
|
||||
Assert.False(body!.Accepted);
|
||||
|
|
@ -165,49 +183,58 @@ public sealed class AbilityCastApiTests
|
|||
[Fact]
|
||||
public async Task PostAbilityCast_ShouldReturnBadRequest_WhenBodyMalformed()
|
||||
{
|
||||
// Arrange
|
||||
await using var factory = new InMemoryWebApplicationFactory();
|
||||
var client = factory.CreateClient();
|
||||
var malformed = new StringContent(
|
||||
"{\"schemaVersion\":1,\"slotIndex\":",
|
||||
Encoding.UTF8,
|
||||
"application/json");
|
||||
|
||||
var response = await client.PostAsync(
|
||||
"/game/players/dev-local-1/ability-cast",
|
||||
new StringContent("{\"schemaVersion\":1,\"slotIndex\":", Encoding.UTF8, "application/json"));
|
||||
// Act
|
||||
var response = await client.PostAsync("/game/players/dev-local-1/ability-cast", malformed);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostAbilityCast_ShouldReturnBadRequest_WhenSchemaVersionWrong()
|
||||
{
|
||||
// Arrange
|
||||
await using var factory = new InMemoryWebApplicationFactory();
|
||||
var client = factory.CreateClient();
|
||||
var request = new AbilityCastRequest
|
||||
{
|
||||
SchemaVersion = 999,
|
||||
SlotIndex = 0,
|
||||
AbilityId = PrototypeAbilityRegistry.PrototypePulse,
|
||||
};
|
||||
|
||||
var response = await client.PostAsJsonAsync(
|
||||
"/game/players/dev-local-1/ability-cast",
|
||||
new AbilityCastRequest
|
||||
{
|
||||
SchemaVersion = 999,
|
||||
SlotIndex = 0,
|
||||
AbilityId = PrototypeAbilityRegistry.PrototypePulse,
|
||||
});
|
||||
// Act
|
||||
var response = await client.PostAsJsonAsync("/game/players/dev-local-1/ability-cast", request);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.BadRequest, response.StatusCode);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task PostAbilityCast_ShouldReturnNotFound_WhenPlayerUnknown()
|
||||
{
|
||||
// Arrange
|
||||
await using var factory = new InMemoryWebApplicationFactory();
|
||||
var client = factory.CreateClient();
|
||||
var request = new AbilityCastRequest
|
||||
{
|
||||
SchemaVersion = AbilityCastRequest.CurrentSchemaVersion,
|
||||
SlotIndex = 0,
|
||||
AbilityId = PrototypeAbilityRegistry.PrototypePulse,
|
||||
};
|
||||
|
||||
var response = await client.PostAsJsonAsync(
|
||||
"/game/players/missing-player/ability-cast",
|
||||
new AbilityCastRequest
|
||||
{
|
||||
SchemaVersion = AbilityCastRequest.CurrentSchemaVersion,
|
||||
SlotIndex = 0,
|
||||
AbilityId = PrototypeAbilityRegistry.PrototypePulse,
|
||||
});
|
||||
// Act
|
||||
var response = await client.PostAsJsonAsync("/game/players/missing-player/ability-cast", request);
|
||||
|
||||
// Assert
|
||||
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue