File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1212using System . Collections . Generic ;
1313using System . Dynamic ;
1414using System . Text . Json ;
15+ using System . Threading ;
1516
1617namespace CloudConvert . Test
1718{
@@ -27,6 +28,28 @@ public void Setup()
2728 _cloudConvertAPI = new CloudConvertAPI ( apiKey , true ) ;
2829 }
2930
31+ [ TestCase ( "cancellationtoken" ) ]
32+ public async Task CancellationToken ( string streamingMethod )
33+ {
34+ using var cts = new CancellationTokenSource ( ) ;
35+ var token = cts . Token ;
36+
37+ cts . Cancel ( ) ;
38+
39+ try
40+ {
41+ await _cloudConvertAPI . CreateJobAsync ( new JobCreateRequest
42+ {
43+ Tasks = new ( )
44+ } , token ) . ConfigureAwait ( false ) ;
45+
46+ Assert . Fail ( "Expected TaskCanceledException" ) ;
47+ }
48+ catch ( WebApiException ex ) when ( ex . InnerException is TaskCanceledException )
49+ {
50+ }
51+ }
52+
3053 [ TestCase ( "stream" ) ]
3154 [ TestCase ( "bytes" ) ]
3255 public async Task CreateJob ( string streamingMethod )
You can’t perform that action at this time.
0 commit comments