From d560f9ade4ac28c1136f67830a8b650edcf0b91f Mon Sep 17 00:00:00 2001 From: gamer147 Date: Fri, 29 May 2026 13:55:46 -0400 Subject: [PATCH] chore(di): register entitlements + spend services; add test freeplay helper Co-Authored-By: Claude Sonnet 4.6 --- SVSim.EmulatedEntrypoint/Program.cs | 2 ++ .../Infrastructure/SVSimTestFactory.cs | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/SVSim.EmulatedEntrypoint/Program.cs b/SVSim.EmulatedEntrypoint/Program.cs index 43391b8..524916c 100644 --- a/SVSim.EmulatedEntrypoint/Program.cs +++ b/SVSim.EmulatedEntrypoint/Program.cs @@ -84,6 +84,8 @@ public class Program builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped(); + builder.Services.AddScoped(); + builder.Services.AddScoped(); builder.Services.AddScoped(); builder.Services.AddScoped await new PackImporter().ImportAsync(ctx, seedDir); } + /// + /// Enables Freeplay mode by writing the GameConfigs DB row (tier-1 of GameConfigService). + /// Call before issuing the request under test. Idempotent. + /// + public async Task EnableFreeplayAsync(ulong currencyAmount = 99999, int cardCopies = 3) + { + using var scope = Services.CreateScope(); + var db = scope.ServiceProvider.GetRequiredService(); + var json = System.Text.Json.JsonSerializer.Serialize(new + { + Enabled = true, + CurrencyAmount = currencyAmount, + CardCopies = cardCopies, + }); + var existing = await db.GameConfigs.FirstOrDefaultAsync(s => s.SectionName == "Freeplay"); + if (existing is null) + db.GameConfigs.Add(new GameConfigSection { SectionName = "Freeplay", ValueJson = json }); + else + existing.ValueJson = json; + await db.SaveChangesAsync(); + } + /// Convenience: bake the X-Test-Viewer-Id header into a fresh client. public HttpClient CreateAuthenticatedClient(long viewerId) {