using System.Net; using System.Net.Http.Json; using Microsoft.AspNetCore.Mvc.Testing; using NeonSprawl.Server.Game.PositionState; using Xunit; namespace NeonSprawl.Server.Tests; public class PositionStateApiTests(WebApplicationFactory factory) : IClassFixture> { private readonly HttpClient _client = factory.CreateClient(); [Fact] public async Task GetPosition_dev_player_returns_versioned_json_with_xyz() { var response = await _client.GetAsync("/game/players/dev-local-1/position"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var body = await response.Content.ReadFromJsonAsync(); Assert.NotNull(body); Assert.Equal(PositionStateResponse.CurrentSchemaVersion, body.SchemaVersion); Assert.Equal("dev-local-1", body.PlayerId); Assert.NotNull(body.Position); Assert.Equal(0, body.Position.X); Assert.Equal(0, body.Position.Y); Assert.Equal(0, body.Position.Z); } [Fact] public async Task GetPosition_dev_player_case_insensitive_path_returns_200() { var response = await _client.GetAsync("/game/players/DEV-LOCAL-1/position"); Assert.Equal(HttpStatusCode.OK, response.StatusCode); var body = await response.Content.ReadFromJsonAsync(); Assert.NotNull(body); Assert.Equal(PositionStateResponse.CurrentSchemaVersion, body!.SchemaVersion); Assert.Equal("DEV-LOCAL-1", body.PlayerId); Assert.Equal(0, body.Position!.X); } [Fact] public async Task GetPosition_unknown_player_returns_404() { var response = await _client.GetAsync("/game/players/unknown-player/position"); Assert.Equal(HttpStatusCode.NotFound, response.StatusCode); } }