From 7a9889e0d9b1657955497cd806df1729ccdb6197 Mon Sep 17 00:00:00 2001 From: Vedant Koditkar Date: Mon, 29 Aug 2022 02:14:06 +0530 Subject: [PATCH] Add integration test to verify the fix --- .../IPageClientTests.cs | 54 +++++++++++++++++++ 1 file changed, 54 insertions(+) diff --git a/Test/Notion.IntegrationTests/IPageClientTests.cs b/Test/Notion.IntegrationTests/IPageClientTests.cs index 2b0ec368..acdab301 100644 --- a/Test/Notion.IntegrationTests/IPageClientTests.cs +++ b/Test/Notion.IntegrationTests/IPageClientTests.cs @@ -244,5 +244,59 @@ public async Task Test_UpdatePageProperty_with_date_as_null() //cleanup await _client.Blocks.DeleteAsync(page.Id); } + + [Fact] + public async Task Bug_Unable_To_Parse_NumberPropertyItem() + { + // Arrange + var pagesCreateParameters = PagesCreateParametersBuilder.Create(new DatabaseParentInput + { + DatabaseId = _databaseId + }).AddProperty("Name", new TitlePropertyValue + { + Title = new List + { + new RichTextText + { + Text = new Text + { + Content = "Test Page Title" + } + } + } + }).AddProperty("Number", new NumberPropertyValue + { + Number = 200.00 + }).Build(); + + // Act + var page = await _client.Pages.CreateAsync(pagesCreateParameters); + + // Assert + Assert.NotNull(page); + var pageParent = Assert.IsType(page.Parent); + Assert.Equal(_databaseId, pageParent.DatabaseId); + + var titleProperty = (ListPropertyItem)await _client.Pages.RetrievePagePropertyItem(new RetrievePropertyItemParameters + { + PageId = page.Id, + PropertyId = page.Properties["Name"].Id + }); + + Assert.Equal("Test Page Title", titleProperty.Results.First().As().Title.PlainText); + + var numberProperty = (NumberPropertyItem)await _client.Pages.RetrievePagePropertyItem(new RetrievePropertyItemParameters + { + PageId = page.Id, + PropertyId = page.Properties["Number"].Id + }); + + Assert.Equal(200.00, numberProperty.Number); + + await _client.Pages.UpdateAsync(page.Id, new PagesUpdateParameters + { + Archived = true + }); + } } }