11using System . Collections ;
22using System . Collections . Generic ;
33using System . Linq ;
4+ using System . Text ;
45using NUnit . Framework ;
56using Unity . Netcode ;
67using Unity . Netcode . TestHelpers . Runtime ;
@@ -105,8 +106,7 @@ private IEnumerator RunSceneEventCallbackTest(ClientType clientType, Action acti
105106 // Load the scene initially
106107 authority . SceneManager . LoadScene ( k_SceneToLoad , LoadSceneMode . Additive ) ;
107108
108- yield return WaitForConditionOrTimeOut ( ValidateSceneIsLoaded ) ;
109- AssertOnTimeout ( $ "Timed out waiting for client to load the scene { k_SceneToLoad } !") ;
109+ yield return WaitForConditionOrAssert ( ValidateSceneIsLoaded , $ "[Setup] Timed out waiting for client to load the scene { k_SceneToLoad } !") ;
110110
111111 // Wait for any pending messages to be processed
112112 yield return null ;
@@ -179,16 +179,14 @@ private IEnumerator RunSceneEventCallbackTest(ClientType clientType, Action acti
179179 {
180180 Assert . That ( authority . SceneManager . LoadScene ( loadCall , LoadSceneMode . Additive ) == SceneEventProgressStatus . Started ) ;
181181
182- yield return WaitForConditionOrTimeOut ( ValidateSceneIsLoaded ) ;
183- AssertOnTimeout ( $ "Timed out waiting for client to load the scene { k_SceneToLoad } !") ;
182+ yield return WaitForConditionOrAssert ( ValidateSceneIsLoaded , $ "[Test] Timed out waiting for client to load the scene { k_SceneToLoad } !") ;
184183 }
185184 else
186185 {
187186 Assert . That ( loadedScene . name , Is . EqualTo ( k_SceneToLoad ) , "scene was not loaded!" ) ;
188187 Assert . That ( authority . SceneManager . UnloadScene ( loadedScene ) == SceneEventProgressStatus . Started ) ;
189188
190- yield return WaitForConditionOrTimeOut ( ValidateSceneIsUnloaded ) ;
191- AssertOnTimeout ( $ "Timed out waiting for client to unload the scene { k_SceneToLoad } !") ;
189+ yield return WaitForConditionOrAssert ( ValidateSceneIsUnloaded , $ "[Test] Timed out waiting for client to unload the scene { k_SceneToLoad } !") ;
192190 }
193191
194192 // Wait for all messages to process
@@ -202,19 +200,21 @@ private IEnumerator RunSceneEventCallbackTest(ClientType clientType, Action acti
202200 managerToTest . SceneManager . OnSceneEvent -= OnSceneEvent ;
203201 }
204202
205- private bool ValidateSceneIsLoaded ( )
203+ private bool ValidateSceneIsLoaded ( StringBuilder errorBuilder )
206204 {
207205 foreach ( var manager in m_NetworkManagers )
208206 {
209207 // default will have isLoaded as false so we can get the scene or default and test on isLoaded
210208 var loadedScene = manager . SceneManager . ScenesLoaded . Values . FirstOrDefault ( scene => scene . name == k_SceneToLoad ) ;
211209 if ( ! loadedScene . isLoaded )
212210 {
211+ errorBuilder . AppendLine ( $ "[ValidateIsLoaded] Scene { loadedScene . name } exists but is not loaded!") ;
213212 return false ;
214213 }
215214
216215 if ( manager . SceneManager . SceneEventProgressTracking . Count > 0 )
217216 {
217+ errorBuilder . AppendLine ( $ "[ValidateIsLoaded] NetworkManager { manager . name } still has progress tracking events.") ;
218218 return false ;
219219 }
220220 }
0 commit comments