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
parent
aa83790703
commit
12e52bccc9
|
|
@ -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"));
|
||||
}
|
||||
}
|
||||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in New Issue