1
- #nullable disable
2
-
3
1
using System ;
4
2
using System . Collections . Generic ;
5
3
using System . Linq ;
@@ -56,7 +54,9 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
56
54
57
55
responseDocument . Data . SingleValue . ShouldNotBeNull ( ) ;
58
56
responseDocument . Data . SingleValue . Id . Should ( ) . Be ( broadcast . StringId ) ;
59
- responseDocument . Data . SingleValue . Attributes [ "archivedAt" ] . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( broadcast . ArchivedAt . GetValueOrDefault ( ) ) ;
57
+
58
+ responseDocument . Data . SingleValue . Attributes . ShouldContainKey ( "archivedAt" )
59
+ . With ( value => value . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( broadcast . ArchivedAt ! . Value ) ) ;
60
60
}
61
61
62
62
[ Fact ]
@@ -82,7 +82,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
82
82
83
83
responseDocument . Data . SingleValue . ShouldNotBeNull ( ) ;
84
84
responseDocument . Data . SingleValue . Id . Should ( ) . Be ( broadcast . StringId ) ;
85
- responseDocument . Data . SingleValue . Attributes [ "archivedAt" ] . As < DateTimeOffset ? > ( ) . Should ( ) . BeNull ( ) ;
85
+ responseDocument . Data . SingleValue . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . As < DateTimeOffset ? > ( ) . Should ( ) . BeNull ( ) ) ;
86
86
}
87
87
88
88
[ Fact ]
@@ -109,7 +109,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
109
109
110
110
responseDocument . Data . ManyValue . ShouldHaveCount ( 1 ) ;
111
111
responseDocument . Data . ManyValue [ 0 ] . Id . Should ( ) . Be ( broadcasts [ 1 ] . StringId ) ;
112
- responseDocument . Data . ManyValue [ 0 ] . Attributes [ "archivedAt" ] . As < DateTimeOffset ? > ( ) . Should ( ) . BeNull ( ) ;
112
+ responseDocument . Data . ManyValue [ 0 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . As < DateTimeOffset ? > ( ) . Should ( ) . BeNull ( ) ) ;
113
113
}
114
114
115
115
[ Fact ]
@@ -136,9 +136,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
136
136
137
137
responseDocument . Data . ManyValue . ShouldHaveCount ( 2 ) ;
138
138
responseDocument . Data . ManyValue [ 0 ] . Id . Should ( ) . Be ( broadcasts [ 0 ] . StringId ) ;
139
- responseDocument . Data . ManyValue [ 0 ] . Attributes [ "archivedAt" ] . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( broadcasts [ 0 ] . ArchivedAt . GetValueOrDefault ( ) ) ;
139
+
140
+ responseDocument . Data . ManyValue [ 0 ] . Attributes . ShouldContainKey ( "archivedAt" )
141
+ . With ( value => value . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( broadcasts [ 0 ] . ArchivedAt ! . Value ) ) ;
142
+
140
143
responseDocument . Data . ManyValue [ 1 ] . Id . Should ( ) . Be ( broadcasts [ 1 ] . StringId ) ;
141
- responseDocument . Data . ManyValue [ 1 ] . Attributes [ "archivedAt" ] . Should ( ) . BeNull ( ) ;
144
+ responseDocument . Data . ManyValue [ 1 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . Should ( ) . BeNull ( ) ) ;
142
145
}
143
146
144
147
[ Fact ]
@@ -168,7 +171,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
168
171
169
172
responseDocument . Included . ShouldHaveCount ( 1 ) ;
170
173
responseDocument . Included [ 0 ] . Id . Should ( ) . Be ( station . Broadcasts . ElementAt ( 1 ) . StringId ) ;
171
- responseDocument . Included [ 0 ] . Attributes [ "archivedAt" ] . Should ( ) . BeNull ( ) ;
174
+ responseDocument . Included [ 0 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . Should ( ) . BeNull ( ) ) ;
172
175
}
173
176
174
177
[ Fact ]
@@ -194,16 +197,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
194
197
// Assert
195
198
httpResponse . Should ( ) . HaveStatusCode ( HttpStatusCode . OK ) ;
196
199
197
- DateTimeOffset archivedAt0 = station . Broadcasts . ElementAt ( 0 ) . ArchivedAt . GetValueOrDefault ( ) ;
200
+ DateTimeOffset archivedAt0 = station . Broadcasts . ElementAt ( 0 ) . ArchivedAt ! . Value ;
198
201
199
202
responseDocument . Data . SingleValue . ShouldNotBeNull ( ) ;
200
203
responseDocument . Data . SingleValue . Id . Should ( ) . Be ( station . StringId ) ;
201
204
202
205
responseDocument . Included . ShouldHaveCount ( 2 ) ;
203
206
responseDocument . Included [ 0 ] . Id . Should ( ) . Be ( station . Broadcasts . ElementAt ( 0 ) . StringId ) ;
204
- responseDocument . Included [ 0 ] . Attributes [ "archivedAt" ] . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( archivedAt0 ) ;
207
+ responseDocument . Included [ 0 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( archivedAt0 ) ) ;
205
208
responseDocument . Included [ 1 ] . Id . Should ( ) . Be ( station . Broadcasts . ElementAt ( 1 ) . StringId ) ;
206
- responseDocument . Included [ 1 ] . Attributes [ "archivedAt" ] . Should ( ) . BeNull ( ) ;
209
+ responseDocument . Included [ 1 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . Should ( ) . BeNull ( ) ) ;
207
210
}
208
211
209
212
[ Fact ]
@@ -227,11 +230,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
227
230
// Assert
228
231
httpResponse . Should ( ) . HaveStatusCode ( HttpStatusCode . OK ) ;
229
232
230
- DateTimeOffset archivedAt = comment . AppliesTo . ArchivedAt . GetValueOrDefault ( ) ;
231
-
232
233
responseDocument . Data . SingleValue . ShouldNotBeNull ( ) ;
233
234
responseDocument . Data . SingleValue . Id . Should ( ) . Be ( comment . AppliesTo . StringId ) ;
234
- responseDocument . Data . SingleValue . Attributes [ "archivedAt" ] . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( archivedAt ) ;
235
+
236
+ responseDocument . Data . SingleValue . Attributes . ShouldContainKey ( "archivedAt" )
237
+ . With ( value => value . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( comment . AppliesTo . ArchivedAt ! . Value ) ) ;
235
238
}
236
239
237
240
[ Fact ]
@@ -258,7 +261,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
258
261
259
262
responseDocument . Data . ManyValue . ShouldHaveCount ( 1 ) ;
260
263
responseDocument . Data . ManyValue [ 0 ] . Id . Should ( ) . Be ( station . Broadcasts . ElementAt ( 1 ) . StringId ) ;
261
- responseDocument . Data . ManyValue [ 0 ] . Attributes [ "archivedAt" ] . Should ( ) . BeNull ( ) ;
264
+ responseDocument . Data . ManyValue [ 0 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . Should ( ) . BeNull ( ) ) ;
262
265
}
263
266
264
267
[ Fact ]
@@ -283,13 +286,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
283
286
// Assert
284
287
httpResponse . Should ( ) . HaveStatusCode ( HttpStatusCode . OK ) ;
285
288
286
- DateTimeOffset archivedAt0 = station . Broadcasts . ElementAt ( 0 ) . ArchivedAt . GetValueOrDefault ( ) ;
287
-
288
289
responseDocument . Data . ManyValue . ShouldHaveCount ( 2 ) ;
289
290
responseDocument . Data . ManyValue [ 0 ] . Id . Should ( ) . Be ( station . Broadcasts . ElementAt ( 0 ) . StringId ) ;
290
- responseDocument . Data . ManyValue [ 0 ] . Attributes [ "archivedAt" ] . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( archivedAt0 ) ;
291
+
292
+ responseDocument . Data . ManyValue [ 0 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value =>
293
+ value . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( station . Broadcasts . ElementAt ( 0 ) . ArchivedAt ! . Value ) ) ;
294
+
291
295
responseDocument . Data . ManyValue [ 1 ] . Id . Should ( ) . Be ( station . Broadcasts . ElementAt ( 1 ) . StringId ) ;
292
- responseDocument . Data . ManyValue [ 1 ] . Attributes [ "archivedAt" ] . Should ( ) . BeNull ( ) ;
296
+ responseDocument . Data . ManyValue [ 1 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . Should ( ) . BeNull ( ) ) ;
293
297
}
294
298
295
299
[ Fact ]
@@ -320,7 +324,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
320
324
321
325
responseDocument . Included . ShouldHaveCount ( 1 ) ;
322
326
responseDocument . Included [ 0 ] . Id . Should ( ) . Be ( network . Stations . ElementAt ( 0 ) . Broadcasts . ElementAt ( 1 ) . StringId ) ;
323
- responseDocument . Included [ 0 ] . Attributes [ "archivedAt" ] . Should ( ) . BeNull ( ) ;
327
+ responseDocument . Included [ 0 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . Should ( ) . BeNull ( ) ) ;
324
328
}
325
329
326
330
[ Fact ]
@@ -346,16 +350,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
346
350
// Assert
347
351
httpResponse . Should ( ) . HaveStatusCode ( HttpStatusCode . OK ) ;
348
352
349
- DateTimeOffset archivedAt0 = network . Stations . ElementAt ( 0 ) . Broadcasts . ElementAt ( 0 ) . ArchivedAt . GetValueOrDefault ( ) ;
353
+ DateTimeOffset archivedAt0 = network . Stations . ElementAt ( 0 ) . Broadcasts . ElementAt ( 0 ) . ArchivedAt ! . Value ;
350
354
351
355
responseDocument . Data . ManyValue . ShouldHaveCount ( 1 ) ;
352
356
responseDocument . Data . ManyValue [ 0 ] . Id . Should ( ) . Be ( network . Stations . ElementAt ( 0 ) . StringId ) ;
353
357
354
358
responseDocument . Included . ShouldHaveCount ( 2 ) ;
355
359
responseDocument . Included [ 0 ] . Id . Should ( ) . Be ( network . Stations . ElementAt ( 0 ) . Broadcasts . ElementAt ( 0 ) . StringId ) ;
356
- responseDocument . Included [ 0 ] . Attributes [ "archivedAt" ] . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( archivedAt0 ) ;
360
+ responseDocument . Included [ 0 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . As < DateTimeOffset ? > ( ) . Should ( ) . BeCloseTo ( archivedAt0 ) ) ;
357
361
responseDocument . Included [ 1 ] . Id . Should ( ) . Be ( network . Stations . ElementAt ( 0 ) . Broadcasts . ElementAt ( 1 ) . StringId ) ;
358
- responseDocument . Included [ 1 ] . Attributes [ "archivedAt" ] . Should ( ) . BeNull ( ) ;
362
+ responseDocument . Included [ 1 ] . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . Should ( ) . BeNull ( ) ) ;
359
363
}
360
364
361
365
[ Fact ]
@@ -439,9 +443,12 @@ public async Task Can_create_unarchived_resource()
439
443
httpResponse . Should ( ) . HaveStatusCode ( HttpStatusCode . Created ) ;
440
444
441
445
responseDocument . Data . SingleValue . ShouldNotBeNull ( ) ;
442
- responseDocument . Data . SingleValue . Attributes [ "title" ] . Should ( ) . Be ( newBroadcast . Title ) ;
443
- responseDocument . Data . SingleValue . Attributes [ "airedAt" ] . As < DateTimeOffset > ( ) . Should ( ) . BeCloseTo ( newBroadcast . AiredAt ) ;
444
- responseDocument . Data . SingleValue . Attributes [ "archivedAt" ] . Should ( ) . BeNull ( ) ;
446
+ responseDocument . Data . SingleValue . Attributes . ShouldContainKey ( "title" ) . With ( value => value . Should ( ) . Be ( newBroadcast . Title ) ) ;
447
+
448
+ responseDocument . Data . SingleValue . Attributes . ShouldContainKey ( "airedAt" )
449
+ . With ( value => value . As < DateTimeOffset > ( ) . Should ( ) . BeCloseTo ( newBroadcast . AiredAt ) ) ;
450
+
451
+ responseDocument . Data . SingleValue . Attributes . ShouldContainKey ( "archivedAt" ) . With ( value => value . Should ( ) . BeNull ( ) ) ;
445
452
}
446
453
447
454
[ Fact ]
@@ -636,7 +643,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
636
643
637
644
await _testContext . RunOnDatabaseAsync ( async dbContext =>
638
645
{
639
- TelevisionBroadcast broadcastInDatabase = await dbContext . Broadcasts . FirstWithIdOrDefaultAsync ( broadcast . Id ) ;
646
+ TelevisionBroadcast ? broadcastInDatabase = await dbContext . Broadcasts . FirstWithIdOrDefaultAsync ( broadcast . Id ) ;
640
647
641
648
broadcastInDatabase . Should ( ) . BeNull ( ) ;
642
649
} ) ;
0 commit comments