@@ -134,13 +134,13 @@ public async Task ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagramAsync
134134 // create a dummy ILogger instance for testing
135135 var options = new HidiOptions
136136 {
137- OpenApi = Path . Combine ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
138- Output = new ( "sample .md")
137+ OpenApi = Path . Join ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
138+ Output = new ( $ " { nameof ( ShowCommandGeneratesMermaidMarkdownFileWithMermaidDiagramAsync ) } .md")
139139 } ;
140140
141- await OpenApiService . ShowOpenApiDocumentAsync ( options , _logger ) ;
141+ await OpenApiService . ShowOpenApiDocumentAsync ( options , _logger , TestContext . Current . CancellationToken ) ;
142142
143- var output = await File . ReadAllTextAsync ( options . Output . FullName ) ;
143+ var output = await File . ReadAllTextAsync ( options . Output . FullName , TestContext . Current . CancellationToken ) ;
144144 Assert . Contains ( "graph LR" , output , StringComparison . Ordinal ) ;
145145 }
146146
@@ -149,54 +149,54 @@ public async Task ShowCommandGeneratesMermaidHtmlFileWithMermaidDiagramAsync()
149149 {
150150 var options = new HidiOptions
151151 {
152- OpenApi = Path . Combine ( "UtilityFiles" , "SampleOpenApi.yml" )
152+ OpenApi = Path . Join ( "UtilityFiles" , "SampleOpenApi.yml" )
153153 } ;
154- var filePath = await OpenApiService . ShowOpenApiDocumentAsync ( options , _logger ) ;
154+ var filePath = await OpenApiService . ShowOpenApiDocumentAsync ( options , _logger , TestContext . Current . CancellationToken ) ;
155155 Assert . True ( File . Exists ( filePath ) ) ;
156156 }
157157
158158 [ Fact ]
159159 public Task ThrowIfOpenApiUrlIsNotProvidedWhenValidatingAsync ( )
160160 {
161161 return Assert . ThrowsAsync < ArgumentNullException > ( ( ) =>
162- OpenApiService . ValidateOpenApiDocumentAsync ( "" , _logger ) ) ;
162+ OpenApiService . ValidateOpenApiDocumentAsync ( "" , _logger , TestContext . Current . CancellationToken ) ) ;
163163 }
164164
165165 [ Fact ]
166166 public Task ThrowIfURLIsNotResolvableWhenValidatingAsync ( )
167167 {
168168 return Assert . ThrowsAsync < InvalidOperationException > ( ( ) =>
169- OpenApiService . ValidateOpenApiDocumentAsync ( "https://example.org926F4F21-88E7-4DC5-BF88-6C529BB77844/itdoesnmatter" , _logger ) ) ;
169+ OpenApiService . ValidateOpenApiDocumentAsync ( "https://example.org926F4F21-88E7-4DC5-BF88-6C529BB77844/itdoesnmatter" , _logger , TestContext . Current . CancellationToken ) ) ;
170170 }
171171
172172 [ Fact ]
173173 public Task ThrowIfFileDoesNotExistWhenValidatingAsync ( )
174174 {
175175 return Assert . ThrowsAsync < InvalidOperationException > ( ( ) =>
176- OpenApiService . ValidateOpenApiDocumentAsync ( "aFileThatBetterNotExist.fake" , _logger ) ) ;
176+ OpenApiService . ValidateOpenApiDocumentAsync ( "aFileThatBetterNotExist.fake" , _logger , TestContext . Current . CancellationToken ) ) ;
177177 }
178178
179179 [ Fact ]
180180 public async Task ValidateCommandProcessesOpenApiAsync ( )
181181 {
182182 // create a dummy ILogger instance for testing
183- await OpenApiService . ValidateOpenApiDocumentAsync ( Path . Combine ( "UtilityFiles" , "SampleOpenApi.yml" ) , _logger ) ;
183+ await OpenApiService . ValidateOpenApiDocumentAsync ( Path . Join ( "UtilityFiles" , "SampleOpenApi.yml" ) , _logger , TestContext . Current . CancellationToken ) ;
184184
185185 Assert . True ( true ) ;
186186 }
187187
188188 [ Fact ]
189189 public async Task ValidFileReturnsTrueAsync ( )
190190 {
191- var isValid = await OpenApiService . ValidateOpenApiDocumentAsync ( Path . Combine ( "UtilityFiles" , "SampleOpenApi.yml" ) , _logger ) ;
191+ var isValid = await OpenApiService . ValidateOpenApiDocumentAsync ( Path . Join ( "UtilityFiles" , "SampleOpenApi.yml" ) , _logger , TestContext . Current . CancellationToken ) ;
192192
193193 Assert . True ( isValid ) ;
194194 }
195195
196196 [ Fact ]
197197 public async Task InvalidFileReturnsFalseAsync ( )
198198 {
199- var isValid = await OpenApiService . ValidateOpenApiDocumentAsync ( Path . Combine ( "UtilityFiles" , "InvalidSampleOpenApi.yml" ) , _logger ) ;
199+ var isValid = await OpenApiService . ValidateOpenApiDocumentAsync ( Path . Join ( "UtilityFiles" , "InvalidSampleOpenApi.yml" ) , _logger , TestContext . Current . CancellationToken ) ;
200200
201201 Assert . False ( isValid ) ;
202202 }
@@ -206,7 +206,7 @@ public async Task CancellingValidationReturnsNullAsync()
206206 {
207207 using var cts = new CancellationTokenSource ( ) ;
208208 await cts . CancelAsync ( ) ;
209- var isValid = await OpenApiService . ValidateOpenApiDocumentAsync ( Path . Combine ( "UtilityFiles" , "SampleOpenApi.yml" ) , _logger , cts . Token ) ;
209+ var isValid = await OpenApiService . ValidateOpenApiDocumentAsync ( Path . Join ( "UtilityFiles" , "SampleOpenApi.yml" ) , _logger , cts . Token ) ;
210210
211211 Assert . Null ( isValid ) ;
212212 }
@@ -216,17 +216,17 @@ public async Task TransformCommandConvertsOpenApiAsync()
216216 {
217217 var options = new HidiOptions
218218 {
219- OpenApi = Path . Combine ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
220- Output = new ( "sample .json") ,
219+ OpenApi = Path . Join ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
220+ Output = new ( $ " { nameof ( TransformCommandConvertsOpenApiAsync ) } .json") ,
221221 CleanOutput = true ,
222222 TerseOutput = false ,
223223 InlineLocal = false ,
224224 InlineExternal = false ,
225225 } ;
226226 // create a dummy ILogger instance for testing
227- await OpenApiService . TransformOpenApiDocumentAsync ( options , _logger ) ;
227+ await OpenApiService . TransformOpenApiDocumentAsync ( options , _logger , TestContext . Current . CancellationToken ) ;
228228
229- var output = await File . ReadAllTextAsync ( "sample.json" ) ;
229+ var output = await File . ReadAllTextAsync ( options . Output . FullName , TestContext . Current . CancellationToken ) ;
230230 Assert . NotEmpty ( output ) ;
231231 }
232232
@@ -236,16 +236,17 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAsync()
236236 {
237237 var options = new HidiOptions
238238 {
239- OpenApi = Path . Combine ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
239+ OpenApi = Path . Join ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
240240 CleanOutput = true ,
241241 TerseOutput = false ,
242242 InlineLocal = false ,
243243 InlineExternal = false ,
244+ Output = new FileInfo ( $ "{ nameof ( TransformCommandConvertsOpenApiWithDefaultOutputNameAsync ) } .yml")
244245 } ;
245246 // create a dummy ILogger instance for testing
246- await OpenApiService . TransformOpenApiDocumentAsync ( options , _logger ) ;
247+ await OpenApiService . TransformOpenApiDocumentAsync ( options , _logger , TestContext . Current . CancellationToken ) ;
247248
248- var output = await File . ReadAllTextAsync ( "output.yml" ) ;
249+ var output = await File . ReadAllTextAsync ( options . Output . FullName , TestContext . Current . CancellationToken ) ;
249250 Assert . NotEmpty ( output ) ;
250251 }
251252
@@ -254,7 +255,8 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF
254255 {
255256 var options = new HidiOptions
256257 {
257- OpenApi = Path . Combine ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
258+ OpenApi = Path . Join ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
259+ Output = new ( $ "{ nameof ( TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchFormatAsync ) } .yml") ,
258260 CleanOutput = true ,
259261 Version = "3.0" ,
260262 OpenApiFormat = OpenApiConstants . Yaml ,
@@ -263,9 +265,9 @@ public async Task TransformCommandConvertsOpenApiWithDefaultOutputNameAndSwitchF
263265 InlineExternal = false ,
264266 } ;
265267 // create a dummy ILogger instance for testing
266- await OpenApiService . TransformOpenApiDocumentAsync ( options , _logger ) ;
268+ await OpenApiService . TransformOpenApiDocumentAsync ( options , _logger , TestContext . Current . CancellationToken ) ;
267269
268- var output = await File . ReadAllTextAsync ( "output.yml" ) ;
270+ var output = await File . ReadAllTextAsync ( options . Output . FullName , TestContext . Current . CancellationToken ) ;
269271 Assert . NotEmpty ( output ) ;
270272 }
271273
@@ -280,16 +282,17 @@ public Task ThrowTransformCommandIfOpenApiAndCsdlAreEmptyAsync()
280282 InlineExternal = false ,
281283 } ;
282284 return Assert . ThrowsAsync < ArgumentException > ( ( ) =>
283- OpenApiService . TransformOpenApiDocumentAsync ( options , _logger ) ) ;
285+ OpenApiService . TransformOpenApiDocumentAsync ( options , _logger , TestContext . Current . CancellationToken ) ) ;
284286 }
285287
286288 [ Fact ]
287289 public async Task TransformToPowerShellCompliantOpenApiAsync ( )
288290 {
289- var settingsPath = Path . Combine ( AppDomain . CurrentDomain . BaseDirectory , "UtilityFiles" , "examplepowershellsettings.json" ) ;
291+ var settingsPath = Path . Join ( AppDomain . CurrentDomain . BaseDirectory , "UtilityFiles" , "examplepowershellsettings.json" ) ;
290292 var options = new HidiOptions
291293 {
292- OpenApi = Path . Combine ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
294+ OpenApi = Path . Join ( "UtilityFiles" , "SampleOpenApi.yml" ) ,
295+ Output = new ( $ "{ nameof ( TransformToPowerShellCompliantOpenApiAsync ) } .yaml") ,
293296 CleanOutput = true ,
294297 Version = "3.0" ,
295298 OpenApiFormat = OpenApiConstants . Yaml ,
@@ -299,24 +302,25 @@ public async Task TransformToPowerShellCompliantOpenApiAsync()
299302 SettingsConfig = SettingsUtilities . GetConfiguration ( settingsPath )
300303 } ;
301304 // create a dummy ILogger instance for testing
302- await OpenApiService . TransformOpenApiDocumentAsync ( options , _logger ) ;
305+ await OpenApiService . TransformOpenApiDocumentAsync ( options , _logger , TestContext . Current . CancellationToken ) ;
303306
304- var output = await File . ReadAllTextAsync ( "output.yaml" ) ;
307+ var output = await File . ReadAllTextAsync ( options . Output . FullName , TestContext . Current . CancellationToken ) ;
305308 Assert . NotEmpty ( output ) ;
306309 }
307310
308311 [ Fact ]
309312 public async Task InvokeTransformCommandAsync ( )
310313 {
311314 var rootCommand = Program . CreateRootCommand ( ) ;
312- var openapi = Path . Combine ( "." , "UtilityFiles" , "SampleOpenApi.yml" ) ;
313- var args = new [ ] { "transform" , "-d" , openapi , "-o" , "sample.json" , "--co" } ;
315+ var openapi = Path . Join ( "." , "UtilityFiles" , "SampleOpenApi.yml" ) ;
316+ var outputPath = $ "{ nameof ( InvokeTransformCommandAsync ) } .json";
317+ var args = new [ ] { "transform" , "-d" , openapi , "-o" , outputPath , "--co" } ;
314318 var parseResult = rootCommand . Parse ( args ) ;
315319 var handler = Assert . IsType < AsynchronousCommandLineAction > ( rootCommand . Subcommands . First ( c => c . Name == "transform" ) . Action , exactMatch : false ) ;
316320
317- await handler . InvokeAsync ( parseResult ) ;
321+ await handler . InvokeAsync ( parseResult , TestContext . Current . CancellationToken ) ;
318322
319- var output = await File . ReadAllTextAsync ( "sample.json" ) ;
323+ var output = await File . ReadAllTextAsync ( outputPath , TestContext . Current . CancellationToken ) ;
320324 Assert . NotEmpty ( output ) ;
321325 }
322326
@@ -325,29 +329,31 @@ public async Task InvokeTransformCommandAsync()
325329 public async Task InvokeShowCommandAsync ( )
326330 {
327331 var rootCommand = Program . CreateRootCommand ( ) ;
328- var openApi = Path . Combine ( "." , "UtilityFiles" , "SampleOpenApi.yml" ) ;
329- var args = new [ ] { "show" , "-d" , openApi , "-o" , "sample.md" } ;
332+ var openApi = Path . Join ( "." , "UtilityFiles" , "SampleOpenApi.yml" ) ;
333+ var outputPath = $ "{ nameof ( InvokeShowCommandAsync ) } .md";
334+ var args = new [ ] { "show" , "-d" , openApi , "-o" , outputPath } ;
330335 var parseResult = rootCommand . Parse ( args ) ;
331336 var handler = Assert . IsType < AsynchronousCommandLineAction > ( rootCommand . Subcommands . First ( c => c . Name == "show" ) . Action , exactMatch : false ) ;
332337
333- await handler . InvokeAsync ( parseResult ) ;
338+ await handler . InvokeAsync ( parseResult , TestContext . Current . CancellationToken ) ;
334339
335- var output = await File . ReadAllTextAsync ( "sample.md" ) ;
340+ var output = await File . ReadAllTextAsync ( outputPath , TestContext . Current . CancellationToken ) ;
336341 Assert . Contains ( "graph LR" , output , StringComparison . Ordinal ) ;
337342 }
338343
339344 [ Fact ]
340345 public async Task InvokePluginCommandAsync ( )
341346 {
342347 var rootCommand = Program . CreateRootCommand ( ) ;
343- var manifest = Path . Combine ( "." , "UtilityFiles" , "exampleapimanifest.json" ) ;
344- var args = new [ ] { "plugin" , "-m" , manifest , "--of" , AppDomain . CurrentDomain . BaseDirectory } ;
348+ var manifest = Path . Join ( "." , "UtilityFiles" , "exampleapimanifest.json" ) ;
349+ var outputPath = Path . Join ( AppDomain . CurrentDomain . BaseDirectory , nameof ( InvokePluginCommandAsync ) ) ;
350+ var args = new [ ] { "plugin" , "-m" , manifest , "--of" , outputPath } ;
345351 var parseResult = rootCommand . Parse ( args ) ;
346352 var handler = Assert . IsType < AsynchronousCommandLineAction > ( rootCommand . Subcommands . First ( c => c . Name == "plugin" ) . Action , exactMatch : false ) ;
347353
348- await handler . InvokeAsync ( parseResult ) ;
354+ await handler . InvokeAsync ( parseResult , TestContext . Current . CancellationToken ) ;
349355
350- using var jsDoc = JsonDocument . Parse ( await File . ReadAllTextAsync ( "ai-plugin.json" ) ) ;
356+ using var jsDoc = JsonDocument . Parse ( await File . ReadAllTextAsync ( Path . Join ( outputPath , "ai-plugin.json" ) , TestContext . Current . CancellationToken ) ) ;
351357 var openAiManifest = OpenAIPluginManifest . Load ( jsDoc . RootElement ) ;
352358
353359 Assert . NotNull ( openAiManifest ) ;
0 commit comments