repo(viewer): restore dropped rationale comment, add link-idempotency assertion
Review polish on the prior commit (30874c6):
- BuildDefaultViewer extract dropped the "filter out Id=0 placeholders
and dedupe" comment from the leader-skin grant block — restored.
- LinkSteamToViewer test now calls link twice and asserts count stays
at 1, exercising the alreadyLinked short-circuit.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -155,12 +155,20 @@ public class ViewerRepositoryTests
|
||||
await repo.LinkSteamToViewer(viewerId, steamId);
|
||||
}
|
||||
|
||||
using (var scope = factory.Services.CreateScope())
|
||||
{
|
||||
var repo = scope.ServiceProvider.GetRequiredService<IViewerRepository>();
|
||||
await repo.LinkSteamToViewer(viewerId, steamId); // second call must be a no-op
|
||||
}
|
||||
|
||||
using var verifyScope = factory.Services.CreateScope();
|
||||
var db = verifyScope.ServiceProvider.GetRequiredService<SVSimDbContext>();
|
||||
var loaded = await db.Viewers
|
||||
.Include(v => v.SocialAccountConnections)
|
||||
.FirstAsync(v => v.Id == viewerId);
|
||||
|
||||
// Count == 1 proves both the initial append AND that the second LinkSteamToViewer call
|
||||
// hit the `alreadyLinked` short-circuit (idempotent re-link).
|
||||
Assert.That(loaded.SocialAccountConnections, Has.Count.EqualTo(1));
|
||||
Assert.That(loaded.SocialAccountConnections[0].AccountType,
|
||||
Is.EqualTo(SocialAccountType.Steam));
|
||||
|
||||
Reference in New Issue
Block a user