@@ -21,42 +21,51 @@ public sealed class MediaInputTest(ITestOutputHelper output) : IntegrationTest(o
2121{
2222 private const string WorkflowWithConversationFileName = "MediaInputConversation.yaml" ;
2323 private const string WorkflowWithAutoSendFileName = "MediaInputAutoSend.yaml" ;
24- private const string PdfReference = "https://sample-files.com/downloads/documents/pdf/basic-text.pdf" ;
2524 private const string ImageReference = "https://sample-files.com/downloads/images/jpg/web_optimized_1200x800_97kb.jpg" ;
25+ private const string PdfReference = "https://sample-files.com/downloads/documents/pdf/basic-text.pdf" ;
2626
2727 [ Theory ]
28- [ InlineData ( ImageReference , "image/jpeg" , true , Skip = "Failing due to agent service bug." ) ]
29- [ InlineData ( ImageReference , "image/jpeg" , false , Skip = "Failing due to agent service bug." ) ]
28+ [ InlineData ( ImageReference , "image/jpeg" , true ) ]
29+ [ InlineData ( ImageReference , "image/jpeg" , false ) ]
3030 public async Task ValidateFileUrlAsync ( string fileSource , string mediaType , bool useConversation )
3131 {
32- this . Output . WriteLine ( $ "File: { ImageReference } ") ;
32+ // Arrange
33+ this . Output . WriteLine ( $ "File: { fileSource } ") ;
34+
35+ // Act & Assert
3336 await this . ValidateFileAsync ( new UriContent ( fileSource , mediaType ) , useConversation ) ;
3437 }
3538
3639 [ Theory ]
3740 [ InlineData ( ImageReference , "image/jpeg" , true ) ]
38- [ InlineData ( ImageReference , "image/jpeg" , false , Skip = "Failing due to agent service bug." ) ]
41+ [ InlineData ( ImageReference , "image/jpeg" , false ) ]
3942 [ InlineData ( PdfReference , "application/pdf" , true ) ]
4043 [ InlineData ( PdfReference , "application/pdf" , false ) ]
4144 public async Task ValidateFileDataAsync ( string fileSource , string mediaType , bool useConversation )
4245 {
46+ // Arrange
4347 byte [ ] fileData = await DownloadFileAsync ( fileSource ) ;
4448 string encodedData = Convert . ToBase64String ( fileData ) ;
4549 string fileUrl = $ "data:{ mediaType } ;base64,{ encodedData } ";
46- this . Output . WriteLine ( $ "Content: { fileUrl . Substring ( 0 , 112 ) } ...") ;
50+ this . Output . WriteLine ( $ "Content: { fileUrl . Substring ( 0 , Math . Min ( 112 , fileUrl . Length ) ) } ...") ;
51+
52+ // Act & Assert
4753 await this . ValidateFileAsync ( new DataContent ( fileUrl ) , useConversation ) ;
4854 }
4955
5056 [ Theory ]
51- [ InlineData ( PdfReference , "doc.pdf" , true , Skip = "Failing due to agent service bug." ) ]
52- [ InlineData ( PdfReference , "doc.pdf" , false , Skip = "Failing due to agent service bug." ) ]
57+ [ InlineData ( PdfReference , "doc.pdf" , true ) ]
58+ [ InlineData ( PdfReference , "doc.pdf" , false ) ]
5359 public async Task ValidateFileUploadAsync ( string fileSource , string documentName , bool useConversation )
5460 {
61+ // Arrange
5562 byte [ ] fileData = await DownloadFileAsync ( fileSource ) ;
5663 AIProjectClient client = new ( this . TestEndpoint , new AzureCliCredential ( ) ) ;
5764 using MemoryStream contentStream = new ( fileData ) ;
5865 OpenAIFileClient fileClient = client . GetProjectOpenAIClient ( ) . GetOpenAIFileClient ( ) ;
5966 OpenAIFile fileInfo = await fileClient . UploadFileAsync ( contentStream , documentName , FileUploadPurpose . Assistants ) ;
67+
68+ // Act & Assert
6069 try
6170 {
6271 this . Output . WriteLine ( $ "File: { fileInfo . Id } ") ;
@@ -77,6 +86,7 @@ private static async Task<byte[]> DownloadFileAsync(string uri)
7786
7887 private async Task ValidateFileAsync ( AIContent fileContent , bool useConversation )
7988 {
89+ // Act
8090 AgentProvider agentProvider = AgentProvider . Create ( this . Configuration , AgentProvider . Names . Vision ) ;
8191 await agentProvider . CreateAgentsAsync ( ) . ConfigureAwait ( false ) ;
8292
@@ -93,6 +103,8 @@ private async Task ValidateFileAsync(AIContent fileContent, bool useConversation
93103
94104 WorkflowHarness harness = new ( workflow , runId : Path . GetFileNameWithoutExtension ( workflowFileName ) ) ;
95105 WorkflowEvents workflowEvents = await harness . RunWorkflowAsync ( inputMessage ) . ConfigureAwait ( false ) ;
106+
107+ // Assert
96108 Assert . Equal ( useConversation ? 1 : 2 , workflowEvents . ConversationEvents . Count ) ;
97109 this . Output . WriteLine ( "CONVERSATION: " + workflowEvents . ConversationEvents [ 0 ] . ConversationId ) ;
98110 AgentResponseEvent agentResponseEvent = Assert . Single ( workflowEvents . AgentResponseEvents ) ;
0 commit comments