File tree Expand file tree Collapse file tree 4 files changed +122
-8
lines changed
Src/Notion.Client/Models/Database/Properties Expand file tree Collapse file tree 4 files changed +122
-8
lines changed Original file line number Diff line number Diff line change @@ -30,5 +30,7 @@ public class Property
3030
3131 [ JsonConverter ( typeof ( StringEnumConverter ) ) ]
3232 public virtual PropertyType Type { get ; set ; }
33+
34+ public string Name { get ; set ; }
3335 }
3436}
Original file line number Diff line number Diff line change 1- using System . Threading . Tasks ;
1+ using System . IO ;
2+ using System . Threading . Tasks ;
3+ using FluentAssertions ;
24using Notion . Client ;
5+ using WireMock . ResponseBuilders ;
36using Xunit ;
47
58namespace Notion . UnitTests
69{
7- public class DatabasesClientTests
10+ public class DatabasesClientTests : ApiTestBase
811 {
912 private readonly IDatabasesClient _client ;
1013
1114 public DatabasesClientTests ( )
1215 {
13- var options = new ClientOptions ( )
14- {
15- AuthToken = "<Token>"
16- } ;
17-
18- _client = new DatabasesClient ( new RestClient ( options ) ) ;
16+ _client = new DatabasesClient ( new RestClient ( ClientOptions ) ) ;
1917 }
2018
2119 [ Fact ( Skip = "Internal Testing Purpose" ) ]
@@ -42,5 +40,27 @@ public async Task QueryAsync()
4240
4341 Assert . NotNull ( pagesList ) ;
4442 }
43+
44+ [ Fact ]
45+ public async Task DatabasePropertyObjectContainNameProperty ( )
46+ {
47+ var databaseId = "f0212efc-caf6-4afc-87f6-1c06f1dfc8a1" ;
48+ var path = ApiEndpoints . DatabasesApiUrls . Retrieve ( databaseId ) ;
49+ var jsonData = await File . ReadAllTextAsync ( "data/databases/DatabasePropertyObjectContainNameProperty.json" ) ;
50+
51+ Server . Given ( CreateGetRequestBuilder ( path ) )
52+ . RespondWith (
53+ Response . Create ( )
54+ . WithStatusCode ( 200 )
55+ . WithBody ( jsonData )
56+ ) ;
57+
58+ var database = await _client . RetrieveAsync ( databaseId ) ;
59+
60+ foreach ( var property in database . Properties )
61+ {
62+ property . Key . Should ( ) . Be ( property . Value . Name ) ;
63+ }
64+ }
4565 }
4666}
Original file line number Diff line number Diff line change 3636 <None Update =" data\pages\UpdatePagePropertiesResponse.json" >
3737 <CopyToOutputDirectory >Always</CopyToOutputDirectory >
3838 </None >
39+ <None Update =" data\databases\DatabasePropertyObjectContainNameProperty.json" >
40+ <CopyToOutputDirectory >Always</CopyToOutputDirectory >
41+ </None >
3942 </ItemGroup >
4043
4144</Project >
Original file line number Diff line number Diff line change 1+ {
2+ "object" : " database" ,
3+ "id" : " f0212efc-caf6-4afc-87f6-1c06f1dfc8a1" ,
4+ "created_time" : " 2021-05-22T18:44:00.000Z" ,
5+ "last_edited_time" : " 2021-05-23T12:29:00.000Z" ,
6+ "title" : [
7+ {
8+ "type" : " text" ,
9+ "text" : {
10+ "content" : " sample table" ,
11+ "link" : null
12+ },
13+ "annotations" : {
14+ "bold" : false ,
15+ "italic" : false ,
16+ "strikethrough" : false ,
17+ "underline" : false ,
18+ "code" : false ,
19+ "color" : " default"
20+ },
21+ "plain_text" : " sample table" ,
22+ "href" : null
23+ }
24+ ],
25+ "properties" : {
26+ "Tags" : {
27+ "id" : " YG~h" ,
28+ "name" : " Tags" ,
29+ "type" : " multi_select" ,
30+ "multi_select" : {
31+ "options" : []
32+ }
33+ },
34+ "SimpleText" : {
35+ "id" : " _Dfp" ,
36+ "name" : " SimpleText" ,
37+ "type" : " rich_text" ,
38+ "rich_text" : {}
39+ },
40+ "Column" : {
41+ "id" : " bxhl" ,
42+ "name" : " Column" ,
43+ "type" : " multi_select" ,
44+ "multi_select" : {
45+ "options" : [
46+ {
47+ "id" : " 5a44a233-33be-435e-b358-2c0ed1799dcf" ,
48+ "name" : " what" ,
49+ "color" : " gray"
50+ }
51+ ]
52+ }
53+ },
54+ "SelectProp" : {
55+ "id" : " eZ[y" ,
56+ "name" : " SelectProp" ,
57+ "type" : " select" ,
58+ "select" : {
59+ "options" : [
60+ {
61+ "id" : " 362dc255-c867-4543-b3ea-7bd988638228" ,
62+ "name" : " Female" ,
63+ "color" : " green"
64+ }
65+ ]
66+ }
67+ },
68+ "Property" : {
69+ "id" : " zDGa" ,
70+ "name" : " Property" ,
71+ "type" : " relation" ,
72+ "relation" : {
73+ "database_id" : " f86f2262-0751-40f2-8f63-e3f7a3c39fcb" ,
74+ "synced_property_name" : " Related to sample table (Property)" ,
75+ "synced_property_id" : " VQ}{"
76+ }
77+ },
78+ "Name" : {
79+ "id" : " title" ,
80+ "name" : " Name" ,
81+ "type" : " title" ,
82+ "title" : {}
83+ }
84+ },
85+ "parent" : {
86+ "type" : " page_id" ,
87+ "page_id" : " 649089db-8984-4051-98fb-a03593b852d8"
88+ }
89+ }
You can’t perform that action at this time.
0 commit comments