@@ -23,6 +23,11 @@ private static int Main()
2323 SettingsAreClamped ( ) ;
2424 StandardLeaderboardWaitsForEightPlayers ( ) ;
2525 PartialLeaderboardRequiresStability ( ) ;
26+ MatchIdentityUsesNewStatsHandleAfterMenu ( ) ;
27+ MatchIdentityPreservesMatchingHandleAfterMenu ( ) ;
28+ MatchIdentityWaitsForAmbiguousConflict ( ) ;
29+ MatchIdentityPreservesStoredHandleDuringActiveConflict ( ) ;
30+ MatchEndPolicyRequiresAConfirmedResult ( ) ;
2631 Console . WriteLine ( "All Opponent Memory tests passed." ) ;
2732 return 0 ;
2833 }
@@ -142,6 +147,41 @@ private static IReadOnlyList<LeaderboardPlayer> Players(int count)
142147 return players ;
143148 }
144149
150+ private static void MatchIdentityUsesNewStatsHandleAfterMenu ( )
151+ {
152+ var snapshot = new GameHandleSnapshot ( 100 , 200 ) ;
153+ var decision = MatchIdentityResolver . Evaluate ( 100 , true , snapshot ) ;
154+ Equal ( MatchIdentityAction . StartNew , decision . Action , "new stats handle starts a new match" ) ;
155+ Equal < uint ? > ( 200 , decision . GameHandle , "new stats handle is selected" ) ;
156+ }
157+
158+ private static void MatchIdentityPreservesMatchingHandleAfterMenu ( )
159+ {
160+ var decision = MatchIdentityResolver . Evaluate ( 100 , true , new GameHandleSnapshot ( 100 , 100 ) ) ;
161+ Equal ( MatchIdentityAction . Preserve , decision . Action , "matching handles preserve state" ) ;
162+ Equal < uint ? > ( 100 , decision . GameHandle , "matching handle remains active" ) ;
163+ }
164+
165+ private static void MatchIdentityWaitsForAmbiguousConflict ( )
166+ {
167+ var decision = MatchIdentityResolver . Evaluate ( 100 , true , new GameHandleSnapshot ( 200 , 300 ) ) ;
168+ Equal ( MatchIdentityAction . Wait , decision . Action , "unrelated conflicting handles wait for stable data" ) ;
169+ }
170+
171+ private static void MatchIdentityPreservesStoredHandleDuringActiveConflict ( )
172+ {
173+ var decision = MatchIdentityResolver . Evaluate ( 200 , false , new GameHandleSnapshot ( 100 , 200 ) ) ;
174+ Equal ( MatchIdentityAction . Preserve , decision . Action , "active match keeps its known handle during a transient conflict" ) ;
175+ Equal < uint ? > ( 200 , decision . GameHandle , "known active handle is retained" ) ;
176+ }
177+
178+ private static void MatchEndPolicyRequiresAConfirmedResult ( )
179+ {
180+ False ( MatchEndPolicy . ShouldClearState ( false , false ) , "missing game stats do not clear match state" ) ;
181+ False ( MatchEndPolicy . ShouldClearState ( true , false ) , "pending result does not clear match state" ) ;
182+ True ( MatchEndPolicy . ShouldClearState ( true , true ) , "confirmed result clears match state" ) ;
183+ }
184+
145185 private static void True ( bool value , string name ) { if ( ! value ) throw new InvalidOperationException ( name ) ; }
146186 private static void False ( bool value , string name ) { if ( value ) throw new InvalidOperationException ( name ) ; }
147187 private static void Equal < T > ( T expected , T actual , string name ) { if ( ! Equals ( expected , actual ) ) throw new InvalidOperationException ( name + ": expected " + expected + ", actual " + actual ) ; }
0 commit comments