File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -374,42 +374,4 @@ public async Task ListModels_WithCustomHandler_WorksWithoutStart()
374374 Assert . Single ( models ) ;
375375 Assert . Equal ( "no-start-model" , models [ 0 ] . Id ) ;
376376 }
377-
378- [ Fact ]
379- public async Task State_Should_Transition_To_Disconnected_When_Process_Is_Killed ( )
380- {
381- using var client = new CopilotClient ( new CopilotClientOptions { UseStdio = true } ) ;
382-
383- try
384- {
385- await client . StartAsync ( ) ;
386- Assert . Equal ( ConnectionState . Connected , client . State ) ;
387-
388- // Use reflection to reach the child process inside the private Connection object
389- var taskField = typeof ( CopilotClient )
390- . GetField ( "_connectionTask" , System . Reflection . BindingFlags . NonPublic | System . Reflection . BindingFlags . Instance ) ! ;
391- var task = ( Task ) taskField . GetValue ( client ) ! ;
392- await task ; // ensure it's completed
393- // Task<Connection>.Result via reflection
394- var resultProp = task . GetType ( ) . GetProperty ( "Result" ) ! ;
395- var connection = resultProp . GetValue ( task ) ! ;
396- var processProp = connection . GetType ( ) . GetProperty ( "CliProcess" ) ! ;
397- var process = ( System . Diagnostics . Process ) processProp . GetValue ( connection ) ! ;
398-
399- process . Kill ( ) ;
400-
401- // Wait for ContinueWith callback to set _disconnected
402- for ( var i = 0 ; i < 50 ; i ++ )
403- {
404- if ( client . State == ConnectionState . Disconnected ) break ;
405- await Task . Delay ( 100 ) ;
406- }
407-
408- Assert . Equal ( ConnectionState . Disconnected , client . State ) ;
409- }
410- finally
411- {
412- try { await client . ForceStopAsync ( ) ; } catch { /* process already dead */ }
413- }
414- }
415377}
You can’t perform that action at this time.
0 commit comments