forked from fsprojects/FSharp.Data.GraphQL
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLocalProviderTests.fs
More file actions
533 lines (457 loc) · 24.9 KB
/
LocalProviderTests.fs
File metadata and controls
533 lines (457 loc) · 24.9 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
module FSharp.Data.GraphQL.IntegrationTests.LocalProviderTests
open Xunit
open System.Threading.Tasks
open FSharp.Data.GraphQL
open Helpers
let [<Literal>] ServerUrl = "http://localhost:8085"
let [<Literal>] EmptyGuidAsString = "00000000-0000-0000-0000-000000000000"
type Provider = GraphQLProvider<ServerUrl, uploadInputTypeName = "File", explicitOptionalParameters = false>
// type FileProvider = GraphQLProvider<ServerUrl, uploadInputTypeName = "FileType", explicitOptionalParameters = true>
let context = Provider.GetContext(ServerUrl)
type Input = Provider.Types.Input
type InputField = Provider.Types.InputField
module SimpleOperation =
let operation =
Provider.Operation<"""query Q($input: Input) {
echo(input: $input) {
single {
...Field
}
list {
...Field
}
}
}
fragment Field on OutputField {
string
stringOption
int
intOption
uri
deprecated
guid
}""">()
type Operation = Provider.Operations.Q
let validateResult (input : Input option) (result : Operation.OperationResult) =
result |> checkRequestTypeHeader "Classic"
result.Data.IsSome |> equals true
input |> Option.iter (fun input ->
result.Data.Value.Echo.IsSome |> equals true
input.List |> Option.iter (fun list ->
result.Data.Value.Echo.Value.List.IsSome |> equals true
let input = list |> Array.map (fun x -> x.Int, x.IntOption, x.String, x.StringOption, x.Uri, x.Guid.ToString())
let output = result.Data.Value.Echo.Value.List.Value |> Array.map (fun x -> x.Int, x.IntOption, x.String, x.StringOption, x.Uri, x.Guid)
input |> equals output)
input.Single |> Option.iter (fun single ->
result.Data.Value.Echo.Value.Single.IsSome |> equals true
let input = single.Int, single.IntOption, single.String, single.StringOption, single.Uri, single.Guid.ToString()
let output = result.Data.Value.Echo.Value.Single.Value |> map (fun x -> x.Int, x.IntOption, x.String, x.StringOption, x.Uri, x.Guid)
input |> equals output))
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query without sending input field``() =
SimpleOperation.operation.Run()
|> SimpleOperation.validateResult None
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query using context, without sending input field``() =
SimpleOperation.operation.Run(context)
|> SimpleOperation.validateResult None
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query without sending input field asynchronously``() : Task = task {
let! result = SimpleOperation.operation.AsyncRun()
result |> SimpleOperation.validateResult None
}
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query using context, without sending input field, asynchronously``() : Task = task {
let! result = SimpleOperation.operation.AsyncRun(context)
result |> SimpleOperation.validateResult None
}
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query sending an empty input field``() =
let input = Input()
SimpleOperation.operation.Run(input)
|> SimpleOperation.validateResult (Some input)
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query using context, sending an empty input field``() =
let input = Input()
SimpleOperation.operation.Run(context, input)
|> SimpleOperation.validateResult (Some input)
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query without sending an empty input field asynchronously``() : Task = task {
let input = Input()
let! result = SimpleOperation.operation.AsyncRun(input)
result |> SimpleOperation.validateResult (Some input)
}
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query using context, sending an empty input field, asynchronously``() : Task = task {
let input = Input()
let! result = SimpleOperation.operation.AsyncRun(context, input)
result |> SimpleOperation.validateResult (Some input)
}
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query sending an input field with single field``() =
let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString)
let input = Input(single)
SimpleOperation.operation.Run(input)
|> SimpleOperation.validateResult (Some input)
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query using context, sending an input field with single field``() =
let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString)
let input = Input(single)
SimpleOperation.operation.Run(context, input)
|> SimpleOperation.validateResult (Some input)
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query without sending an input field with single field asynchronously``() : Task = task {
let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString)
let input = Input(single)
let! result = SimpleOperation.operation.AsyncRun(input)
result |> SimpleOperation.validateResult (Some input)
}
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query using context, sending an input field with single field, asynchronously``() : Task = task {
let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString)
let input = Input(single)
let! result = SimpleOperation.operation.AsyncRun(context, input)
result |> SimpleOperation.validateResult (Some input)
}
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query sending an input field with list field``() =
let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|]
let input = Input(list)
SimpleOperation.operation.Run(input)
|> SimpleOperation.validateResult (Some input)
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query using context, sending an input field with list field``() =
let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|]
let input = Input(list)
SimpleOperation.operation.Run(context, input)
|> SimpleOperation.validateResult (Some input)
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query without sending an input field with list field asynchronously``() : Task = task {
let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|]
let input = Input(list)
let! result = SimpleOperation.operation.AsyncRun(input)
result |> SimpleOperation.validateResult (Some input)
}
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query using context, sending an input field with list field, asynchronously``() : Task = task {
let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|]
let input = Input(list)
let! result = SimpleOperation.operation.AsyncRun(context, input)
result |> SimpleOperation.validateResult (Some input)
}
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query sending an input field with single and list fields``() =
let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString)
let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|]
let input = Input(single, list)
SimpleOperation.operation.Run(input)
|> SimpleOperation.validateResult (Some input)
[<Fact; Trait("Execution", "Sync")>]
let ``Should be able to execute a query using context, sending an input field with single and list fields``() =
let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString)
let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|]
let input = Input(single, list)
SimpleOperation.operation.Run(context, input)
|> SimpleOperation.validateResult (Some input)
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query without sending an input field with single and list fields asynchronously``() : Task = task {
let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString)
let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|]
let input = Input(single, list)
let! result = SimpleOperation.operation.AsyncRun(input)
result |> SimpleOperation.validateResult (Some input)
}
[<Fact; Trait("Execution", "Async")>]
let ``Should be able to execute a query using context, sending an input field with single and list fields, asynchronously``() : Task = task {
let single = InputField("A", 2, System.Uri("http://localhost:1234"), EmptyGuidAsString)
let list = [|InputField("A", 2, System.Uri("http://localhost:4321"), EmptyGuidAsString)|]
let input = Input(single, list)
let! result = SimpleOperation.operation.AsyncRun(context, input)
result |> SimpleOperation.validateResult (Some input)
}
module SingleRequiredUploadOperation =
let operation =
Provider.Operation<"""mutation SingleUpload($file: File!) {
singleUpload(file: $file) {
name
contentType
contentAsText
}
}""">()
type Operation = Provider.Operations.SingleUpload
let validateResult (file : File) (result : Operation.OperationResult) =
result |> checkRequestTypeHeader "Multipart"
result.Data.IsSome |> equals true
result.Data.Value.SingleUpload.Name |> equals file.Name
result.Data.Value.SingleUpload.ContentAsText |> equals file.Content
result.Data.Value.SingleUpload.ContentType |> equals file.ContentType
[<Fact>]
let ``Should be able to execute a single required upload``() =
let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" }
SingleRequiredUploadOperation.operation.Run(file.MakeUpload())
|> SingleRequiredUploadOperation.validateResult file
[<Fact>]
let ``Should be able to execute a single required upload asynchronously``() : Task = task {
let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" }
let! result = SingleRequiredUploadOperation.operation.AsyncRun(file.MakeUpload())
result |> SingleRequiredUploadOperation.validateResult file
}
module SingleOptionalUploadOperation =
let operation =
Provider.Operation<"""mutation NullableSingleUpload($file: File) {
nullableSingleUpload(file: $file) {
name
contentType
contentAsText
}
}""">()
type Operation = Provider.Operations.NullableSingleUpload
let validateResult (file : File option) (result : Operation.OperationResult) =
result |> checkRequestTypeHeader "Multipart"
result.Data.IsSome |> equals true
file |> Option.iter (fun file ->
result.Data.Value.NullableSingleUpload.IsSome |> equals true
result.Data.Value.NullableSingleUpload.Value.Name |> equals file.Name
result.Data.Value.NullableSingleUpload.Value.ContentAsText |> equals file.Content
result.Data.Value.NullableSingleUpload.Value.ContentType |> equals file.ContentType)
[<Fact>]
let ``Should be able to execute a single optional upload by passing a file``() =
let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" }
SingleOptionalUploadOperation.operation.Run(file.MakeUpload())
|> SingleOptionalUploadOperation.validateResult (Some file)
[<Fact()>]
let ``Should be able to execute a single optional upload by passing a file, asynchronously``() : Task = task {
let file = { Name = "file.txt"; ContentType = "text/plain"; Content = "Sample text file contents" }
let! result = SingleOptionalUploadOperation.operation.AsyncRun(file.MakeUpload())
result |> SingleOptionalUploadOperation.validateResult (Some file)
}
[<Fact()>]
let ``Should be able to execute a single optional upload by not passing a file``() =
SingleOptionalUploadOperation.operation.Run()
|> SingleOptionalUploadOperation.validateResult None
[<Fact>]
let ``Should be able to execute a single optional upload by not passing a file asynchronously``() : Task = task {
let! result = SingleOptionalUploadOperation.operation.AsyncRun()
result |> SingleOptionalUploadOperation.validateResult None
}
module RequiredMultipleUploadOperation =
let operation =
Provider.Operation<"""mutation MultipleUpload($files: [File!]!) {
multipleUpload(files: $files) {
name
contentType
contentAsText
}
}""">()
type Operation = Provider.Operations.MultipleUpload
let validateResult (files : File []) (result : Operation.OperationResult) =
result |> checkRequestTypeHeader "Multipart"
result.Data.IsSome |> equals true
let receivedFiles =
result.Data.Value.MultipleUpload
|> Array.map (fun file -> { Name = file.Name; ContentType = file.ContentType; Content = file.ContentAsText })
receivedFiles |> equals files
[<Fact>]
let ``Should be able to execute a multiple required upload``() =
let files =
[| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" }
{ Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |]
RequiredMultipleUploadOperation.operation.Run(files |> Array.map (fun f -> f.MakeUpload()))
|> RequiredMultipleUploadOperation.validateResult files
[<Fact>]
let ``Should be able to execute a multiple required upload asynchronously``() : Task = task {
let files =
[| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" }
{ Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |]
let! result = RequiredMultipleUploadOperation.operation.AsyncRun(files |> Array.map (fun f -> f.MakeUpload()))
result |> RequiredMultipleUploadOperation.validateResult files
}
module OptionalMultipleUploadOperation =
let operation =
Provider.Operation<"""mutation NullableMultipleUpload($files: [File!]) {
nullableMultipleUpload(files: $files) {
name
contentType
contentAsText
}
}""">()
type Operation = Provider.Operations.NullableMultipleUpload
let validateResult (files : File [] option) (result : Operation.OperationResult) =
result |> checkRequestTypeHeader "Multipart"
result.Data.IsSome |> equals true
let receivedFiles =
result.Data.Value.NullableMultipleUpload
|> Option.map (Array.map (fun file -> { Name = file.Name; ContentType = file.ContentType; Content = file.ContentAsText }))
receivedFiles |> equals files
[<Fact>]
let ``Should be able to execute a multiple upload``() =
let files =
[| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" }
{ Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |]
OptionalMultipleUploadOperation.operation.Run(files |> Array.map (fun f -> f.MakeUpload()))
|> OptionalMultipleUploadOperation.validateResult (Some files)
[<Fact>]
let ``Should be able to execute a multiple upload asynchronously``() : Task = task {
let files =
[| { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" }
{ Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |]
let! result = OptionalMultipleUploadOperation.operation.AsyncRun(files |> Array.map (fun f -> f.MakeUpload()))
result |> OptionalMultipleUploadOperation.validateResult (Some files)
}
[<Fact>]
let ``Should be able to execute a multiple upload by sending no uploads``() =
OptionalMultipleUploadOperation.operation.Run()
|> OptionalMultipleUploadOperation.validateResult None
[<Fact>]
let ``Should be able to execute a multiple upload asynchronously by sending no uploads``() : Task = task {
let! result = OptionalMultipleUploadOperation.operation.AsyncRun()
result |> OptionalMultipleUploadOperation.validateResult None
}
module OptionalMultipleOptionalUploadOperation =
let operation =
Provider.Operation<"""mutation NullableMultipleNullableUpload($files: [File]) {
nullableMultipleNullableUpload(files: $files) {
name
contentType
contentAsText
}
}""">()
type Operation = Provider.Operations.NullableMultipleNullableUpload
let validateResult (files : File option [] option) (result : Operation.OperationResult) =
result |> checkRequestTypeHeader "Multipart"
result.Data.IsSome |> equals true
let receivedFiles =
result.Data.Value.NullableMultipleNullableUpload
|> Option.map (Array.map (Option.map (fun file -> { Name = file.Name; ContentType = file.ContentType; Content = file.ContentAsText })))
receivedFiles |> equals files
[<Fact>]
let ``Should be able to execute a multiple optional upload``() =
let files =
[| Some { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" }
Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |]
OptionalMultipleOptionalUploadOperation.operation.Run(files |> Array.map (Option.map (fun f -> f.MakeUpload())))
|> OptionalMultipleOptionalUploadOperation.validateResult (Some files)
[<Fact>]
let ``Should be able to execute a multiple optional upload asynchronously``() : Task = task {
let files =
[| Some { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" }
Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" } |]
let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(files |> Array.map (Option.map (fun f -> f.MakeUpload())))
result |> (OptionalMultipleOptionalUploadOperation.validateResult (Some files))
}
[<Fact>]
let ``Should be able to execute a multiple optional upload by sending no uploads``() =
OptionalMultipleOptionalUploadOperation.operation.Run()
|> OptionalMultipleOptionalUploadOperation.validateResult None
[<Fact>]
let ``Should be able to execute a multiple optional upload asynchronously by sending no uploads``() : Task = task {
let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun()
result |> OptionalMultipleOptionalUploadOperation.validateResult None
}
[<Fact>]
let ``Should be able to execute a multiple optional upload by sending some uploads``() =
let files =
[| Some { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" }
None
Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" }
None |]
OptionalMultipleOptionalUploadOperation.operation.Run(files |> Array.map (Option.map (fun f -> f.MakeUpload())))
|> OptionalMultipleOptionalUploadOperation.validateResult (Some files)
[<Fact>]
let ``Should be able to execute a multiple optional upload asynchronously by sending some uploads``() : Task = task {
let files =
[| Some { Name = "file1.txt"; ContentType = "text/plain"; Content = "Sample text file contents 1" }
None
Some { Name = "file2.txt"; ContentType = "text/plain"; Content = "Sample text file contents 2" }
None |]
let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun(files |> Array.map (Option.map (fun f -> f.MakeUpload())))
result |> OptionalMultipleOptionalUploadOperation.validateResult (Some files)
}
module UploadRequestOperation =
let operation =
Provider.Operation<"""mutation UploadRequestOperation($request: UploadRequest!) {
uploadRequest(request: $request) {
single {
...File
}
multiple {
...File
}
nullableMultiple {
...File
}
nullableMultipleNullable {
...File
}
}
}
fragment File on UploadedFile {
name
contentType
contentAsText
}""">()
type Operation = Provider.Operations.UploadRequestOperation
type Request = Provider.Types.UploadRequest
let validateResult (request : FilesRequest) (result : Operation.OperationResult) =
result |> checkRequestTypeHeader "Multipart"
result.Data.IsSome |> equals true
result.Data.Value.UploadRequest.Single.ToDictionary() |> File.FromDictionary |> equals request.Single
result.Data.Value.UploadRequest.Multiple |> Array.map ((fun x -> x.ToDictionary()) >> File.FromDictionary) |> equals request.Multiple
result.Data.Value.UploadRequest.NullableMultiple |> Option.map (Array.map ((fun x -> x.ToDictionary()) >> File.FromDictionary)) |> equals request.NullableMultiple
result.Data.Value.UploadRequest.NullableMultipleNullable |> Option.map (Array.map (Option.map ((fun x -> x.ToDictionary()) >> File.FromDictionary))) |> equals request.NullableMultipleNullable
[<Fact>]
let ``Should be able to upload files inside another input type``() : Task = task {
let request =
{ Single = { Name = "single.txt"; ContentType = "text/plain"; Content = "Single file content" }
Multiple =
[| { Name = "multiple1.txt"; ContentType = "text/plain"; Content = "Multiple files first file content" }
{ Name = "multiple2.txt"; ContentType = "text/plain"; Content = "Multiple files second file content" } |]
NullableMultiple = Some [| { Name = "multiple3.txt"; ContentType = "text/plain"; Content = "Multiple files third file content" } |]
NullableMultipleNullable =
Some [| Some { Name = "multiple4.txt"; ContentType = "text/plain"; Content = "Multiple files fourth file content" }; None |] }
let input =
let makeUpload (x : File) = x.MakeUpload()
UploadRequestOperation.Request(single = makeUpload request.Single,
multiple = Array.map makeUpload request.Multiple,
nullableMultiple = Array.map makeUpload request.NullableMultiple.Value,
nullableMultipleNullable = Array.map (Option.map makeUpload) request.NullableMultipleNullable.Value)
let! result = UploadRequestOperation.operation.AsyncRun(input)
result |> UploadRequestOperation.validateResult request
}
module UploadComplexOperation =
let operation =
Provider.Operation<"""mutation UploadComplex($input: InputFile!) {
uploadComplex(input: $input)
}""">()
type Operation = Provider.Operations.UploadComplex
type InputFile = Provider.Types.InputFile
let validateResult (file : File) (result : Operation.OperationResult) =
result |> checkRequestTypeHeader "Multipart"
result.Data.IsSome |> equals true
result.Data.Value.UploadComplex |> equals file.Content
[<Fact>]
let ``Should be able to upload file using complex input object`` () =
let file = { Name = "complex.txt"; ContentType = "text/plain"; Content = "Complex input object file content" }
let input = UploadComplexOperation.InputFile(file = file.MakeUpload())
UploadComplexOperation.operation.Run(input)
|> UploadComplexOperation.validateResult file
[<Fact>]
let ``Should be able to upload file using complex input object with context`` () =
let file = { Name = "complex_context.txt"; ContentType = "text/plain"; Content = "Complex input with context file content" }
let input = UploadComplexOperation.InputFile(file = file.MakeUpload())
UploadComplexOperation.operation.Run(context, input)
|> UploadComplexOperation.validateResult file
[<Fact>]
let ``Should be able to upload file using complex input object asynchronously`` () : Task = task {
let file = { Name = "complex_async.txt"; ContentType = "text/plain"; Content = "Complex input object async file content" }
let input = UploadComplexOperation.InputFile(file = file.MakeUpload())
let! result = UploadComplexOperation.operation.AsyncRun(input)
result |> UploadComplexOperation.validateResult file
}
[<Fact>]
let ``Should be able to upload file using complex input object with context asynchronously`` () : Task = task {
let file = { Name = "complex_context_async.txt"; ContentType = "text/plain"; Content = "Complex input with context async file content" }
let input = UploadComplexOperation.InputFile(file = file.MakeUpload())
let! result = UploadComplexOperation.operation.AsyncRun(context, input)
result |> UploadComplexOperation.validateResult file
}