@@ -34,6 +34,18 @@ public async Task A_is_null_and_B_is_set_Error()
34
34
. MatchSnapshotAsync ( ) ;
35
35
}
36
36
37
+ [ Fact ]
38
+ public async Task A_is_null_and_B_is_null_Error ( )
39
+ {
40
+ // Error: Exactly one key must be specified
41
+ await new ServiceCollection ( )
42
+ . AddGraphQL ( )
43
+ . AddQueryType < Query > ( )
44
+ . ModifyOptions ( o => o . EnableOneOf = true )
45
+ . ExecuteRequestAsync ( "{ example(input: { a: null, b: null }) }" )
46
+ . MatchSnapshotAsync ( ) ;
47
+ }
48
+
37
49
[ Fact ]
38
50
public async Task A_is_null_Error ( )
39
51
{
@@ -57,6 +69,18 @@ public async Task B_is_set_Valid()
57
69
. MatchSnapshotAsync ( ) ;
58
70
}
59
71
72
+ [ Fact ]
73
+ public async Task Input_is_empty_object_Error ( )
74
+ {
75
+ // Error: Exactly one key must be specified
76
+ await new ServiceCollection ( )
77
+ . AddGraphQL ( )
78
+ . AddQueryType < Query > ( )
79
+ . ModifyOptions ( o => o . EnableOneOf = true )
80
+ . ExecuteRequestAsync ( "{ example(input: { }) }" )
81
+ . MatchSnapshotAsync ( ) ;
82
+ }
83
+
60
84
[ Fact ]
61
85
public async Task A_is_variable_and_B_is_set_Error ( )
62
86
{
@@ -67,8 +91,40 @@ public async Task A_is_variable_and_B_is_set_Error()
67
91
. ModifyOptions ( o => o . EnableOneOf = true )
68
92
. ExecuteRequestAsync (
69
93
OperationRequestBuilder . New ( )
70
- . SetDocument ( "query($var: String!) { example(input: { a: $var, b: 123 }) }" )
71
- . SetVariableValues ( new Dictionary < string , object ? > { { "var" , null } } )
94
+ . SetDocument ( "query($a: String!) { example(input: { a: $a, b: 123 }) }" )
95
+ . SetVariableValues ( new Dictionary < string , object ? > { { "a" , null } } )
96
+ . Build ( ) )
97
+ . MatchSnapshotAsync ( ) ;
98
+ }
99
+
100
+ [ Fact ]
101
+ public async Task A_is_unset_variable_and_B_is_set_Error ( )
102
+ {
103
+ // Error: Exactly one key must be specified
104
+ await new ServiceCollection ( )
105
+ . AddGraphQL ( )
106
+ . AddQueryType < Query > ( )
107
+ . ModifyOptions ( o => o . EnableOneOf = true )
108
+ . ExecuteRequestAsync (
109
+ OperationRequestBuilder . New ( )
110
+ . SetDocument ( "query($a: String!) { example(input: { a: $a, b: 123 }) }" )
111
+ . Build ( ) )
112
+ . MatchSnapshotAsync ( ) ;
113
+ }
114
+
115
+ [ Fact ]
116
+ public async Task A_is_variable_and_B_is_unset_variable_Error ( )
117
+ {
118
+ // Error: Exactly one key must be specified
119
+ await new ServiceCollection ( )
120
+ . AddGraphQL ( )
121
+ . AddQueryType < Query > ( )
122
+ . ModifyOptions ( o => o . EnableOneOf = true )
123
+ . ExecuteRequestAsync (
124
+ OperationRequestBuilder . New ( )
125
+ . SetDocument (
126
+ "query($a: String!, $b: Int!) { example(input: { a: $a, b: $b }) }" )
127
+ . SetVariableValues ( new Dictionary < string , object ? > { { "a" , "abc" } } )
72
128
. Build ( ) )
73
129
. MatchSnapshotAsync ( ) ;
74
130
}
@@ -82,14 +138,14 @@ public async Task B_is_variable_and_var_is_123_Valid()
82
138
. ModifyOptions ( o => o . EnableOneOf = true )
83
139
. ExecuteRequestAsync (
84
140
OperationRequestBuilder . New ( )
85
- . SetDocument ( "query($var : Int!) { example(input: { b: $var }) }" )
86
- . SetVariableValues ( new Dictionary < string , object ? > { { "var " , 123 } } )
141
+ . SetDocument ( "query($b : Int!) { example(input: { b: $b }) }" )
142
+ . SetVariableValues ( new Dictionary < string , object ? > { { "b " , 123 } } )
87
143
. Build ( ) )
88
144
. MatchSnapshotAsync ( ) ;
89
145
}
90
146
91
147
[ Fact ]
92
- public async Task Var_is_object_with_field_b_set_to_123_Valid ( )
148
+ public async Task Var_is_object_with_field_B_set_to_123_Valid ( )
93
149
{
94
150
await new ServiceCollection ( )
95
151
. AddGraphQL ( )
@@ -105,11 +161,100 @@ public async Task Var_is_object_with_field_b_set_to_123_Valid()
105
161
. MatchSnapshotAsync ( ) ;
106
162
}
107
163
164
+ [ Fact ]
165
+ public async Task Var_is_object_with_A_set_to_abc_and_B_set_to_123_Error ( )
166
+ {
167
+ // Error: Exactly one key must be specified
168
+ await new ServiceCollection ( )
169
+ . AddGraphQL ( )
170
+ . AddQueryType < Query > ( )
171
+ . ModifyOptions ( o => o . EnableOneOf = true )
172
+ . ExecuteRequestAsync (
173
+ OperationRequestBuilder . New ( )
174
+ . SetDocument ( "query($var: ExampleInput!) { example(input: $var) }" )
175
+ . SetVariableValues (
176
+ new Dictionary < string , object ? >
177
+ {
178
+ {
179
+ "var" ,
180
+ new ObjectValueNode (
181
+ new ObjectFieldNode ( "a" , "abc" ) ,
182
+ new ObjectFieldNode ( "b" , 123 ) )
183
+ }
184
+ } )
185
+ . Build ( ) )
186
+ . MatchSnapshotAsync ( ) ;
187
+ }
188
+
189
+ [ Fact ]
190
+ public async Task Var_is_object_with_A_set_to_abc_and_B_set_to_null_Error ( )
191
+ {
192
+ // Error: Exactly one key must be specified
193
+ await new ServiceCollection ( )
194
+ . AddGraphQL ( )
195
+ . AddQueryType < Query > ( )
196
+ . ModifyOptions ( o => o . EnableOneOf = true )
197
+ . ExecuteRequestAsync (
198
+ OperationRequestBuilder . New ( )
199
+ . SetDocument ( "query($var: ExampleInput!) { example(input: $var) }" )
200
+ . SetVariableValues (
201
+ new Dictionary < string , object ? >
202
+ {
203
+ {
204
+ "var" ,
205
+ new ObjectValueNode (
206
+ new ObjectFieldNode ( "a" , "abc" ) ,
207
+ new ObjectFieldNode ( "b" , NullValueNode . Default ) )
208
+ }
209
+ } )
210
+ . Build ( ) )
211
+ . MatchSnapshotAsync ( ) ;
212
+ }
213
+
214
+ [ Fact ]
215
+ public async Task Var_is_object_with_A_set_to_null_Error ( )
216
+ {
217
+ // Error: Value for member field {a} must be non-null
218
+ await new ServiceCollection ( )
219
+ . AddGraphQL ( )
220
+ . AddQueryType < Query > ( )
221
+ . ModifyOptions ( o => o . EnableOneOf = true )
222
+ . ExecuteRequestAsync (
223
+ OperationRequestBuilder . New ( )
224
+ . SetDocument ( "query($var: ExampleInput!) { example(input: $var) }" )
225
+ . SetVariableValues (
226
+ new Dictionary < string , object ? >
227
+ {
228
+ {
229
+ "var" ,
230
+ new ObjectValueNode ( new ObjectFieldNode ( "a" , NullValueNode . Default ) )
231
+ }
232
+ } )
233
+ . Build ( ) )
234
+ . MatchSnapshotAsync ( ) ;
235
+ }
236
+
237
+ [ Fact ]
238
+ public async Task Var_is_empty_object_Error ( )
239
+ {
240
+ // Error: Exactly one key must be specified
241
+ await new ServiceCollection ( )
242
+ . AddGraphQL ( )
243
+ . AddQueryType < Query > ( )
244
+ . ModifyOptions ( o => o . EnableOneOf = true )
245
+ . ExecuteRequestAsync (
246
+ OperationRequestBuilder . New ( )
247
+ . SetDocument ( "query($var: ExampleInput!) { example(input: $var) }" )
248
+ . SetVariableValues (
249
+ new Dictionary < string , object ? > { { "var" , new ObjectValueNode ( ) } } )
250
+ . Build ( ) )
251
+ . MatchSnapshotAsync ( ) ;
252
+ }
253
+
108
254
[ Fact ]
109
255
public async Task Input_is_set_to_string_abc123_Error ( )
110
256
{
111
257
// Error: Incorrect value
112
-
113
258
await new ServiceCollection ( )
114
259
. AddGraphQL ( )
115
260
. AddQueryType < Query > ( )
@@ -125,7 +270,6 @@ public async Task Input_is_set_to_string_abc123_Error()
125
270
public async Task Var_is_string_abc123_and_passed_to_input_Error ( )
126
271
{
127
272
// Error: Incorrect value
128
-
129
273
await new ServiceCollection ( )
130
274
. AddGraphQL ( )
131
275
. AddQueryType < Query > ( )
@@ -163,14 +307,36 @@ public async Task B_is_set_to_string_Error()
163
307
}
164
308
165
309
[ Fact ]
166
- public async Task A_is_set_to_string_Error ( )
310
+ public async Task Var_is_object_with_B_set_to_abc_Error ( )
167
311
{
168
312
// Error: Incorrect value for member field {b}
169
313
await new ServiceCollection ( )
170
314
. AddGraphQL ( )
171
315
. AddQueryType < Query > ( )
172
316
. ModifyOptions ( o => o . EnableOneOf = true )
173
- . ExecuteRequestAsync ( "{ example(input: { a: \" 123\" }) }" )
317
+ . ExecuteRequestAsync (
318
+ OperationRequestBuilder . New ( )
319
+ . SetDocument ( "query($var: ExampleInput!) { example(input: $var) }" )
320
+ . SetVariableValues (
321
+ new Dictionary < string , object ? >
322
+ {
323
+ {
324
+ "var" ,
325
+ new ObjectValueNode ( new ObjectFieldNode ( "b" , "abc" ) )
326
+ }
327
+ } )
328
+ . Build ( ) )
329
+ . MatchSnapshotAsync ( ) ;
330
+ }
331
+
332
+ [ Fact ]
333
+ public async Task A_is_set_to_string_Valid ( )
334
+ {
335
+ await new ServiceCollection ( )
336
+ . AddGraphQL ( )
337
+ . AddQueryType < Query > ( )
338
+ . ModifyOptions ( o => o . EnableOneOf = true )
339
+ . ExecuteRequestAsync ( "{ example(input: { a: \" abc\" }) }" )
174
340
. MatchSnapshotAsync ( ) ;
175
341
}
176
342
@@ -184,13 +350,13 @@ public async Task B_is_variable_and_var_not_set_Error()
184
350
. ModifyOptions ( o => o . EnableOneOf = true )
185
351
. ExecuteRequestAsync (
186
352
OperationRequestBuilder . New ( )
187
- . SetDocument ( "query($var : Int!) { example(input: { b: $var }) }" )
353
+ . SetDocument ( "query($b : Int!) { example(input: { b: $b }) }" )
188
354
. Build ( ) )
189
355
. MatchSnapshotAsync ( ) ;
190
356
}
191
357
192
358
[ Fact ]
193
- public async Task Var_is_object_with_field_a_set_to_abc_Valid ( )
359
+ public async Task Var_is_object_with_field_A_set_to_abc_Valid ( )
194
360
{
195
361
await new ServiceCollection ( )
196
362
. AddGraphQL ( )
@@ -219,24 +385,25 @@ public async Task A_is_set_and_B_is_null_Error()
219
385
}
220
386
221
387
[ Fact ]
222
- public async Task B_is_variable_and_var_is_null_Valid ( )
388
+ public async Task B_is_variable_and_var_is_null_Error ( )
223
389
{
390
+ // Error: Value for member field {b} must be non-null
224
391
await new ServiceCollection ( )
225
392
. AddGraphQL ( )
226
393
. AddQueryType < Query > ( )
227
394
. ModifyOptions ( o => o . EnableOneOf = true )
228
395
. ExecuteRequestAsync (
229
396
OperationRequestBuilder . New ( )
230
- . SetDocument ( "query($var : Int) { example(input: { b: $var }) }" )
231
- . SetVariableValues ( new Dictionary < string , object ? > { { "var " , null } } )
397
+ . SetDocument ( "query($b : Int) { example(input: { b: $b }) }" )
398
+ . SetVariableValues ( new Dictionary < string , object ? > { { "b " , null } } )
232
399
. Build ( ) )
233
400
. MatchSnapshotAsync ( ) ;
234
401
}
235
402
236
403
[ Fact ]
237
404
public async Task B_is_set_and_C_is_invalid_prop_Error ( )
238
405
{
239
- // Error: Exactly one key must be specified
406
+ // Error: Unexpected field {c}
240
407
await new ServiceCollection ( )
241
408
. AddGraphQL ( )
242
409
. AddQueryType < Query > ( )
@@ -245,6 +412,31 @@ public async Task B_is_set_and_C_is_invalid_prop_Error()
245
412
. MatchSnapshotAsync ( ) ;
246
413
}
247
414
415
+ [ Fact ]
416
+ public async Task Var_is_object_with_fields_B_and_C_set_Error ( )
417
+ {
418
+ // Error: Unexpected field {c}
419
+ await new ServiceCollection ( )
420
+ . AddGraphQL ( )
421
+ . AddQueryType < Query > ( )
422
+ . ModifyOptions ( o => o . EnableOneOf = true )
423
+ . ExecuteRequestAsync (
424
+ OperationRequestBuilder . New ( )
425
+ . SetDocument ( "query($var: ExampleInput!) { example(input: $var) }" )
426
+ . SetVariableValues (
427
+ new Dictionary < string , object ? >
428
+ {
429
+ {
430
+ "var" ,
431
+ new ObjectValueNode (
432
+ new ObjectFieldNode ( "b" , 123 ) ,
433
+ new ObjectFieldNode ( "c" , "xyz" ) )
434
+ }
435
+ } )
436
+ . Build ( ) )
437
+ . MatchSnapshotAsync ( ) ;
438
+ }
439
+
248
440
[ Fact ]
249
441
public void OneOf_Input_Objects_that_is_Valid ( )
250
442
=> ExpectValid (
0 commit comments