|
8 | 8 | using CloudConvert.API.Models.JobModels; |
9 | 9 | using System; |
10 | 10 | using System.Net.Http; |
| 11 | +using CloudConvert.API.Models.TaskOperations; |
| 12 | +using System.Collections.Generic; |
11 | 13 |
|
12 | 14 | namespace CloudConvert.Test |
13 | 15 | { |
@@ -83,6 +85,49 @@ public async Task CreateJob(string streamingMethod) |
83 | 85 | await File.WriteAllBytesAsync(fileExport.Filename, fileBytes); |
84 | 86 | } |
85 | 87 |
|
| 88 | + |
| 89 | + [Test] |
| 90 | + public async Task CreateJobWithOptions() |
| 91 | + { |
| 92 | + var job = await _cloudConvertAPI.CreateJobAsync(new JobCreateRequest |
| 93 | + { |
| 94 | + Tasks = new |
| 95 | + { |
| 96 | + import_it = new ImportUploadCreateRequest(), |
| 97 | + convert_it = new ConvertCreateRequest |
| 98 | + { |
| 99 | + Input = "import_it", |
| 100 | + Input_Format = "pdf", |
| 101 | + Output_Format = "jpg", |
| 102 | + Options = new Dictionary<string, object> { |
| 103 | + { "width", 800 }, |
| 104 | + { "height", 600 }, |
| 105 | + { "fit", "max" } |
| 106 | + } |
| 107 | + } |
| 108 | + }, |
| 109 | + Tag = "integration-test-convert-with-options" |
| 110 | + }); |
| 111 | + |
| 112 | + var uploadTask = job.Data.Tasks.FirstOrDefault(t => t.Name == "import_it"); |
| 113 | + |
| 114 | + var path = AppDomain.CurrentDomain.BaseDirectory + @"TestFiles/input.pdf"; |
| 115 | + |
| 116 | + byte[] file = File.ReadAllBytes(path); |
| 117 | + await _cloudConvertAPI.UploadAsync(uploadTask.Result.Form.Url.ToString(), file, "input.pdf", uploadTask.Result.Form.Parameters); |
| 118 | + |
| 119 | + |
| 120 | + // get created convert task |
| 121 | + |
| 122 | + var convertTask = await _cloudConvertAPI.GetTaskAsync(job.Data.Tasks.FirstOrDefault(t => t.Name == "convert_it").Id, "payload"); |
| 123 | + var payload = ((Newtonsoft.Json.Linq.JObject)convertTask.Data.Payload).ToObject<Dictionary<string, object>>(); |
| 124 | + Assert.IsNotNull(payload); |
| 125 | + Assert.AreEqual(800, payload["width"]); |
| 126 | + Assert.AreEqual(600, payload["height"]); |
| 127 | + Assert.AreEqual("max", payload["fit"]); |
| 128 | + |
| 129 | + } |
| 130 | + |
86 | 131 | [TestCase("stream")] |
87 | 132 | [TestCase("bytes")] |
88 | 133 | public async Task CreateTask(string streamingMethod) |
|
0 commit comments