@@ -67,6 +67,33 @@ public async Task AudioTranscription_NoStreaming_Succeeds_WithTemperature()
6767 Console . WriteLine ( $ "Response: { content } ") ;
6868 }
6969
70+ [ Test ]
71+ public async Task AudioTranscription_NoStreaming_InValidFile ( )
72+ {
73+ var audioClient = await model ! . GetAudioClientAsync ( ) ;
74+ await Assert . That ( audioClient ) . IsNotNull ( ) ;
75+
76+ audioClient . Settings . Language = "en" ;
77+
78+ var audioFilePath = Path . Combine ( AppContext . BaseDirectory , "testdata/non_exist_Recording.mp3" ) ;
79+
80+ FoundryLocalException ? caught = null ;
81+ try
82+ {
83+ await audioClient . TranscribeAudioAsync ( audioFilePath ) . ConfigureAwait ( false ) ;
84+ }
85+ catch ( FoundryLocalException ex )
86+ {
87+ caught = ex ;
88+ }
89+
90+ // Assert: a FoundryLocalException must have been thrown
91+ await Assert . That ( caught ) . IsNotNull ( ) ;
92+ Console . WriteLine ( $ "Caught exception: { caught } ") ;
93+ await Assert . That ( caught ! . Message ) . Contains ( "Audio file not found" ) ;
94+
95+ }
96+
7097 [ Test ]
7198 public async Task AudioTranscription_Streaming_Succeeds ( )
7299 {
@@ -123,4 +150,33 @@ public async Task AudioTranscription_Streaming_Succeeds_WithTemperature()
123150
124151
125152 }
153+
154+ [ Test ]
155+ public async Task AudioTranscription_Streaming_InvalidFiles ( )
156+ {
157+ var audioClient = await model ! . GetAudioClientAsync ( ) ;
158+ await Assert . That ( audioClient ) . IsNotNull ( ) ;
159+
160+ audioClient . Settings . Language = "en" ;
161+
162+ var audioFilePath = Path . Combine ( AppContext . BaseDirectory , "testdata/Record.mp3" ) ;
163+
164+ FoundryLocalException ? caught = null ;
165+ try
166+ {
167+ await foreach ( var _ in audioClient . TranscribeAudioStreamingAsync ( audioFilePath , CancellationToken . None ) . ConfigureAwait ( false ) )
168+ {
169+ }
170+ }
171+ catch ( FoundryLocalException ex )
172+ {
173+ caught = ex ;
174+ }
175+
176+ // Assert: a FoundryLocalException must have been thrown
177+ await Assert . That ( caught ) . IsNotNull ( ) ;
178+ Console . WriteLine ( $ "Caught exception: { caught } ") ;
179+ await Assert . That ( caught ! . Message ) . Contains ( "Audio file not found" ) ;
180+
181+ }
126182}
0 commit comments