Consolidation

This commit is contained in:
gamer147
2026-05-25 16:34:24 -04:00
parent 9b051c444c
commit 8e913578ff
14 changed files with 566 additions and 280 deletions

View File

@@ -79,41 +79,4 @@ public class PackRepositoryTests
}
}
[Test]
public async Task GrantCardsToViewer_inserts_new_and_increments_existing()
{
using var factory = new SVSimTestFactory();
long viewerId = await factory.SeedViewerAsync();
// Cards are not seeded by BaseDataSeeder (they come from CardImport). Insert one directly.
const long seedCardId = 100000001L;
using (var scope = factory.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
db.Cards.Add(new ShadowverseCardEntry { Id = seedCardId, Name = "Test Card", Rarity = Rarity.Bronze });
await db.SaveChangesAsync();
}
long sampleCardId;
using (var scope = factory.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
sampleCardId = await db.Cards.OrderBy(c => c.Id).Select(c => c.Id).FirstAsync();
}
using (var scope = factory.Services.CreateScope())
{
var repo = scope.ServiceProvider.GetRequiredService<IPackRepository>();
await repo.GrantCardsToViewer(viewerId, new[] { sampleCardId, sampleCardId });
}
using (var scope = factory.Services.CreateScope())
{
var db = scope.ServiceProvider.GetRequiredService<SVSimDbContext>();
var v = await db.Viewers.Include(x => x.Cards).ThenInclude(c => c.Card)
.FirstAsync(x => x.Id == viewerId);
var owned = v.Cards.Single(c => c.Card.Id == sampleCardId);
Assert.That(owned.Count, Is.EqualTo(2));
}
}
}