neon-sprawl/server/NeonSprawl.Server.Tests/Game/Skills/SkillProgressionSnapshotApi...

53 lines
1.8 KiB
C#

using System.Linq;
using System.Net;
using System.Net.Http.Json;
using NeonSprawl.Server.Game.Skills;
using Xunit;
namespace NeonSprawl.Server.Tests.Game.Skills;
public sealed class SkillProgressionSnapshotApiTests
{
[Fact]
public async Task GetSkillProgression_ShouldReturnNotFound_WhenPlayerUnknown()
{
// Arrange
await using var factory = new InMemoryWebApplicationFactory();
var client = factory.CreateClient();
// Act
var response = await client.GetAsync("/game/players/missing-player/skill-progression");
// Assert
Assert.Equal(HttpStatusCode.NotFound, response.StatusCode);
}
[Fact]
public async Task GetSkillProgression_ShouldReturnSchemaV1_WithDefaultXpAndLevel_ForFrozenTrio()
{
// Arrange
await using var factory = new InMemoryWebApplicationFactory();
var client = factory.CreateClient();
// Act
var response = await client.GetAsync("/game/players/dev-local-1/skill-progression");
// Assert
Assert.Equal(HttpStatusCode.OK, response.StatusCode);
var body = await response.Content.ReadFromJsonAsync<SkillProgressionSnapshotResponse>();
Assert.NotNull(body);
Assert.Equal(SkillProgressionSnapshotResponse.CurrentSchemaVersion, body!.SchemaVersion);
Assert.Equal("dev-local-1", body.PlayerId);
Assert.NotNull(body.Skills);
Assert.Equal(3, body.Skills!.Count);
var byId = body.Skills.ToDictionary(static s => s.Id, StringComparer.Ordinal);
Assert.Equal(3, byId.Count);
foreach (var id in new[] { "intrusion", "refine", "salvage" })
{
Assert.True(byId.TryGetValue(id, out var row));
Assert.Equal(0, row!.Xp);
Assert.Equal(1, row.Level);
}
}
}