50 lines
1.7 KiB
C#
50 lines
1.7 KiB
C#
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http.Json;
|
|
using NeonSprawl.Server.Game.Items;
|
|
using Xunit;
|
|
|
|
namespace NeonSprawl.Server.Tests.Game.Items;
|
|
|
|
public class ItemDefinitionsWorldApiTests
|
|
{
|
|
private static readonly string[] FrozenSixInIdOrder =
|
|
[
|
|
"contract_handoff_token",
|
|
"field_stim_mk0",
|
|
"prototype_armor_shell",
|
|
"refined_plate_stock",
|
|
"scrap_metal_bulk",
|
|
"survey_drone_kit",
|
|
];
|
|
|
|
[Fact]
|
|
public async Task GetItemDefinitions_ShouldReturnSchemaV1_WithFrozenSixInIdOrder()
|
|
{
|
|
// Arrange
|
|
await using var factory = new InMemoryWebApplicationFactory();
|
|
var client = factory.CreateClient();
|
|
// Act
|
|
var response = await client.GetAsync("/game/world/item-definitions");
|
|
// Assert
|
|
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
|
|
var body = await response.Content.ReadFromJsonAsync<ItemDefinitionsListResponse>();
|
|
Assert.NotNull(body);
|
|
Assert.Equal(ItemDefinitionsListResponse.CurrentSchemaVersion, body!.SchemaVersion);
|
|
Assert.NotNull(body.Items);
|
|
var ids = body.Items.Select(static i => i.Id).ToList();
|
|
Assert.Equal(FrozenSixInIdOrder, ids);
|
|
|
|
var scrap = body.Items.Single(i => i.Id == "scrap_metal_bulk");
|
|
Assert.Equal("Scrap Metal (Bulk)", scrap.DisplayName);
|
|
Assert.Equal("material", scrap.PrototypeRole);
|
|
Assert.Equal(999, scrap.StackMax);
|
|
Assert.Equal("bag", scrap.InventorySlotKind);
|
|
|
|
var armor = body.Items.Single(i => i.Id == "prototype_armor_shell");
|
|
Assert.Equal("equip_stub", armor.PrototypeRole);
|
|
Assert.Equal(1, armor.StackMax);
|
|
Assert.Equal("equipment", armor.InventorySlotKind);
|
|
}
|
|
}
|