NEO-48: fix in-memory TrySetSkillXpTotal zero on absent skill

Setting XP to 0 is a no-op success when no row exists, matching Postgres DELETE
semantics and TrySetSkillXpTotals behavior.
pull/83/head
VinPropane 2026-05-17 20:46:55 -04:00
parent aa83790703
commit 12e52bccc9
2 changed files with 25 additions and 1 deletions

View File

@ -0,0 +1,23 @@
using Microsoft.Extensions.DependencyInjection;
using NeonSprawl.Server.Game.Skills;
using Xunit;
namespace NeonSprawl.Server.Tests.Game.Skills;
public sealed class InMemoryPlayerSkillProgressionStoreTests
{
[Fact]
public void TrySetSkillXpTotal_WhenXpZeroAndSkillAbsent_ShouldReturnTrue()
{
// Arrange
using var factory = new InMemoryWebApplicationFactory();
var store = factory.Services.GetRequiredService<IPlayerSkillProgressionStore>();
// Act
var applied = store.TrySetSkillXpTotal("dev-local-1", "intrusion", xp: 0);
// Assert
Assert.True(applied);
Assert.False(store.GetXpTotals("dev-local-1").ContainsKey("intrusion"));
}
}

View File

@ -82,7 +82,8 @@ public sealed class InMemoryPlayerSkillProgressionStore(IOptions<GamePositionOpt
{
if (xp == 0)
{
return inner.TryRemove(sid, out _);
inner.TryRemove(sid, out _);
return true;
}
inner[sid] = xp;