File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed
Src/Notion.Client/Api/Databases Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change 1- using System . Threading ;
1+ using System ;
2+ using System . Threading ;
23using System . Threading . Tasks ;
34using static Notion . Client . ApiEndpoints ;
45
@@ -15,6 +16,11 @@ public DatabasesClient(IRestClient client)
1516
1617 public async Task < Database > RetrieveAsync ( string databaseId , CancellationToken cancellationToken = default )
1718 {
19+ if ( string . IsNullOrWhiteSpace ( databaseId ) )
20+ {
21+ throw new ArgumentNullException ( nameof ( databaseId ) ) ;
22+ }
23+
1824 return await _client . GetAsync < Database > ( DatabasesApiUrls . Retrieve ( databaseId ) , cancellationToken : cancellationToken ) ;
1925 }
2026
Original file line number Diff line number Diff line change @@ -504,4 +504,18 @@ var jsonData
504504 formulaPropertyValue . Formula . Date . End . Should ( ) . BeNull ( ) ;
505505 }
506506 }
507+
508+ [ Theory ]
509+ [ InlineData ( null ) ]
510+ [ InlineData ( "" ) ]
511+ [ InlineData ( " " ) ]
512+ public async Task RetrieveAsync_throws_argument_null_exception_if_database_id_is_null_or_empty ( string databaseId )
513+ {
514+ // Arrange && Act
515+ async Task < Database > Act ( ) => await _client . RetrieveAsync ( databaseId ) ;
516+
517+ // Assert
518+ var exception = await Assert . ThrowsAsync < ArgumentNullException > ( Act ) ;
519+ Assert . Equal ( "databaseId" , exception . ParamName ) ;
520+ }
507521}
You can’t perform that action at this time.
0 commit comments