Consolidation
This commit is contained in:
@@ -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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user