22using System . Collections . Generic ;
33using System . Linq ;
44using System . Threading . Tasks ;
5+ using FluentAssertions ;
56using Notion . Client ;
67using Xunit ;
78
89namespace Notion . IntegrationTests ;
910
10- public class DatabasesClientTests : IntegrationTestBase , IDisposable
11+ public class DatabasesClientTests : IntegrationTestBase , IAsyncDisposable
1112{
1213 private readonly Page _page ;
1314
@@ -17,12 +18,12 @@ public DatabasesClientTests()
1718 PagesCreateParametersBuilder . Create (
1819 new ParentPageInput { PageId = ParentPageId }
1920 ) . Build ( )
20- ) . Result ;
21+ ) . GetAwaiter ( ) . GetResult ( ) ;
2122 }
2223
23- public void Dispose ( )
24+ public async ValueTask DisposeAsync ( )
2425 {
25- Client . Pages . UpdateAsync ( _page . Id , new PagesUpdateParameters { Archived = true } ) . Wait ( ) ;
26+ await Client . Pages . UpdateAsync ( _page . Id , new PagesUpdateParameters { Archived = true } ) ;
2627 }
2728
2829 [ Fact ]
@@ -35,11 +36,12 @@ public async Task QueryDatabase()
3536 var response = await Client . Databases . QueryAsync ( createdDatabase . Id , new DatabasesQueryParameters ( ) ) ;
3637
3738 // Assert
38- Assert . NotNull ( response . Results ) ;
39- Assert . Single ( response . Results ) ;
40- var page = response . Results . Cast < Page > ( ) . First ( ) ;
41- var title = page . Properties [ "Name" ] as TitlePropertyValue ;
42- Assert . Equal ( "Test Title" , ( title ! . Title . Cast < RichTextText > ( ) . First ( ) ) . Text . Content ) ;
39+ response . Results . Should ( ) . NotBeNull ( ) ;
40+ var page = response . Results . Should ( ) . ContainSingle ( ) . Subject . As < Page > ( ) ;
41+
42+ page . Properties [ "Name" ] . As < TitlePropertyValue > ( )
43+ . Title . Cast < RichTextText > ( ) . First ( )
44+ . Text . Content . Should ( ) . Be ( "Test Title" ) ;
4345 }
4446
4547 private async Task < Database > CreateDatabaseWithAPageAsync ( )
0 commit comments