@@ -125,5 +125,70 @@ public async Task PageObjectShouldHaveUrlProperty()
125125
126126 page . Url . Should ( ) . Be ( "https://www.notion.so/Avocado-251d2b5f268c4de2afe9c71ff92ca95c" ) ;
127127 }
128+
129+ [ Fact ]
130+ public async Task UpdatePageAsync ( )
131+ {
132+ var pageId = "251d2b5f-268c-4de2-afe9-c71ff92ca95c" ;
133+ var path = ApiEndpoints . PagesApiUrls . UpdateProperties ( pageId ) ;
134+
135+ var jsonData = await File . ReadAllTextAsync ( "data/pages/UpdatePagePropertiesResponse.json" ) ;
136+
137+ Server . Given ( CreatePatchRequestBuilder ( path ) )
138+ . RespondWith (
139+ Response . Create ( )
140+ . WithStatusCode ( 200 )
141+ . WithBody ( jsonData )
142+ ) ;
143+
144+ var pagesUpdateParameters = new PagesUpdateParameters
145+ {
146+ Properties = new Dictionary < string , PropertyValue > ( )
147+ {
148+ { "In stock" , new CheckboxPropertyValue ( ) { Checkbox = true } }
149+ }
150+ } ;
151+
152+ var page = await _client . UpdateAsync ( pageId , pagesUpdateParameters ) ;
153+
154+ page . Id . Should ( ) . Be ( pageId ) ;
155+ page . IsArchived . Should ( ) . BeFalse ( ) ;
156+ page . Properties . Should ( ) . HaveCount ( 2 ) ;
157+ var updatedProperty = page . Properties . First ( x => x . Key == "In stock" ) ;
158+ ( ( CheckboxPropertyValue ) updatedProperty . Value ) . Checkbox . Should ( ) . BeTrue ( ) ;
159+ }
160+
161+ [ Fact ]
162+ public async Task ArchivePageAsync ( )
163+ {
164+ var pageId = "251d2b5f-268c-4de2-afe9-c71ff92ca95c" ;
165+ var path = ApiEndpoints . PagesApiUrls . UpdateProperties ( pageId ) ;
166+
167+ var jsonData = await File . ReadAllTextAsync ( "data/pages/ArchivePageResponse.json" ) ;
168+
169+ Server . Given ( CreatePatchRequestBuilder ( path ) )
170+ . RespondWith (
171+ Response . Create ( )
172+ . WithStatusCode ( 200 )
173+ . WithBody ( jsonData )
174+ ) ;
175+
176+ var pagesUpdateParameters = new PagesUpdateParameters
177+ {
178+ Archived = true ,
179+ Properties = new Dictionary < string , PropertyValue > ( )
180+ {
181+ { "In stock" , new CheckboxPropertyValue ( ) { Checkbox = true } }
182+ }
183+ } ;
184+
185+ var page = await _client . UpdateAsync ( pageId , pagesUpdateParameters ) ;
186+
187+ page . Id . Should ( ) . Be ( pageId ) ;
188+ page . IsArchived . Should ( ) . BeTrue ( ) ;
189+ page . Properties . Should ( ) . HaveCount ( 2 ) ;
190+ var updatedProperty = page . Properties . First ( x => x . Key == "In stock" ) ;
191+ ( ( CheckboxPropertyValue ) updatedProperty . Value ) . Checkbox . Should ( ) . BeTrue ( ) ;
192+ }
128193 }
129194}
0 commit comments