@@ -104,7 +104,8 @@ public async Task DeleteAsync_DeleteBlockWithGivenId()
104
104
105
105
[ Theory ]
106
106
[ MemberData ( nameof ( BlockData ) ) ]
107
- public async Task UpdateAsync_UpdatesGivenBlock ( IBlock block , IUpdateBlock updateBlock , Action < IBlock > assert )
107
+ public async Task UpdateAsync_UpdatesGivenBlock (
108
+ IBlock block , IUpdateBlock updateBlock , Action < IBlock , INotionClient > assert )
108
109
{
109
110
var page = await Client . Pages . CreateAsync (
110
111
PagesCreateParametersBuilder . Create (
@@ -125,7 +126,7 @@ public async Task UpdateAsync_UpdatesGivenBlock(IBlock block, IUpdateBlock updat
125
126
126
127
var updatedBlock = blocks . Results . First ( ) ;
127
128
128
- assert . Invoke ( updatedBlock ) ;
129
+ assert . Invoke ( updatedBlock , Client ) ;
129
130
130
131
// cleanup
131
132
await Client . Pages . UpdateAsync ( page . Id , new PagesUpdateParameters { Archived = true } ) ;
@@ -159,7 +160,7 @@ private static IEnumerable<object[]> BlockData()
159
160
}
160
161
}
161
162
} ,
162
- new Action < IBlock > ( block =>
163
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
163
164
{
164
165
var updatedBlock = ( BookmarkBlock ) block ;
165
166
Assert . Equal ( "https://github.com/notion-dotnet/notion-sdk-net" , updatedBlock . Bookmark . Url ) ;
@@ -170,7 +171,7 @@ private static IEnumerable<object[]> BlockData()
170
171
{
171
172
new EquationBlock { Equation = new EquationBlock . Info { Expression = "e=mc^3" } } ,
172
173
new EquationUpdateBlock { Equation = new EquationUpdateBlock . Info { Expression = "e=mc^2" } } ,
173
- new Action < IBlock > ( block =>
174
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
174
175
{
175
176
var updatedBlock = ( EquationBlock ) block ;
176
177
Assert . Equal ( "e=mc^2" , updatedBlock . Equation . Expression ) ;
@@ -207,10 +208,10 @@ private static IEnumerable<object[]> BlockData()
207
208
}
208
209
}
209
210
} ,
210
- new Action < IBlock > ( block =>
211
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
211
212
{
212
213
block . Should ( ) . NotBeNull ( ) ;
213
-
214
+
214
215
block . Should ( ) . BeOfType < AudioBlock > ( ) . Subject
215
216
. Audio . Should ( ) . BeOfType < ExternalFile > ( ) . Subject
216
217
. External . Url . Should ( ) . Be ( "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-3.mp3" ) ;
@@ -219,7 +220,7 @@ private static IEnumerable<object[]> BlockData()
219
220
new object [ ]
220
221
{
221
222
new TableOfContentsBlock { TableOfContents = new TableOfContentsBlock . Data ( ) } ,
222
- new TableOfContentsUpdateBlock ( ) , new Action < IBlock > ( block =>
223
+ new TableOfContentsUpdateBlock ( ) , new Action < IBlock , INotionClient > ( ( block , client ) =>
223
224
{
224
225
Assert . NotNull ( block ) ;
225
226
_ = Assert . IsType < TableOfContentsBlock > ( block ) ;
@@ -247,11 +248,11 @@ private static IEnumerable<object[]> BlockData()
247
248
}
248
249
}
249
250
} ,
250
- new Action < IBlock > ( block =>
251
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
251
252
{
252
253
Assert . NotNull ( block ) ;
253
254
var calloutBlock = Assert . IsType < CalloutBlock > ( block ) ;
254
-
255
+
255
256
Assert . Equal ( "Test 2" , calloutBlock . Callout . RichText . OfType < RichTextText > ( ) . First ( ) . Text . Content ) ;
256
257
} )
257
258
} ,
@@ -277,11 +278,11 @@ private static IEnumerable<object[]> BlockData()
277
278
}
278
279
}
279
280
} ,
280
- new Action < IBlock > ( block =>
281
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
281
282
{
282
283
Assert . NotNull ( block ) ;
283
284
var quoteBlock = Assert . IsType < QuoteBlock > ( block ) ;
284
-
285
+
285
286
Assert . Equal ( "Test 2" , quoteBlock . Quote . RichText . OfType < RichTextText > ( ) . First ( ) . Text . Content ) ;
286
287
} )
287
288
} ,
@@ -308,12 +309,12 @@ private static IEnumerable<object[]> BlockData()
308
309
}
309
310
}
310
311
} ,
311
- new Action < IBlock > ( block =>
312
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
312
313
{
313
314
Assert . NotNull ( block ) ;
314
315
var imageBlock = Assert . IsType < ImageBlock > ( block ) ;
315
316
var imageFile = Assert . IsType < ExternalFile > ( imageBlock . Image ) ;
316
-
317
+
317
318
Assert . Equal ( "https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg" ,
318
319
imageFile . External . Url ) ;
319
320
} )
@@ -334,11 +335,11 @@ private static IEnumerable<object[]> BlockData()
334
335
Url = "https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg"
335
336
}
336
337
} ,
337
- new Action < IBlock > ( block =>
338
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
338
339
{
339
340
Assert . NotNull ( block ) ;
340
341
var embedBlock = Assert . IsType < EmbedBlock > ( block ) ;
341
-
342
+
342
343
Assert . Equal ( "https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg" ,
343
344
embedBlock . Embed . Url ) ;
344
345
} )
@@ -376,14 +377,14 @@ private static IEnumerable<object[]> BlockData()
376
377
}
377
378
}
378
379
} ,
379
- new Action < IBlock > ( block =>
380
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
380
381
{
381
382
Assert . NotNull ( block ) ;
382
383
var templateBlock = Assert . IsType < TemplateBlock > ( block ) ;
383
-
384
+
384
385
Assert . Single ( templateBlock . Template . RichText ) ;
385
386
Assert . Null ( templateBlock . Template . Children ) ;
386
-
387
+
387
388
Assert . Equal ( "Test Template 2" ,
388
389
templateBlock . Template . RichText . OfType < RichTextText > ( ) . First ( ) . Text . Content ) ;
389
390
} )
@@ -402,17 +403,55 @@ private static IEnumerable<object[]> BlockData()
402
403
{
403
404
LinkToPage = new ParentPageInput { PageId = "3c357473a28149a488c010d2b245a589" }
404
405
} ,
405
- new Action < IBlock > ( block =>
406
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
406
407
{
407
408
Assert . NotNull ( block ) ;
408
409
var linkToPageBlock = Assert . IsType < LinkToPageBlock > ( block ) ;
409
-
410
+
410
411
var pageParent = Assert . IsType < PageParent > ( linkToPageBlock . LinkToPage ) ;
411
-
412
+
412
413
// TODO: Currently the api doesn't allow to update the link_to_page block type
413
414
// This will change to updated ID once api start to support
414
415
Assert . Equal ( Guid . Parse ( "533578e3edf14c0a91a9da6b09bac3ee" ) , Guid . Parse ( pageParent . PageId ) ) ;
415
416
} )
417
+ } ,
418
+ new object [ ]
419
+ {
420
+ new TableBlock
421
+ {
422
+ Table = new TableBlock . Info
423
+ {
424
+ TableWidth = 1 ,
425
+ Children = new [ ]
426
+ {
427
+ new TableRowBlock
428
+ {
429
+ TableRow = new TableRowBlock . Info
430
+ {
431
+ Cells = new [ ]
432
+ {
433
+ new [ ] { new RichTextText { Text = new Text { Content = "Data" } } }
434
+ }
435
+ }
436
+ }
437
+ }
438
+ }
439
+ } ,
440
+ new TableUpdateBlock { Table = new TableUpdateBlock . Info { HasColumnHeader = false } } ,
441
+ new Action < IBlock , INotionClient > ( ( block , client ) =>
442
+ {
443
+ var tableBlock = block . Should ( ) . NotBeNull ( ) . And . BeOfType < TableBlock > ( ) . Subject ;
444
+ tableBlock . HasChildren . Should ( ) . BeTrue ( ) ;
445
+
446
+ var children = client . Blocks . RetrieveChildrenAsync ( tableBlock . Id ) . GetAwaiter ( ) . GetResult ( ) ;
447
+
448
+ children . Results . Should ( ) . ContainSingle ( )
449
+ . Subject . Should ( ) . BeOfType < TableRowBlock > ( )
450
+ . Subject . TableRow . Cells . Should ( ) . ContainSingle ( )
451
+ . Subject . Should ( ) . ContainSingle ( )
452
+ . Subject . Should ( ) . BeOfType < RichTextText > ( )
453
+ . Subject . Text . Content . Should ( ) . Be ( "Data" ) ;
454
+ } )
416
455
}
417
456
} ;
418
457
}
0 commit comments