@@ -13,38 +13,38 @@ namespace GZCTF.Integration.Test.Base;
1313public static class TestDataSeeder
1414{
1515 // Shared game instances for test reuse
16- private static int _sharedBasicGameId ;
17- private static int _sharedInviteGameId ;
18- private static int _sharedPracticeModeGameId ;
19- private static int _sharedWithReviewGameId ;
16+ private static int SharedBasicGameId ;
17+ private static int SharedInviteGameId ;
18+ private static int SharedPracticeModeGameId ;
19+ private static int SharedWithReviewGameId ;
2020
21- private static readonly SemaphoreSlim _basicGameLock = new ( 1 , 1 ) ;
22- private static readonly SemaphoreSlim _inviteGameLock = new ( 1 , 1 ) ;
23- private static readonly SemaphoreSlim _practiceModeGameLock = new ( 1 , 1 ) ;
24- private static readonly SemaphoreSlim _withReviewGameLock = new ( 1 , 1 ) ;
21+ private static readonly SemaphoreSlim BasicGameLock = new ( 1 , 1 ) ;
22+ private static readonly SemaphoreSlim InviteGameLock = new ( 1 , 1 ) ;
23+ private static readonly SemaphoreSlim PracticeModeGameLock = new ( 1 , 1 ) ;
24+ private static readonly SemaphoreSlim WithReviewGameLock = new ( 1 , 1 ) ;
2525
2626 /// <summary>
2727 /// Get or create a shared basic game (no special configuration)
2828 /// Suitable for: basic join, permission tests, multi-user scenarios
2929 /// </summary>
3030 public static async Task < int > GetOrCreateBasicGameAsync ( IServiceProvider services )
3131 {
32- if ( _sharedBasicGameId > 0 )
33- return _sharedBasicGameId ;
32+ if ( SharedBasicGameId > 0 )
33+ return SharedBasicGameId ;
3434
35- await _basicGameLock . WaitAsync ( ) ;
35+ await BasicGameLock . WaitAsync ( ) ;
3636 try
3737 {
38- if ( _sharedBasicGameId > 0 )
39- return _sharedBasicGameId ;
38+ if ( SharedBasicGameId > 0 )
39+ return SharedBasicGameId ;
4040
4141 var game = await CreateGameAsync ( services , "Shared Basic Game" ) ;
42- _sharedBasicGameId = game . Id ;
43- return _sharedBasicGameId ;
42+ SharedBasicGameId = game . Id ;
43+ return SharedBasicGameId ;
4444 }
4545 finally
4646 {
47- _basicGameLock . Release ( ) ;
47+ BasicGameLock . Release ( ) ;
4848 }
4949 }
5050
@@ -54,33 +54,33 @@ public static async Task<int> GetOrCreateBasicGameAsync(IServiceProvider service
5454 /// </summary>
5555 public static async Task < int > GetOrCreateInviteGameAsync ( IServiceProvider services )
5656 {
57- if ( _sharedInviteGameId > 0 )
58- return _sharedInviteGameId ;
57+ if ( SharedInviteGameId > 0 )
58+ return SharedInviteGameId ;
5959
60- await _inviteGameLock . WaitAsync ( ) ;
60+ await InviteGameLock . WaitAsync ( ) ;
6161 try
6262 {
63- if ( _sharedInviteGameId > 0 )
64- return _sharedInviteGameId ;
63+ if ( SharedInviteGameId > 0 )
64+ return SharedInviteGameId ;
6565
6666 var game = await CreateGameAsync ( services , "Shared Invite Game" ) ;
6767
6868 // Set game invite code
6969 using var scope = services . CreateScope ( ) ;
7070 var gameRepo = scope . ServiceProvider . GetRequiredService < IGameRepository > ( ) ;
71- var gameEntity = await gameRepo . GetGameById ( game . Id , default ) ;
71+ var gameEntity = await gameRepo . GetGameById ( game . Id , CancellationToken . None ) ;
7272 if ( gameEntity != null )
7373 {
7474 gameEntity . InviteCode = "SHARED_INVITE_2025" ;
75- await gameRepo . SaveAsync ( default ) ;
75+ await gameRepo . SaveAsync ( CancellationToken . None ) ;
7676 }
7777
78- _sharedInviteGameId = game . Id ;
79- return _sharedInviteGameId ;
78+ SharedInviteGameId = game . Id ;
79+ return SharedInviteGameId ;
8080 }
8181 finally
8282 {
83- _inviteGameLock . Release ( ) ;
83+ InviteGameLock . Release ( ) ;
8484 }
8585 }
8686
@@ -90,23 +90,23 @@ public static async Task<int> GetOrCreateInviteGameAsync(IServiceProvider servic
9090 /// </summary>
9191 public static async Task < int > GetOrCreatePracticeModeGameAsync ( IServiceProvider services )
9292 {
93- if ( _sharedPracticeModeGameId > 0 )
94- return _sharedPracticeModeGameId ;
93+ if ( SharedPracticeModeGameId > 0 )
94+ return SharedPracticeModeGameId ;
9595
96- await _practiceModeGameLock . WaitAsync ( ) ;
96+ await PracticeModeGameLock . WaitAsync ( ) ;
9797 try
9898 {
99- if ( _sharedPracticeModeGameId > 0 )
100- return _sharedPracticeModeGameId ;
99+ if ( SharedPracticeModeGameId > 0 )
100+ return SharedPracticeModeGameId ;
101101
102102 var game = await CreateGameAsync ( services , "Shared Practice Mode Game" ,
103103 practiceMode : true ) ;
104- _sharedPracticeModeGameId = game . Id ;
105- return _sharedPracticeModeGameId ;
104+ SharedPracticeModeGameId = game . Id ;
105+ return SharedPracticeModeGameId ;
106106 }
107107 finally
108108 {
109- _practiceModeGameLock . Release ( ) ;
109+ PracticeModeGameLock . Release ( ) ;
110110 }
111111 }
112112
@@ -116,23 +116,23 @@ public static async Task<int> GetOrCreatePracticeModeGameAsync(IServiceProvider
116116 /// </summary>
117117 public static async Task < int > GetOrCreateWithReviewGameAsync ( IServiceProvider services )
118118 {
119- if ( _sharedWithReviewGameId > 0 )
120- return _sharedWithReviewGameId ;
119+ if ( SharedWithReviewGameId > 0 )
120+ return SharedWithReviewGameId ;
121121
122- await _withReviewGameLock . WaitAsync ( ) ;
122+ await WithReviewGameLock . WaitAsync ( ) ;
123123 try
124124 {
125- if ( _sharedWithReviewGameId > 0 )
126- return _sharedWithReviewGameId ;
125+ if ( SharedWithReviewGameId > 0 )
126+ return SharedWithReviewGameId ;
127127
128128 var game = await CreateGameAsync ( services , "Shared With Review Game" ,
129129 acceptWithoutReview : false ) ;
130- _sharedWithReviewGameId = game . Id ;
131- return _sharedWithReviewGameId ;
130+ SharedWithReviewGameId = game . Id ;
131+ return SharedWithReviewGameId ;
132132 }
133133 finally
134134 {
135- _withReviewGameLock . Release ( ) ;
135+ WithReviewGameLock . Release ( ) ;
136136 }
137137 }
138138
@@ -297,7 +297,7 @@ public static async Task<SeededParticipation> JoinGameAsync(IServiceProvider ser
297297 if ( existingPart is not null )
298298 {
299299 // Add user to participation if not already a member
300- if ( ! existingPart . Members . Any ( m => m . UserId = = userId ) )
300+ if ( existingPart . Members . All ( m => m . UserId ! = userId ) )
301301 {
302302 existingPart . Members . Add ( new UserParticipation
303303 {
0 commit comments