@@ -39,7 +39,7 @@ public async Task ConnectAndPing_Stdio(string clientId)
3939
4040 // Act
4141 await using var client = await _fixture . CreateClientAsync ( clientId ) ;
42- await client . PingAsync ( CancellationToken . None ) ;
42+ await client . PingAsync ( TestContext . Current . CancellationToken ) ;
4343
4444 // Assert
4545 Assert . NotNull ( client ) ;
@@ -89,7 +89,7 @@ public async Task CallTool_Stdio_EchoServer(string clientId)
8989 {
9090 [ "message" ] = "Hello MCP!"
9191 } ,
92- CancellationToken . None
92+ TestContext . Current . CancellationToken
9393 ) ;
9494
9595 // assert
@@ -141,7 +141,7 @@ public async Task GetPrompt_Stdio_SimplePrompt(string clientId)
141141
142142 // act
143143 await using var client = await _fixture . CreateClientAsync ( clientId ) ;
144- var result = await client . GetPromptAsync ( "simple_prompt" , null , CancellationToken . None ) ;
144+ var result = await client . GetPromptAsync ( "simple_prompt" , null , TestContext . Current . CancellationToken ) ;
145145
146146 // assert
147147 Assert . NotNull ( result ) ;
@@ -161,7 +161,7 @@ public async Task GetPrompt_Stdio_ComplexPrompt(string clientId)
161161 { "temperature" , "0.7" } ,
162162 { "style" , "formal" }
163163 } ;
164- var result = await client . GetPromptAsync ( "complex_prompt" , arguments , CancellationToken . None ) ;
164+ var result = await client . GetPromptAsync ( "complex_prompt" , arguments , TestContext . Current . CancellationToken ) ;
165165
166166 // assert
167167 Assert . NotNull ( result ) ;
@@ -177,7 +177,7 @@ public async Task GetPrompt_NonExistent_ThrowsException(string clientId)
177177 // act
178178 await using var client = await _fixture . CreateClientAsync ( clientId ) ;
179179 await Assert . ThrowsAsync < McpClientException > ( ( ) =>
180- client . GetPromptAsync ( "non_existent_prompt" , null , CancellationToken . None ) ) ;
180+ client . GetPromptAsync ( "non_existent_prompt" , null , TestContext . Current . CancellationToken ) ) ;
181181 }
182182
183183 [ Theory ]
@@ -220,7 +220,7 @@ public async Task ReadResource_Stdio_TextResource(string clientId)
220220 await using var client = await _fixture . CreateClientAsync ( clientId ) ;
221221 // Odd numbered resources are text in the everything server (despite the docs saying otherwise)
222222 // 1 is index 0, which is "even" in the 0-based index
223- var result = await client . ReadResourceAsync ( "test://static/resource/1" , CancellationToken . None ) ;
223+ var result = await client . ReadResourceAsync ( "test://static/resource/1" , TestContext . Current . CancellationToken ) ;
224224
225225 Assert . NotNull ( result ) ;
226226 Assert . Single ( result . Contents ) ;
@@ -237,7 +237,7 @@ public async Task ReadResource_Stdio_BinaryResource(string clientId)
237237 await using var client = await _fixture . CreateClientAsync ( clientId ) ;
238238 // Even numbered resources are binary in the everything server (despite the docs saying otherwise)
239239 // 2 is index 1, which is "odd" in the 0-based index
240- var result = await client . ReadResourceAsync ( "test://static/resource/2" , CancellationToken . None ) ;
240+ var result = await client . ReadResourceAsync ( "test://static/resource/2" , TestContext . Current . CancellationToken ) ;
241241
242242 Assert . NotNull ( result ) ;
243243 Assert . Single ( result . Contents ) ;
@@ -260,7 +260,7 @@ public async Task SubscribeResource_Stdio()
260260 tcs . TrySetResult ( true ) ;
261261 return Task . CompletedTask ;
262262 } ) ;
263- await client . SubscribeToResourceAsync ( "test://static/resource/1" , CancellationToken . None ) ;
263+ await client . SubscribeToResourceAsync ( "test://static/resource/1" , TestContext . Current . CancellationToken ) ;
264264
265265 await tcs . Task ;
266266 }
@@ -281,13 +281,13 @@ public async Task UnsubscribeResource_Stdio()
281281 receivedNotification . TrySetResult ( true ) ;
282282 return Task . CompletedTask ;
283283 } ) ;
284- await client . SubscribeToResourceAsync ( "test://static/resource/1" , CancellationToken . None ) ;
284+ await client . SubscribeToResourceAsync ( "test://static/resource/1" , TestContext . Current . CancellationToken ) ;
285285
286286 // wait until we received a notification
287287 await receivedNotification . Task ;
288288
289289 // unsubscribe
290- await client . UnsubscribeFromResourceAsync ( "test://static/resource/1" , CancellationToken . None ) ;
290+ await client . UnsubscribeFromResourceAsync ( "test://static/resource/1" , TestContext . Current . CancellationToken ) ;
291291 receivedNotification = new ( ) ;
292292
293293 // wait a bit to validate we don't receive another. this is best effort only;
@@ -309,7 +309,7 @@ public async Task GetCompletion_Stdio_ResourceReference(string clientId)
309309 Uri = "test://static/resource/1"
310310 } ,
311311 "argument_name" , "1" ,
312- CancellationToken . None
312+ TestContext . Current . CancellationToken
313313 ) ;
314314
315315 Assert . NotNull ( result ) ;
@@ -331,7 +331,7 @@ public async Task GetCompletion_Stdio_PromptReference(string clientId)
331331 Name = "irrelevant"
332332 } ,
333333 argumentName : "style" , argumentValue : "fo" ,
334- CancellationToken . None
334+ TestContext . Current . CancellationToken
335335 ) ;
336336
337337 Assert . NotNull ( result ) ;
@@ -411,7 +411,7 @@ public async Task Sampling_Stdio(string clientId)
411411 // });
412412
413413 // // Connect
414- // await client.ConnectAsync(CancellationToken.None );
414+ // await client.ConnectAsync(TestContext.Current.CancellationToken );
415415
416416 // // assert
417417 // // nothing to assert, no servers implement roots, so we if no exception is thrown, it's a success
@@ -560,7 +560,7 @@ public async Task SetLoggingLevel_ReceivesLoggingMessages(string clientId)
560560 } ) ;
561561
562562 // act
563- await client . SetLoggingLevel ( LoggingLevel . Debug , CancellationToken . None ) ;
563+ await client . SetLoggingLevel ( LoggingLevel . Debug , TestContext . Current . CancellationToken ) ;
564564
565565 // assert
566566 await receivedNotification . Task ;
0 commit comments