@@ -15,20 +15,23 @@ public class CancelledNotificationTests(
1515    public  async  Task  NotifyCancelAsync_SendsCorrectNotification ( ) 
1616    { 
1717        // Arrange 
18-         await   using   var  endpoint  =  fixture . CreateEndpoint ( ) ; 
19-         await   using   var  transport  =  fixture . CreateTransport ( ) ; 
20-         var  cancellationToken  =  TestContext . Current . CancellationToken ; 
21-         endpoint . Start ( transport ,   cancellationToken ) ; 
18+         var  token  =  TestContext . Current . CancellationToken ; 
19+         var  clientTransport  =  fixture . CreateClientTransport ( ) ; 
20+         await   using   var  endpoint  =  await   fixture . CreateClientEndpointAsync ( clientTransport ) ; 
21+         var   transport   =   await   clientTransport . ConnectAsync ( token ) ; 
2222
2323        var  requestId  =  new  RequestId ( "test-request-id-123" ) ; 
2424        const  string  reason  =  "Operation was cancelled by the user" ; 
2525
2626        // Act 
27-         await  endpoint . NotifyCancelAsync ( requestId ,  reason ,  cancellationToken ) ; 
27+         await  endpoint . NotifyCancelAsync ( requestId ,  reason ,  token ) ; 
2828
2929        // Assert 
30-         Assert . Single ( transport . SentMessages ) ; 
31-         var  notification  =  Assert . IsType < JsonRpcNotification > ( transport . SentMessages [ 0 ] ) ; 
30+         Assert . Equal ( 1 ,  transport . MessageReader . Count ) ; 
31+         var  message  =  await  transport . MessageReader . ReadAsync ( token ) ; 
32+         Assert . NotNull ( message ) ; 
33+ 
34+         var  notification  =  Assert . IsType < JsonRpcNotification > ( message ) ; 
3235        Assert . Equal ( NotificationMethods . CancelledNotification ,  notification . Method ) ; 
3336
3437        var  cancelParams  =  Assert . IsType < CancelledNotification > ( notification . Params ) ; 
@@ -40,10 +43,10 @@ public async Task NotifyCancelAsync_SendsCorrectNotification()
4043    public  async  Task  SendRequestAsync_Cancellation_SendsNotification ( ) 
4144    { 
4245        // Arrange 
43-         await   using   var  endpoint  =  fixture . CreateEndpoint ( ) ; 
44-         await   using   var  transport  =  fixture . CreateTransport ( ) ; 
45-         endpoint . Start ( transport ,   CancellationToken . None ) ; 
46-         
46+         var  token  =  TestContext . Current . CancellationToken ; 
47+         var  clientTransport  =  fixture . CreateClientTransport ( ) ; 
48+         await   using   var   endpoint   =   await   fixture . CreateClientEndpointAsync ( clientTransport ) ; 
49+         var   transport   =   await   clientTransport . ConnectAsync ( token ) ; 
4750        var  requestId  =  new  RequestId ( "test-request-id-123" ) ; 
4851        JsonRpcRequest  request  =  new ( ) 
4952        { 
@@ -68,15 +71,19 @@ public async Task SendRequestAsync_Cancellation_SendsNotification()
6871        } 
6972
7073        // Assert 
71-         Assert . NotEmpty ( transport . SentMessages ) ; 
72-         Assert . Equal ( 2 ,  transport . SentMessages . Count ) ; 
73-         var  notification  =  Assert . IsType < JsonRpcNotification > ( transport . SentMessages [ 0 ] ) ; 
74+         Assert . Equal ( 2 ,  transport . MessageReader . Count ) ; 
75+         var  message  =  await  transport . MessageReader . ReadAsync ( token ) ; 
76+         Assert . NotNull ( message ) ; 
77+ 
78+         var  notification  =  Assert . IsType < JsonRpcNotification > ( message ) ; 
7479        Assert . Equal ( NotificationMethods . CancelledNotification ,  notification . Method ) ; 
7580
7681        var  cancelParams  =  Assert . IsType < CancelledNotification > ( notification . Params ) ; 
7782        Assert . Equal ( requestId ,  cancelParams . RequestId ) ; 
7883
79-         var  requestMessage  =  Assert . IsType < JsonRpcRequest > ( transport . SentMessages [ 1 ] ) ; 
84+         message  =  await  transport . MessageReader . ReadAsync ( token ) ; 
85+         Assert . NotNull ( message ) ; 
86+         var  requestMessage  =  Assert . IsType < JsonRpcRequest > ( message ) ; 
8087        Assert . Equal ( request . Id ,  requestMessage . Id ) ; 
8188        Assert . Equal ( request . Method ,  requestMessage . Method ) ; 
8289        Assert . Equal ( request . Params ,  requestMessage . Params ) ; 
0 commit comments