Skip to content

Commit 0813c02

Browse files
Make use of IAsyncDisposable in PageWithPageParent test
1 parent 8a0d469 commit 0813c02

File tree

1 file changed

+18
-10
lines changed

1 file changed

+18
-10
lines changed

Test/Notion.IntegrationTests/PageWithPageParentTests.cs

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using System.Collections.Generic;
1+
using System;
2+
using System.Collections.Generic;
23
using System.Linq;
34
using System.Threading.Tasks;
45
using FluentAssertions;
@@ -7,12 +8,12 @@
78

89
namespace Notion.IntegrationTests;
910

10-
public class PageWithPageParentTests : IntegrationTestBase
11+
public class PageWithPageParentTests : IntegrationTestBase, IAsyncDisposable
1112
{
12-
[Fact]
13-
public async Task Update_Title_Of_Page()
13+
private readonly Page _page;
14+
15+
public PageWithPageParentTests()
1416
{
15-
// Arrange
1617
var pagesCreateParameters = PagesCreateParametersBuilder
1718
.Create(new ParentPageInput() { PageId = ParentPageId })
1819
.AddProperty("title",
@@ -24,8 +25,13 @@ public async Task Update_Title_Of_Page()
2425
}
2526
}).Build();
2627

27-
var page = await Client.Pages.CreateAsync(pagesCreateParameters);
28+
_page = Client.Pages.CreateAsync(pagesCreateParameters).GetAwaiter().GetResult();
29+
}
2830

31+
[Fact]
32+
public async Task Update_Title_Of_Page()
33+
{
34+
// Arrange
2935
var updatePage = new PagesUpdateParameters()
3036
{
3137
Properties = new Dictionary<string, PropertyValue>
@@ -44,7 +50,7 @@ public async Task Update_Title_Of_Page()
4450
};
4551

4652
// Act
47-
var updatedPage = await Client.Pages.UpdateAsync(page.Id, updatePage);
53+
var updatedPage = await Client.Pages.UpdateAsync(_page.Id, updatePage);
4854

4955
// Assert
5056
var titleProperty = (ListPropertyItem)await Client.Pages.RetrievePagePropertyItemAsync(
@@ -55,9 +61,11 @@ public async Task Update_Title_Of_Page()
5561
}
5662
);
5763

58-
Assert.Equal("Page Title Updated", titleProperty.Results.First().As<TitlePropertyItem>().Title.PlainText);
64+
titleProperty.Results.First().As<TitlePropertyItem>().Title.PlainText.Should().Be("Page Title Updated");
65+
}
5966

60-
// Clean Up
61-
await Client.Pages.UpdateAsync(page.Id, new PagesUpdateParameters { Archived = true });
67+
public async ValueTask DisposeAsync()
68+
{
69+
await Client.Pages.UpdateAsync(_page.Id, new PagesUpdateParameters { Archived = true });
6270
}
6371
}

0 commit comments

Comments
 (0)