File tree Expand file tree Collapse file tree 2 files changed +18
-1
lines changed
Src/Notion.Client/Api/Databases Expand file tree Collapse file tree 2 files changed +18
-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,15 @@ var jsonData
504504 formulaPropertyValue . Formula . Date . End . Should ( ) . BeNull ( ) ;
505505 }
506506 }
507+
508+ [ Fact ]
509+ public async Task RetrieveAsync_throws_argument_null_exception_if_database_id_is_null_or_empty ( )
510+ {
511+ // Arrange && Act
512+ async Task < Database > Act ( ) => await _client . RetrieveAsync ( null ) ;
513+
514+ // Assert
515+ var exception = await Assert . ThrowsAsync < ArgumentNullException > ( Act ) ;
516+ Assert . Equal ( "databaseId" , exception . ParamName ) ;
517+ }
507518}
You can’t perform that action at this time.
0 commit comments