1+ using AwesomeAssertions . Specialized ;
2+ using Azure . Sdk . Tools . McpEvals . Evaluators ;
13using Azure . Sdk . Tools . McpEvals . Helpers ;
24using Microsoft . Extensions . AI ;
5+ using Microsoft . Extensions . AI . Evaluation ;
6+ using Microsoft . Extensions . AI . Evaluation . Quality ;
7+ using Microsoft . Extensions . AI . Evaluation . Reporting ;
8+ using Microsoft . Extensions . AI . Evaluation . Reporting . Formats . Html ;
9+ using Microsoft . Extensions . AI . Evaluation . Reporting . Storage ;
310using ModelContextProtocol . Client ;
411using NUnit . Framework ;
512
@@ -9,18 +16,48 @@ namespace Azure.Sdk.Tools.McpEvals.Scenarios
916 public partial class Scenario
1017 {
1118 // Static services shared across all tests
12- protected static IChatClient ? ChatClient ;
13- protected static IMcpClient ? McpClient ;
14- protected static ChatCompletion ? ChatCompletion ;
15- protected static IEnumerable < string > ToolNames ;
19+ protected static IChatClient ? s_chatClient ;
20+ protected static IMcpClient ? s_mcpClient ;
21+ protected static ChatCompletion ? s_chatCompletion ;
22+ protected static IEnumerable < string > s_toolNames ;
23+ protected static ReportingConfiguration s_reportingConfiguration ;
24+ protected static ChatConfiguration s_chatConfig ;
25+ private static string s_executionName ;
26+ private string ScenarioName => $ "{ TestContext . CurrentContext . Test . ClassName } .{ TestContext . CurrentContext . Test . Name } ";
27+ private string ReportingPath => Path . Combine ( TestContext . CurrentContext . TestDirectory , "reports" ) ;
28+
1629
1730 [ OneTimeSetUp ]
1831 public async Task GlobalSetup ( )
1932 {
20- ChatClient = TestSetup . GetChatClient ( ) ;
21- McpClient = await TestSetup . GetMcpClientAsync ( ) ;
22- ChatCompletion = TestSetup . GetChatCompletion ( ChatClient , McpClient ) ;
23- ToolNames = ( await McpClient . ListToolsAsync ( ) ) . Select ( tool => tool . Name ) ! ;
33+ s_chatClient = TestSetup . GetChatClient ( ) ;
34+ s_mcpClient = await TestSetup . GetMcpClientAsync ( ) ;
35+ s_chatConfig = new ChatConfiguration ( s_chatClient ) ;
36+ s_chatCompletion = TestSetup . GetChatCompletion ( s_chatClient , s_mcpClient ) ;
37+ s_toolNames = ( await s_mcpClient . ListToolsAsync ( ) ) . Select ( tool => tool . Name ) ! ;
38+ s_executionName = $ "{ DateTime . Now : yyyyMMddTHHmmss} ";
39+ }
40+
41+
42+ [ OneTimeTearDown ]
43+ public async Task GlobalTearDown ( )
44+ {
45+ // Generate a HTML report for all the evaluations run
46+ IEvaluationResultStore resultStore = new DiskBasedResultStore ( ReportingPath ) ;
47+ var allResults = new List < ScenarioRunResult > ( ) ;
48+
49+ await foreach ( string executionName in resultStore . GetLatestExecutionNamesAsync ( count : 1 ) )
50+ {
51+ await foreach ( ScenarioRunResult scenarioResult in resultStore . ReadResultsAsync ( executionName ) )
52+ {
53+ allResults . Add ( scenarioResult ) ;
54+ }
55+ }
56+
57+ var timestamp = DateTime . Now . ToString ( "yyyyMMdd_HHmmss" ) ;
58+ string reportFilePath = Path . Combine ( ReportingPath , $ "report-{ timestamp } .html") ;
59+ IEvaluationReportWriter reportWriter = new HtmlReportWriter ( reportFilePath ) ;
60+ await reportWriter . WriteReportAsync ( allResults ) ;
2461 }
2562 }
2663}
0 commit comments