11// Copyright (c) Microsoft. All rights reserved.
22
3- using System ;
43using System . Threading . Tasks ;
54
65namespace Microsoft . Extensions . AI . Agents . Runtime . InProcess . Tests ;
@@ -35,8 +34,7 @@ public async Task Test_PublishMessage_SingleFailureAsync()
3534 await fixture . RegisterErrorAgentAsync ( topicTypes : "TestTopic" ) ;
3635
3736 // Test that we wrap single errors appropriately
38- var e = await Assert . ThrowsAsync < AggregateException > ( async ( ) => await fixture . RunPublishTestAsync ( new TopicId ( "TestTopic" ) , new BasicMessage { Content = "1" } ) ) ;
39- Assert . IsType < TestException > ( Assert . Single ( e . InnerExceptions ) ) ;
37+ await Assert . ThrowsAsync < TestException > ( async ( ) => await fixture . RunPublishTestAsync ( new TopicId ( "TestTopic" ) , new BasicMessage { Content = "1" } ) ) ;
4038
4139 var values = fixture . GetAgentInstances < ReceiverAgent > ( ) . Values ;
4240 }
@@ -50,9 +48,7 @@ public async Task Test_PublishMessage_MultipleFailuresAsync()
5048 await fixture . RegisterErrorAgentAsync ( "2" , topicTypes : "TestTopic" ) ;
5149
5250 // What we are really testing here is that a single exception does not prevent sending to the remaining agents
53- var e = await Assert . ThrowsAsync < AggregateException > ( async ( ) => await fixture . RunPublishTestAsync ( new TopicId ( "TestTopic" ) , new BasicMessage { Content = "1" } ) ) ;
54- Assert . Equal ( 2 , e . InnerExceptions . Count ) ;
55- Assert . All ( e . InnerExceptions , innerException => Assert . IsType < TestException > ( innerException ) ) ;
51+ await Assert . ThrowsAsync < TestException > ( async ( ) => await fixture . RunPublishTestAsync ( new TopicId ( "TestTopic" ) , new BasicMessage { Content = "1" } ) ) ;
5652
5753 var values = fixture . GetAgentInstances < ErrorAgent > ( ) . Values ;
5854 Assert . Equal ( 2 , values . Count ) ;
@@ -70,9 +66,7 @@ public async Task Test_PublishMessage_MixedSuccessFailureAsync()
7066 await fixture . RegisterErrorAgentAsync ( "2" , topicTypes : "TestTopic" ) ;
7167
7268 // What we are really testing here is that raising exceptions does not prevent sending to the remaining agents
73- var e = await Assert . ThrowsAsync < AggregateException > ( async ( ) => await fixture . RunPublishTestAsync ( new TopicId ( "TestTopic" ) , new BasicMessage { Content = "1" } ) ) ;
74- Assert . Equal ( 2 , e . InnerExceptions . Count ) ;
75- Assert . All ( e . InnerExceptions , innerException => Assert . IsType < TestException > ( innerException ) ) ;
69+ await Assert . ThrowsAsync < TestException > ( async ( ) => await fixture . RunPublishTestAsync ( new TopicId ( "TestTopic" ) , new BasicMessage { Content = "1" } ) ) ;
7670
7771 var agents = fixture . GetAgentInstances < ReceiverAgent > ( ) . Values ;
7872 Assert . Equal ( 2 , agents . Count ) ;
0 commit comments