11module FSharp.Data.GraphQL.IntegrationTests.LocalProviderTests
22
33open Xunit
4- open Helpers
4+ open System. Threading . Tasks
55open FSharp.Data .GraphQL
6+ open Helpers
67
78let [<Literal>] ServerUrl = " http://localhost:8085"
89let [<Literal>] EmptyGuidAsString = " 00000000-0000-0000-0000-000000000000"
@@ -66,16 +67,16 @@ let ``Should be able to execute a query using context, without sending input fie
6667 |> SimpleOperation.validateResult None
6768
6869[<Fact>]
69- let ``Should be able to execute a query without sending input field asynchronously`` () =
70- SimpleOperation.operation.AsyncRun()
71- |> Async.RunSynchronously
72- |> SimpleOperation.validateResult None
70+ let ``Should be able to execute a query without sending input field asynchronously`` () : Task = task {
71+ let! result = SimpleOperation.operation.AsyncRun()
72+ result |> SimpleOperation.validateResult None
73+ }
7374
7475[<Fact>]
75- let ``Should be able to execute a query using context , without sending input field , asynchronously`` () =
76- SimpleOperation.operation.AsyncRun( context)
77- |> Async.RunSynchronously
78- |> SimpleOperation.validateResult None
76+ let ``Should be able to execute a query using context , without sending input field , asynchronously`` () : Task = task {
77+ let! result = SimpleOperation.operation.AsyncRun( context)
78+ result |> SimpleOperation.validateResult None
79+ }
7980
8081[<Fact>]
8182let ``Should be able to execute a query sending an empty input field`` () =
@@ -90,18 +91,18 @@ let ``Should be able to execute a query using context, sending an empty input fi
9091 |> SimpleOperation.validateResult ( Some input)
9192
9293[<Fact>]
93- let ``Should be able to execute a query without sending an empty input field asynchronously`` () =
94+ let ``Should be able to execute a query without sending an empty input field asynchronously`` () : Task = task {
9495 let input = Input()
95- SimpleOperation.operation.AsyncRun( input)
96- |> Async.RunSynchronously
97- |> SimpleOperation.validateResult ( Some input )
96+ let! result = SimpleOperation.operation.AsyncRun( input)
97+ result |> SimpleOperation.validateResult ( Some input )
98+ }
9899
99100[<Fact>]
100- let ``Should be able to execute a query using context , sending an empty input field , asynchronously`` () =
101+ let ``Should be able to execute a query using context , sending an empty input field , asynchronously`` () : Task = task {
101102 let input = Input()
102- SimpleOperation.operation.AsyncRun( context, input)
103- |> Async.RunSynchronously
104- |> SimpleOperation.validateResult ( Some input )
103+ let! result = SimpleOperation.operation.AsyncRun( context, input)
104+ result |> SimpleOperation.validateResult ( Some input )
105+ }
105106
106107[<Fact>]
107108let ``Should be able to execute a query sending an input field with single field`` () =
@@ -118,20 +119,20 @@ let ``Should be able to execute a query using context, sending an input field wi
118119 |> SimpleOperation.validateResult ( Some input)
119120
120121[<Fact>]
121- let ``Should be able to execute a query without sending an input field with single field asynchronously`` () =
122+ let ``Should be able to execute a query without sending an input field with single field asynchronously`` () : Task = task {
122123 let single = InputField( " A" , 2 , System.Uri( " http://localhost:1234" ), EmptyGuidAsString)
123124 let input = Input( single)
124- SimpleOperation.operation.AsyncRun( input)
125- |> Async.RunSynchronously
126- |> SimpleOperation.validateResult ( Some input )
125+ let! result = SimpleOperation.operation.AsyncRun( input)
126+ result |> SimpleOperation.validateResult ( Some input )
127+ }
127128
128129[<Fact>]
129- let ``Should be able to execute a query using context , sending an input field with single field , asynchronously`` () =
130+ let ``Should be able to execute a query using context , sending an input field with single field , asynchronously`` () : Task = task {
130131 let single = InputField( " A" , 2 , System.Uri( " http://localhost:1234" ), EmptyGuidAsString)
131132 let input = Input( single)
132- SimpleOperation.operation.AsyncRun( context, input)
133- |> Async.RunSynchronously
134- |> SimpleOperation.validateResult ( Some input )
133+ let! result = SimpleOperation.operation.AsyncRun( context, input)
134+ result |> SimpleOperation.validateResult ( Some input )
135+ }
135136
136137[<Fact>]
137138let ``Should be able to execute a query sending an input field with list field`` () =
@@ -148,20 +149,20 @@ let ``Should be able to execute a query using context, sending an input field wi
148149 |> SimpleOperation.validateResult ( Some input)
149150
150151[<Fact>]
151- let ``Should be able to execute a query without sending an input field with list field asynchronously`` () =
152+ let ``Should be able to execute a query without sending an input field with list field asynchronously`` () : Task = task {
152153 let list = [| InputField( " A" , 2 , System.Uri( " http://localhost:4321" ), EmptyGuidAsString)|]
153154 let input = Input( list)
154- SimpleOperation.operation.AsyncRun( input)
155- |> Async.RunSynchronously
156- |> SimpleOperation.validateResult ( Some input )
155+ let! result = SimpleOperation.operation.AsyncRun( input)
156+ result |> SimpleOperation.validateResult ( Some input )
157+ }
157158
158159[<Fact>]
159- let ``Should be able to execute a query using context , sending an input field with list field , asynchronously`` () =
160+ let ``Should be able to execute a query using context , sending an input field with list field , asynchronously`` () : Task = task {
160161 let list = [| InputField( " A" , 2 , System.Uri( " http://localhost:4321" ), EmptyGuidAsString)|]
161162 let input = Input( list)
162- SimpleOperation.operation.AsyncRun( context, input)
163- |> Async.RunSynchronously
164- |> SimpleOperation.validateResult ( Some input )
163+ let! result = SimpleOperation.operation.AsyncRun( context, input)
164+ result |> SimpleOperation.validateResult ( Some input )
165+ }
165166
166167[<Fact>]
167168let ``Should be able to execute a query sending an input field with single and list fields`` () =
@@ -180,22 +181,22 @@ let ``Should be able to execute a query using context, sending an input field wi
180181 |> SimpleOperation.validateResult ( Some input)
181182
182183[<Fact>]
183- let ``Should be able to execute a query without sending an input field with single and list fields asynchronously`` () =
184+ let ``Should be able to execute a query without sending an input field with single and list fields asynchronously`` () : Task = task {
184185 let single = InputField( " A" , 2 , System.Uri( " http://localhost:1234" ), EmptyGuidAsString)
185186 let list = [| InputField( " A" , 2 , System.Uri( " http://localhost:4321" ), EmptyGuidAsString)|]
186187 let input = Input( single, list)
187- SimpleOperation.operation.AsyncRun( input)
188- |> Async.RunSynchronously
189- |> SimpleOperation.validateResult ( Some input )
188+ let! result = SimpleOperation.operation.AsyncRun( input)
189+ result |> SimpleOperation.validateResult ( Some input )
190+ }
190191
191192[<Fact>]
192- let ``Should be able to execute a query using context , sending an input field with single and list fields , asynchronously`` () =
193+ let ``Should be able to execute a query using context , sending an input field with single and list fields , asynchronously`` () : Task = task {
193194 let single = InputField( " A" , 2 , System.Uri( " http://localhost:1234" ), EmptyGuidAsString)
194195 let list = [| InputField( " A" , 2 , System.Uri( " http://localhost:4321" ), EmptyGuidAsString)|]
195196 let input = Input( single, list)
196- SimpleOperation.operation.AsyncRun( context, input)
197- |> Async.RunSynchronously
198- |> SimpleOperation.validateResult ( Some input )
197+ let! result = SimpleOperation.operation.AsyncRun( context, input)
198+ result |> SimpleOperation.validateResult ( Some input )
199+ }
199200
200201module SingleRequiredUploadOperation =
201202 let operation =
@@ -223,11 +224,11 @@ let ``Should be able to execute a single required upload``() =
223224 |> SingleRequiredUploadOperation.validateResult file
224225
225226[<Fact( Skip = " Temporary broken" ) >]
226- let ``Should be able to execute a single required upload asynchronously`` () =
227+ let ``Should be able to execute a single required upload asynchronously`` () : Task = task {
227228 let file = { Name = " file.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents" }
228- SingleRequiredUploadOperation.operation.AsyncRun( file.MakeUpload())
229- |> Async.RunSynchronously
230- |> SingleRequiredUploadOperation.validateResult file
229+ let! result = SingleRequiredUploadOperation.operation.AsyncRun( file.MakeUpload())
230+ result |> SingleRequiredUploadOperation.validateResult file
231+ }
231232
232233module SingleOptionalUploadOperation =
233234 let operation =
@@ -257,22 +258,22 @@ let ``Should be able to execute a single optional upload by passing a file``() =
257258 |> SingleOptionalUploadOperation.validateResult ( Some file)
258259
259260[<Fact( Skip = " Temporary broken" ) >]
260- let ``Should be able to execute a single optional upload by passing a file , asynchronously`` () =
261+ let ``Should be able to execute a single optional upload by passing a file , asynchronously`` () : Task = task {
261262 let file = { Name = " file.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents" }
262- SingleOptionalUploadOperation.operation.AsyncRun( file.MakeUpload())
263- |> Async.RunSynchronously
264- |> SingleOptionalUploadOperation.validateResult ( Some file )
263+ let! result = SingleOptionalUploadOperation.operation.AsyncRun( file.MakeUpload())
264+ result |> SingleOptionalUploadOperation.validateResult ( Some file )
265+ }
265266
266267[<Fact( Skip = " Temporary broken" ) >]
267268let ``Should be able to execute a single optional upload by not passing a file`` () =
268269 SingleOptionalUploadOperation.operation.Run()
269270 |> SingleOptionalUploadOperation.validateResult None
270271
271272[<Fact( Skip = " Temporary broken" ) >]
272- let ``Should be able to execute a single optional upload by not passing a file asynchronously`` () =
273- SingleOptionalUploadOperation.operation.AsyncRun()
274- |> Async.RunSynchronously
275- |> SingleOptionalUploadOperation.validateResult None
273+ let ``Should be able to execute a single optional upload by not passing a file asynchronously`` () : Task = task {
274+ let! result = SingleOptionalUploadOperation.operation.AsyncRun()
275+ result |> SingleOptionalUploadOperation.validateResult None
276+ }
276277
277278module RequiredMultipleUploadOperation =
278279 let operation =
@@ -303,13 +304,13 @@ let ``Should be able to execute a multiple required upload``() =
303304 |> RequiredMultipleUploadOperation.validateResult files
304305
305306[<Fact( Skip = " Temporary broken" ) >]
306- let ``Should be able to execute a multiple required upload asynchronously`` () =
307+ let ``Should be able to execute a multiple required upload asynchronously`` () : Task = task {
307308 let files =
308309 [| { Name = " file1.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents 1" }
309310 { Name = " file2.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents 2" } |]
310- RequiredMultipleUploadOperation.operation.AsyncRun( files |> Array.map ( fun f -> f.MakeUpload()))
311- |> Async.RunSynchronously
312- |> RequiredMultipleUploadOperation.validateResult files
311+ let! result = RequiredMultipleUploadOperation.operation.AsyncRun( files |> Array.map ( fun f -> f.MakeUpload()))
312+ result |> RequiredMultipleUploadOperation.validateResult files
313+ }
313314
314315module OptionalMultipleUploadOperation =
315316 let operation =
@@ -340,24 +341,24 @@ let ``Should be able to execute a multiple upload``() =
340341 |> OptionalMultipleUploadOperation.validateResult ( Some files)
341342
342343[<Fact( Skip = " Temporary broken" ) >]
343- let ``Should be able to execute a multiple upload asynchronously`` () =
344+ let ``Should be able to execute a multiple upload asynchronously`` () : Task = task {
344345 let files =
345346 [| { Name = " file1.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents 1" }
346347 { Name = " file2.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents 2" } |]
347- OptionalMultipleUploadOperation.operation.AsyncRun( files |> Array.map ( fun f -> f.MakeUpload()))
348- |> Async.RunSynchronously
349- |> OptionalMultipleUploadOperation.validateResult ( Some files )
348+ let! result = OptionalMultipleUploadOperation.operation.AsyncRun( files |> Array.map ( fun f -> f.MakeUpload()))
349+ result |> OptionalMultipleUploadOperation.validateResult ( Some files )
350+ }
350351
351352[<Fact( Skip = " Temporary broken" ) >]
352353let ``Should be able to execute a multiple upload by sending no uploads`` () =
353354 OptionalMultipleUploadOperation.operation.Run()
354355 |> OptionalMultipleUploadOperation.validateResult None
355356
356357[<Fact( Skip = " Temporary broken" ) >]
357- let ``Should be able to execute a multiple upload asynchronously by sending no uploads`` () =
358- OptionalMultipleUploadOperation.operation.AsyncRun()
359- |> Async.RunSynchronously
360- |> OptionalMultipleUploadOperation.validateResult None
358+ let ``Should be able to execute a multiple upload asynchronously by sending no uploads`` () : Task = task {
359+ let! result = OptionalMultipleUploadOperation.operation.AsyncRun()
360+ result |> OptionalMultipleUploadOperation.validateResult None
361+ }
361362
362363module OptionalMultipleOptionalUploadOperation =
363364 let operation =
@@ -388,24 +389,24 @@ let ``Should be able to execute a multiple optional upload``() =
388389 |> OptionalMultipleOptionalUploadOperation.validateResult ( Some files)
389390
390391[<Fact( Skip = " Temporary broken" ) >]
391- let ``Should be able to execute a multiple optional upload asynchronously`` () =
392+ let ``Should be able to execute a multiple optional upload asynchronously`` () : Task = task {
392393 let files =
393394 [| Some { Name = " file1.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents 1" }
394395 Some { Name = " file2.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents 2" } |]
395- OptionalMultipleOptionalUploadOperation.operation.AsyncRun( files |> Array.map ( Option.map ( fun f -> f.MakeUpload())))
396- |> Async.RunSynchronously
397- |> OptionalMultipleOptionalUploadOperation.validateResult ( Some files )
396+ let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun( files |> Array.map ( Option.map ( fun f -> f.MakeUpload())))
397+ result |> ( OptionalMultipleOptionalUploadOperation.validateResult ( Some files ))
398+ }
398399
399400[<Fact( Skip = " Temporary broken" ) >]
400401let ``Should be able to execute a multiple optional upload by sending no uploads`` () =
401402 OptionalMultipleOptionalUploadOperation.operation.Run()
402403 |> OptionalMultipleOptionalUploadOperation.validateResult None
403404
404405[<Fact( Skip = " Temporary broken" ) >]
405- let ``Should be able to execute a multiple optional upload asynchronously by sending no uploads`` () =
406- OptionalMultipleOptionalUploadOperation.operation.AsyncRun()
407- |> Async.RunSynchronously
408- |> OptionalMultipleOptionalUploadOperation.validateResult None
406+ let ``Should be able to execute a multiple optional upload asynchronously by sending no uploads`` () : Task = task {
407+ let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun()
408+ result |> OptionalMultipleOptionalUploadOperation.validateResult None
409+ }
409410
410411[<Fact( Skip = " Temporary broken" ) >]
411412let ``Should be able to execute a multiple optional upload by sending some uploads`` () =
@@ -418,15 +419,15 @@ let ``Should be able to execute a multiple optional upload by sending some uploa
418419 |> OptionalMultipleOptionalUploadOperation.validateResult ( Some files)
419420
420421[<Fact( Skip = " Temporary broken" ) >]
421- let ``Should be able to execute a multiple optional upload asynchronously by sending some uploads`` () =
422+ let ``Should be able to execute a multiple optional upload asynchronously by sending some uploads`` () : Task = task {
422423 let files =
423424 [| Some { Name = " file1.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents 1" }
424425 None
425426 Some { Name = " file2.txt" ; ContentType = " text/plain" ; Content = " Sample text file contents 2" }
426427 None |]
427- OptionalMultipleOptionalUploadOperation.operation.AsyncRun( files |> Array.map ( Option.map ( fun f -> f.MakeUpload())))
428- |> Async.RunSynchronously
429- |> OptionalMultipleOptionalUploadOperation.validateResult ( Some files )
428+ let! result = OptionalMultipleOptionalUploadOperation.operation.AsyncRun( files |> Array.map ( Option.map ( fun f -> f.MakeUpload())))
429+ result |> OptionalMultipleOptionalUploadOperation.validateResult ( Some files )
430+ }
430431
431432module UploadRequestOperation =
432433 let operation =
@@ -466,7 +467,7 @@ module UploadRequestOperation =
466467 result.Data.Value.UploadRequest.NullableMultipleNullable |> Option.map ( Array.map ( Option.map (( fun x -> x.ToDictionary()) >> File.FromDictionary))) |> equals request.NullableMultipleNullable
467468
468469[<Fact( Skip = " Temporary broken" ) >]
469- let ``Should be able to upload files inside another input type`` () =
470+ let ``Should be able to upload files inside another input type`` () : Task = task {
470471 let request =
471472 { Single = { Name = " single.txt" ; ContentType = " text/plain" ; Content = " Single file content" }
472473 Multiple =
@@ -481,5 +482,6 @@ let ``Should be able to upload files inside another input type``() =
481482 multiple = Array.map makeUpload request.Multiple,
482483 nullableMultiple = Array.map makeUpload request.NullableMultiple.Value,
483484 nullableMultipleNullable = Array.map ( Option.map makeUpload) request.NullableMultipleNullable.Value)
484- UploadRequestOperation.operation.Run( input)
485- |> UploadRequestOperation.validateResult request
485+ let! result = UploadRequestOperation.operation.AsyncRun( input)
486+ result |> UploadRequestOperation.validateResult request
487+ }
0 commit comments