1- using System . Collections . Generic ;
1+ using System ;
2+ using System . Collections . Generic ;
23using System . IO ;
34using System . Linq ;
45using System . Threading . Tasks ;
@@ -56,6 +57,11 @@ public async Task CreateAsync()
5657 ) ;
5758
5859 var newPage = new NewPage ( ) ;
60+ newPage . Parent = new PageParent
61+ {
62+ PageId = "3c357473-a281-49a4-88c0-10d2b245a589"
63+ } ;
64+
5965 newPage . AddProperty ( "Name" , new TitlePropertyValue ( )
6066 {
6167 Title = new List < RichTextBase > ( )
@@ -77,6 +83,8 @@ public async Task CreateAsync()
7783 page . Properties . Should ( ) . HaveCount ( 1 ) ;
7884 page . Properties . First ( ) . Key . Should ( ) . Be ( "Name" ) ;
7985 page . IsArchived . Should ( ) . BeFalse ( ) ;
86+ page . Parent . Should ( ) . NotBeNull ( ) ;
87+ ( ( PageParent ) page . Parent ) . PageId . Should ( ) . Be ( "3c357473-a281-49a4-88c0-10d2b245a589" ) ;
8088 }
8189
8290 [ Fact ]
@@ -190,5 +198,38 @@ public async Task ArchivePageAsync()
190198 var updatedProperty = page . Properties . First ( x => x . Key == "In stock" ) ;
191199 ( ( CheckboxPropertyValue ) updatedProperty . Value ) . Checkbox . Should ( ) . BeTrue ( ) ;
192200 }
201+
202+ [ Fact ]
203+ public async Task CreateAsync_Throws_ArgumentNullException_When_Parameter_Is_Null ( )
204+ {
205+ Func < Task > act = async ( ) => await _client . CreateAsync ( null ) ;
206+
207+ ( await act . Should ( ) . ThrowAsync < ArgumentNullException > ( ) ) . And . ParamName . Should ( ) . Be ( "page" ) ;
208+ }
209+
210+ [ Fact ]
211+ public async Task CreateAsync_Throws_ArgumentNullException_When_Parent_Is_Missing ( )
212+ {
213+ var newPage = new NewPage ( ) ;
214+
215+ Func < Task > act = async ( ) => await _client . CreateAsync ( newPage ) ;
216+
217+ ( await act . Should ( ) . ThrowAsync < ArgumentNullException > ( ) ) . And . ParamName . Should ( ) . Be ( "Parent" ) ;
218+ }
219+
220+ [ Fact ]
221+ public async Task CreateAsync_Throws_ArgumentNullException_When_Properties_Is_Missing ( )
222+ {
223+ var newPage = new NewPage ( new PageParent ( )
224+ {
225+ PageId = "3c357473-a281-49a4-88c0-10d2b245a589"
226+ } ) ;
227+
228+ newPage . Properties = null ;
229+
230+ Func < Task > act = async ( ) => await _client . CreateAsync ( newPage ) ;
231+
232+ ( await act . Should ( ) . ThrowAsync < ArgumentNullException > ( ) ) . And . ParamName . Should ( ) . Be ( "Properties" ) ;
233+ }
193234 }
194235}
0 commit comments