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 ;
2
3
using System . Threading . Tasks ;
3
4
using static Notion . Client . ApiEndpoints ;
4
5
@@ -15,6 +16,11 @@ public DatabasesClient(IRestClient client)
15
16
16
17
public async Task < Database > RetrieveAsync ( string databaseId , CancellationToken cancellationToken = default )
17
18
{
19
+ if ( string . IsNullOrWhiteSpace ( databaseId ) )
20
+ {
21
+ throw new ArgumentNullException ( nameof ( databaseId ) ) ;
22
+ }
23
+
18
24
return await _client . GetAsync < Database > ( DatabasesApiUrls . Retrieve ( databaseId ) , cancellationToken : cancellationToken ) ;
19
25
}
20
26
Original file line number Diff line number Diff line change @@ -504,4 +504,18 @@ var jsonData
504
504
formulaPropertyValue . Formula . Date . End . Should ( ) . BeNull ( ) ;
505
505
}
506
506
}
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
+ }
507
521
}
You can’t perform that action at this time.
0 commit comments