53 lines
2.4 KiB
C#
53 lines
2.4 KiB
C#
using NeonSprawl.Server.Game.Encounters;
|
|
|
|
namespace NeonSprawl.Server.Tests.Game.Encounters;
|
|
|
|
public class EncounterDefinitionsWorldApiTests
|
|
{
|
|
/// <summary>Frozen prototype encounter id. Keep in sync with Bruno.</summary>
|
|
public const string PrototypeCombatPocket = "prototype_combat_pocket";
|
|
|
|
/// <summary>Frozen prototype grant sequence in catalog order. Keep in sync with Bruno.</summary>
|
|
public static readonly (string ItemId, int Quantity)[] FrozenPrototypeGrantsInOrder =
|
|
[
|
|
("scrap_metal_bulk", 10),
|
|
("contract_handoff_token", 1),
|
|
];
|
|
|
|
[Fact]
|
|
public async Task GetEncounterDefinitions_ShouldReturnSchemaV1_WithFrozenEncounterAndNestedRewardTable()
|
|
{
|
|
// Arrange
|
|
await using var factory = new InMemoryWebApplicationFactory();
|
|
var client = factory.CreateClient();
|
|
// Act
|
|
var response = await client.GetAsync("/game/world/encounter-definitions");
|
|
// Assert
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
var body = await response.Content.ReadFromJsonAsync<EncounterDefinitionsListResponse>();
|
|
Assert.NotNull(body);
|
|
Assert.Equal(EncounterDefinitionsListResponse.CurrentSchemaVersion, body!.SchemaVersion);
|
|
Assert.NotNull(body.Encounters);
|
|
Assert.Single(body.Encounters);
|
|
|
|
var encounter = body.Encounters[0];
|
|
Assert.Equal(PrototypeCombatPocket, encounter.Id);
|
|
Assert.Equal("Prototype Combat Pocket", encounter.DisplayName);
|
|
Assert.NotNull(encounter.CompletionCriteria);
|
|
Assert.Equal("defeat_all_targets", encounter.CompletionCriteria.Kind);
|
|
Assert.Equal(
|
|
["prototype_npc_melee", "prototype_npc_ranged", "prototype_npc_elite"],
|
|
encounter.RequiredNpcInstanceIds);
|
|
|
|
Assert.NotNull(encounter.RewardTable);
|
|
Assert.Equal("prototype_combat_pocket_clear", encounter.RewardTable.Id);
|
|
Assert.Equal("Prototype Combat Pocket Clear", encounter.RewardTable.DisplayName);
|
|
Assert.Equal(FrozenPrototypeGrantsInOrder.Length, encounter.RewardTable.FixedGrants.Count);
|
|
for (var i = 0; i < FrozenPrototypeGrantsInOrder.Length; i++)
|
|
{
|
|
Assert.Equal(FrozenPrototypeGrantsInOrder[i].ItemId, encounter.RewardTable.FixedGrants[i].ItemId);
|
|
Assert.Equal(FrozenPrototypeGrantsInOrder[i].Quantity, encounter.RewardTable.FixedGrants[i].Quantity);
|
|
}
|
|
}
|
|
}
|