Skip to content

Commit d842282

Browse files
committed
add test for creating convert task with custom options
1 parent cd50ea7 commit d842282

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

CloudConvert.Test/IntegrationTests.cs

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
using CloudConvert.API.Models.JobModels;
99
using System;
1010
using System.Net.Http;
11+
using CloudConvert.API.Models.TaskOperations;
12+
using System.Collections.Generic;
1113

1214
namespace CloudConvert.Test
1315
{
@@ -83,6 +85,49 @@ public async Task CreateJob(string streamingMethod)
8385
await File.WriteAllBytesAsync(fileExport.Filename, fileBytes);
8486
}
8587

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+
86131
[TestCase("stream")]
87132
[TestCase("bytes")]
88133
public async Task CreateTask(string streamingMethod)

0 commit comments

Comments
 (0)