Pack opening
This commit is contained in:
61
SVSim.UnitTests/Importers/GlobalsImporterPackTests.cs
Normal file
61
SVSim.UnitTests/Importers/GlobalsImporterPackTests.cs
Normal file
@@ -0,0 +1,61 @@
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using SVSim.Database;
|
||||
using SVSim.Database.Enums;
|
||||
using SVSim.UnitTests.Infrastructure;
|
||||
|
||||
namespace SVSim.UnitTests.Importers;
|
||||
|
||||
public class GlobalsImporterPackTests
|
||||
{
|
||||
[Test]
|
||||
public async Task ImportAll_loads_pack_catalog_from_fixture()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
await factory.SeedGlobalsAsync(); // uses prod-captures fixture dir copied into test output
|
||||
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||
var packs = await db.Packs.OrderBy(p => p.Id).ToListAsync();
|
||||
|
||||
Assert.That(packs.Count, Is.GreaterThanOrEqualTo(3), "fixture has at least 3 packs");
|
||||
var p10001 = packs.Single(p => p.Id == 10001);
|
||||
Assert.That(p10001.PackCategory, Is.EqualTo(PackCategory.None));
|
||||
Assert.That(p10001.BasePackId, Is.EqualTo(10001));
|
||||
Assert.That(p10001.SleeveId, Is.EqualTo(3000011));
|
||||
Assert.That(p10001.GachaPointConfig, Is.Not.Null);
|
||||
Assert.That(p10001.GachaPointConfig!.ExchangeablePoint, Is.EqualTo(400));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ImportAll_persists_child_gachas_with_correct_types_and_costs()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
await factory.SeedGlobalsAsync();
|
||||
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||
var pack = await db.Packs.AsNoTracking()
|
||||
.FirstAsync(p => p.Id == 10001);
|
||||
var children = pack.ChildGachas.OrderBy(c => c.GachaId).ToList();
|
||||
|
||||
Assert.That(children.Count, Is.EqualTo(3));
|
||||
Assert.That(children.Select(c => c.TypeDetail), Is.EqualTo(new[] { 2, 3, 7 }));
|
||||
Assert.That(children.Select(c => c.Cost), Is.EqualTo(new[] { 100, 50, 100 }));
|
||||
Assert.That(children.Single(c => c.TypeDetail == 3).IsDailySingle, Is.True);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ImportAll_is_idempotent_on_rerun()
|
||||
{
|
||||
using var factory = new SVSimTestFactory();
|
||||
await factory.SeedGlobalsAsync();
|
||||
await factory.SeedGlobalsAsync(); // second run must not duplicate or stack child gachas
|
||||
|
||||
using var scope = factory.Services.CreateScope();
|
||||
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||
var pack = await db.Packs.AsNoTracking().FirstAsync(p => p.Id == 10001);
|
||||
Assert.That(pack.ChildGachas.Count, Is.EqualTo(3),
|
||||
"child_gacha_info is owned — rerun must replace, not stack.");
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user