@@ -109,4 +109,83 @@ public async Task ShouldQueryMultipleContentFields()
109
109
110
110
Assert . Equal ( context . Product2ContentItemId , result [ "data" ] [ "product" ] . AsArray ( ) . First ( ) [ "contentItemId" ] . ToString ( ) ) ;
111
111
}
112
+
113
+ [ Fact ]
114
+ public async Task ShouldOrderByCreatedUtc ( )
115
+ {
116
+ using var context = new DynamicContentTypeContext ( ) ;
117
+ await context . InitializeAsync ( ) ;
118
+
119
+ var resultAsc = await context
120
+ . GraphQLClient
121
+ . Content
122
+ . Query ( @"product(orderBy: {createdUtc: ASC}) {
123
+ contentItemId
124
+ displayText
125
+ createdUtc
126
+ }" ) ;
127
+
128
+ var resultDesc = await context
129
+ . GraphQLClient
130
+ . Content
131
+ . Query ( @"product(orderBy: {createdUtc: DESC}) {
132
+ contentItemId
133
+ displayText
134
+ createdUtc
135
+ }" ) ;
136
+
137
+ Assert . Equal ( new DateTime ( 2024 , 04 , 07 , 0 , 0 , 0 , DateTimeKind . Utc ) , resultAsc [ "data" ] [ "product" ] . AsArray ( ) . First ( ) [ "createdUtc" ] . GetValue < DateTime > ( ) ) ;
138
+ Assert . Equal ( new DateTime ( 2024 , 05 , 18 , 0 , 0 , 0 , DateTimeKind . Utc ) , resultDesc [ "data" ] [ "product" ] . AsArray ( ) . First ( ) [ "createdUtc" ] . GetValue < DateTime > ( ) ) ;
139
+ }
140
+
141
+ [ Fact ]
142
+ public async Task ShouldQuerySimilarNamedContentFields ( )
143
+ {
144
+ using var context = new DynamicContentTypeContext ( ) ;
145
+ await context . InitializeAsync ( ) ;
146
+
147
+ var numberResult = await context
148
+ . GraphQLClient
149
+ . Content
150
+ . Query ( @"numberType(where: {value: 123}) {
151
+ contentItemId
152
+ displayText
153
+ value
154
+ }" ) ;
155
+
156
+ var stringResult = await context
157
+ . GraphQLClient
158
+ . Content
159
+ . Query ( @"stringType(where: {value: ""Text123""}) {
160
+ contentItemId
161
+ displayText
162
+ value
163
+ }" ) ;
164
+
165
+ Assert . Single ( numberResult [ "data" ] [ "numberType" ] . AsArray ( ) ) ;
166
+ Assert . Equal ( "123" , numberResult [ "data" ] [ "numberType" ] . AsArray ( ) . First ( ) [ "value" ] . ToString ( ) ) ;
167
+
168
+ Assert . Single ( stringResult [ "data" ] [ "stringType" ] . AsArray ( ) ) ;
169
+ Assert . Equal ( "Text123" , stringResult [ "data" ] [ "stringType" ] . AsArray ( ) . First ( ) [ "value" ] . ToString ( ) ) ;
170
+ }
171
+
172
+ [ Fact ]
173
+ public async Task ShouldDistinquishMultipleNamedContentFields ( )
174
+ {
175
+ using var context = new DynamicContentTypeContext ( ) ;
176
+ await context . InitializeAsync ( ) ;
177
+
178
+ // Make sure values of field2 are not included by querying field1
179
+ var result = await context
180
+ . GraphQLClient
181
+ . Content
182
+ . Query ( @"twoNumbersType(where: {field1: 200}) {
183
+ contentItemId
184
+ displayText
185
+ field1
186
+ field2
187
+ }" ) ;
188
+
189
+ Assert . Empty ( result [ "data" ] [ "twoNumbersType" ] . AsArray ( ) ) ;
190
+ }
112
191
}
0 commit comments