chore(di): register entitlements + spend services; add test freeplay helper

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
gamer147
2026-05-29 13:55:46 -04:00
parent 0052307686
commit d560f9ade4
2 changed files with 24 additions and 0 deletions

View File

@@ -84,6 +84,8 @@ public class Program
builder.Services.AddScoped<IGachaPointService, GachaPointService>();
builder.Services.AddScoped<ICardAcquisitionService, CardAcquisitionService>();
builder.Services.AddScoped<RewardGrantService>();
builder.Services.AddScoped<SVSim.Database.Services.IViewerEntitlements, SVSim.Database.Services.ViewerEntitlements>();
builder.Services.AddScoped<SVSim.Database.Services.ICurrencySpendService, SVSim.Database.Services.CurrencySpendService>();
builder.Services.AddScoped<SVSim.Database.Repositories.BattlePass.IBattlePassRepository,
SVSim.Database.Repositories.BattlePass.BattlePassRepository>();
builder.Services.AddScoped<SVSim.Database.Repositories.BattlePass.IViewerBattlePassRepository,

View File

@@ -244,6 +244,28 @@ internal sealed class SVSimTestFactory : WebApplicationFactory<Program>
await new PackImporter().ImportAsync(ctx, seedDir);
}
/// <summary>
/// Enables Freeplay mode by writing the GameConfigs DB row (tier-1 of GameConfigService).
/// Call before issuing the request under test. Idempotent.
/// </summary>
public async Task EnableFreeplayAsync(ulong currencyAmount = 99999, int cardCopies = 3)
{
using var scope = Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
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();
}
/// <summary>Convenience: bake the X-Test-Viewer-Id header into a fresh client.</summary>
public HttpClient CreateAuthenticatedClient(long viewerId)
{