diff --git a/SVSim.UnitTests/Services/Inventory/InventoryHistoryTests.cs b/SVSim.UnitTests/Services/Inventory/InventoryHistoryTests.cs index 4a86e70..3dbd39a 100644 --- a/SVSim.UnitTests/Services/Inventory/InventoryHistoryTests.cs +++ b/SVSim.UnitTests/Services/Inventory/InventoryHistoryTests.cs @@ -305,4 +305,28 @@ public class InventoryHistoryTests Assert.That(primaryCount, Is.EqualTo(300), "primary viewer pruned to cap"); Assert.That(otherCount, Is.EqualTo(50), "other viewer untouched by primary's prune"); } + + [Test] + public async Task Commit_writes_history_row_with_Unknown_source_when_caller_omits_Source() + { + using var factory = new SVSim.UnitTests.Infrastructure.SVSimTestFactory(); + long viewerId = await factory.SeedViewerAsync(); + using var scope = factory.Services.CreateScope(); + var inv = scope.ServiceProvider.GetRequiredService(); + + // No configure callback — Source defaults to Unknown. + await using (var tx = await inv.BeginAsync(viewerId)) + { + await tx.GrantAsync(SVSim.Database.Enums.UserGoodsType.Rupy, 0, 10); + await tx.CommitAsync(); + } + + using var verifyScope = factory.Services.CreateScope(); + var ctx = verifyScope.ServiceProvider.GetRequiredService(); + var rows = await ctx.ViewerAcquireHistory.AsNoTracking() + .Where(h => h.ViewerId == viewerId).ToListAsync(); + Assert.That(rows, Has.Count.EqualTo(1)); + Assert.That(rows[0].AcquireType, Is.EqualTo((int)GrantSource.Unknown)); + Assert.That(rows[0].Message, Is.EqualTo("Unknown")); + } }