Skip to content

Commit f5db148

Browse files
Use IAsyncDisposable in Databases Client tests
* use fluent assertions
1 parent 5231ed1 commit f5db148

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

Test/Notion.IntegrationTests/DatabasesClientTests.cs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,13 @@
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
5+
using FluentAssertions;
56
using Notion.Client;
67
using Xunit;
78

89
namespace 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

Comments
 (0)