1
- using System . Collections . Generic ;
1
+ using System ;
2
+ using System . Collections . Generic ;
2
3
using System . IO ;
3
4
using System . Linq ;
4
5
using System . Threading . Tasks ;
@@ -56,6 +57,11 @@ public async Task CreateAsync()
56
57
) ;
57
58
58
59
var newPage = new NewPage ( ) ;
60
+ newPage . Parent = new PageParent
61
+ {
62
+ PageId = "3c357473-a281-49a4-88c0-10d2b245a589"
63
+ } ;
64
+
59
65
newPage . AddProperty ( "Name" , new TitlePropertyValue ( )
60
66
{
61
67
Title = new List < RichTextBase > ( )
@@ -77,6 +83,8 @@ public async Task CreateAsync()
77
83
page . Properties . Should ( ) . HaveCount ( 1 ) ;
78
84
page . Properties . First ( ) . Key . Should ( ) . Be ( "Name" ) ;
79
85
page . IsArchived . Should ( ) . BeFalse ( ) ;
86
+ page . Parent . Should ( ) . NotBeNull ( ) ;
87
+ ( ( PageParent ) page . Parent ) . PageId . Should ( ) . Be ( "3c357473-a281-49a4-88c0-10d2b245a589" ) ;
80
88
}
81
89
82
90
[ Fact ]
@@ -190,5 +198,38 @@ public async Task ArchivePageAsync()
190
198
var updatedProperty = page . Properties . First ( x => x . Key == "In stock" ) ;
191
199
( ( CheckboxPropertyValue ) updatedProperty . Value ) . Checkbox . Should ( ) . BeTrue ( ) ;
192
200
}
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
+ }
193
234
}
194
235
}
0 commit comments