@@ -104,7 +104,8 @@ public async Task DeleteAsync_DeleteBlockWithGivenId()
104104
105105 [ Theory ]
106106 [ 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 )
108109 {
109110 var page = await Client . Pages . CreateAsync (
110111 PagesCreateParametersBuilder . Create (
@@ -125,7 +126,7 @@ public async Task UpdateAsync_UpdatesGivenBlock(IBlock block, IUpdateBlock updat
125126
126127 var updatedBlock = blocks . Results . First ( ) ;
127128
128- assert . Invoke ( updatedBlock ) ;
129+ assert . Invoke ( updatedBlock , Client ) ;
129130
130131 // cleanup
131132 await Client . Pages . UpdateAsync ( page . Id , new PagesUpdateParameters { Archived = true } ) ;
@@ -159,7 +160,7 @@ private static IEnumerable<object[]> BlockData()
159160 }
160161 }
161162 } ,
162- new Action < IBlock > ( block =>
163+ new Action < IBlock , INotionClient > ( ( block , client ) =>
163164 {
164165 var updatedBlock = ( BookmarkBlock ) block ;
165166 Assert . Equal ( "https://github.com/notion-dotnet/notion-sdk-net" , updatedBlock . Bookmark . Url ) ;
@@ -170,7 +171,7 @@ private static IEnumerable<object[]> BlockData()
170171 {
171172 new EquationBlock { Equation = new EquationBlock . Info { Expression = "e=mc^3" } } ,
172173 new EquationUpdateBlock { Equation = new EquationUpdateBlock . Info { Expression = "e=mc^2" } } ,
173- new Action < IBlock > ( block =>
174+ new Action < IBlock , INotionClient > ( ( block , client ) =>
174175 {
175176 var updatedBlock = ( EquationBlock ) block ;
176177 Assert . Equal ( "e=mc^2" , updatedBlock . Equation . Expression ) ;
@@ -207,10 +208,10 @@ private static IEnumerable<object[]> BlockData()
207208 }
208209 }
209210 } ,
210- new Action < IBlock > ( block =>
211+ new Action < IBlock , INotionClient > ( ( block , client ) =>
211212 {
212213 block . Should ( ) . NotBeNull ( ) ;
213-
214+
214215 block . Should ( ) . BeOfType < AudioBlock > ( ) . Subject
215216 . Audio . Should ( ) . BeOfType < ExternalFile > ( ) . Subject
216217 . External . Url . Should ( ) . Be ( "https://www.soundhelix.com/examples/mp3/SoundHelix-Song-3.mp3" ) ;
@@ -219,7 +220,7 @@ private static IEnumerable<object[]> BlockData()
219220 new object [ ]
220221 {
221222 new TableOfContentsBlock { TableOfContents = new TableOfContentsBlock . Data ( ) } ,
222- new TableOfContentsUpdateBlock ( ) , new Action < IBlock > ( block =>
223+ new TableOfContentsUpdateBlock ( ) , new Action < IBlock , INotionClient > ( ( block , client ) =>
223224 {
224225 Assert . NotNull ( block ) ;
225226 _ = Assert . IsType < TableOfContentsBlock > ( block ) ;
@@ -247,11 +248,11 @@ private static IEnumerable<object[]> BlockData()
247248 }
248249 }
249250 } ,
250- new Action < IBlock > ( block =>
251+ new Action < IBlock , INotionClient > ( ( block , client ) =>
251252 {
252253 Assert . NotNull ( block ) ;
253254 var calloutBlock = Assert . IsType < CalloutBlock > ( block ) ;
254-
255+
255256 Assert . Equal ( "Test 2" , calloutBlock . Callout . RichText . OfType < RichTextText > ( ) . First ( ) . Text . Content ) ;
256257 } )
257258 } ,
@@ -277,11 +278,11 @@ private static IEnumerable<object[]> BlockData()
277278 }
278279 }
279280 } ,
280- new Action < IBlock > ( block =>
281+ new Action < IBlock , INotionClient > ( ( block , client ) =>
281282 {
282283 Assert . NotNull ( block ) ;
283284 var quoteBlock = Assert . IsType < QuoteBlock > ( block ) ;
284-
285+
285286 Assert . Equal ( "Test 2" , quoteBlock . Quote . RichText . OfType < RichTextText > ( ) . First ( ) . Text . Content ) ;
286287 } )
287288 } ,
@@ -308,12 +309,12 @@ private static IEnumerable<object[]> BlockData()
308309 }
309310 }
310311 } ,
311- new Action < IBlock > ( block =>
312+ new Action < IBlock , INotionClient > ( ( block , client ) =>
312313 {
313314 Assert . NotNull ( block ) ;
314315 var imageBlock = Assert . IsType < ImageBlock > ( block ) ;
315316 var imageFile = Assert . IsType < ExternalFile > ( imageBlock . Image ) ;
316-
317+
317318 Assert . Equal ( "https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg" ,
318319 imageFile . External . Url ) ;
319320 } )
@@ -334,11 +335,11 @@ private static IEnumerable<object[]> BlockData()
334335 Url = "https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg"
335336 }
336337 } ,
337- new Action < IBlock > ( block =>
338+ new Action < IBlock , INotionClient > ( ( block , client ) =>
338339 {
339340 Assert . NotNull ( block ) ;
340341 var embedBlock = Assert . IsType < EmbedBlock > ( block ) ;
341-
342+
342343 Assert . Equal ( "https://www.iaspaper.net/wp-content/uploads/2017/09/TNEA-Online-Application.jpg" ,
343344 embedBlock . Embed . Url ) ;
344345 } )
@@ -376,14 +377,14 @@ private static IEnumerable<object[]> BlockData()
376377 }
377378 }
378379 } ,
379- new Action < IBlock > ( block =>
380+ new Action < IBlock , INotionClient > ( ( block , client ) =>
380381 {
381382 Assert . NotNull ( block ) ;
382383 var templateBlock = Assert . IsType < TemplateBlock > ( block ) ;
383-
384+
384385 Assert . Single ( templateBlock . Template . RichText ) ;
385386 Assert . Null ( templateBlock . Template . Children ) ;
386-
387+
387388 Assert . Equal ( "Test Template 2" ,
388389 templateBlock . Template . RichText . OfType < RichTextText > ( ) . First ( ) . Text . Content ) ;
389390 } )
@@ -402,17 +403,55 @@ private static IEnumerable<object[]> BlockData()
402403 {
403404 LinkToPage = new ParentPageInput { PageId = "3c357473a28149a488c010d2b245a589" }
404405 } ,
405- new Action < IBlock > ( block =>
406+ new Action < IBlock , INotionClient > ( ( block , client ) =>
406407 {
407408 Assert . NotNull ( block ) ;
408409 var linkToPageBlock = Assert . IsType < LinkToPageBlock > ( block ) ;
409-
410+
410411 var pageParent = Assert . IsType < PageParent > ( linkToPageBlock . LinkToPage ) ;
411-
412+
412413 // TODO: Currently the api doesn't allow to update the link_to_page block type
413414 // This will change to updated ID once api start to support
414415 Assert . Equal ( Guid . Parse ( "533578e3edf14c0a91a9da6b09bac3ee" ) , Guid . Parse ( pageParent . PageId ) ) ;
415416 } )
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+ } )
416455 }
417456 } ;
418457 }
0 commit comments