@@ -43,30 +43,27 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
43
43
using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory . CreateAdapter ( _testContext . Factory ) ;
44
44
var apiClient = new QueryStringsClient ( requestAdapter ) ;
45
45
46
- var queryString = new Dictionary < string , string ? >
46
+ using IDisposable scope = _requestAdapterFactory . WithQueryString ( new Dictionary < string , string ? >
47
47
{
48
48
[ "filter" ] = "equals(name,'Brian O''Quote')"
49
- } ;
49
+ } ) ;
50
+
51
+ // Act
52
+ NodeCollectionResponseDocument ? response = await apiClient . Nodes . GetAsync ( ) ;
50
53
51
- using ( _requestAdapterFactory . WithQueryString ( queryString ) )
54
+ // Assert
55
+ response . Should ( ) . NotBeNull ( ) ;
56
+ response . Data . Should ( ) . HaveCount ( 1 ) ;
57
+ response . Data . ElementAt ( 0 ) . Id . Should ( ) . Be ( nodes [ 1 ] . StringId ) ;
58
+
59
+ response . Data . ElementAt ( 0 ) . Attributes . RefShould ( ) . NotBeNull ( ) . And . Subject . With ( attributes =>
52
60
{
53
- // Act
54
- NodeCollectionResponseDocument ? response = await apiClient . Nodes . GetAsync ( ) ;
55
-
56
- // Assert
57
- response . Should ( ) . NotBeNull ( ) ;
58
- response . Data . Should ( ) . HaveCount ( 1 ) ;
59
- response . Data . ElementAt ( 0 ) . Id . Should ( ) . Be ( nodes [ 1 ] . StringId ) ;
60
-
61
- response . Data . ElementAt ( 0 ) . Attributes . RefShould ( ) . NotBeNull ( ) . And . Subject . With ( attributes =>
62
- {
63
- attributes . Name . Should ( ) . Be ( nodes [ 1 ] . Name ) ;
64
- attributes . Comment . Should ( ) . Be ( nodes [ 1 ] . Comment ) ;
65
- } ) ;
66
-
67
- response . Meta . Should ( ) . NotBeNull ( ) ;
68
- response . Meta . AdditionalData . Should ( ) . ContainKey ( "total" ) . WhoseValue . Should ( ) . Be ( 1 ) ;
69
- }
61
+ attributes . Name . Should ( ) . Be ( nodes [ 1 ] . Name ) ;
62
+ attributes . Comment . Should ( ) . Be ( nodes [ 1 ] . Comment ) ;
63
+ } ) ;
64
+
65
+ response . Meta . Should ( ) . NotBeNull ( ) ;
66
+ response . Meta . AdditionalData . Should ( ) . ContainKey ( "total" ) . WhoseValue . Should ( ) . Be ( 1 ) ;
70
67
}
71
68
72
69
[ Fact ]
@@ -88,30 +85,27 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
88
85
using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory . CreateAdapter ( _testContext . Factory ) ;
89
86
var apiClient = new QueryStringsClient ( requestAdapter ) ;
90
87
91
- var queryString = new Dictionary < string , string ? >
88
+ using IDisposable scope = _requestAdapterFactory . WithQueryString ( new Dictionary < string , string ? >
92
89
{
93
90
[ "filter" ] = "and(startsWith(comment,'Discount:'),contains(comment,'%'))"
94
- } ;
91
+ } ) ;
92
+
93
+ // Act
94
+ NodeCollectionResponseDocument ? response = await apiClient . Nodes [ node . StringId ! ] . Children . GetAsync ( ) ;
95
95
96
- using ( _requestAdapterFactory . WithQueryString ( queryString ) )
96
+ // Assert
97
+ response . Should ( ) . NotBeNull ( ) ;
98
+ response . Data . Should ( ) . HaveCount ( 1 ) ;
99
+ response . Data . ElementAt ( 0 ) . Id . Should ( ) . Be ( node . Children . ElementAt ( 1 ) . StringId ) ;
100
+
101
+ response . Data . ElementAt ( 0 ) . Attributes . RefShould ( ) . NotBeNull ( ) . And . Subject . With ( attributes =>
97
102
{
98
- // Act
99
- NodeCollectionResponseDocument ? response = await apiClient . Nodes [ node . StringId ! ] . Children . GetAsync ( ) ;
100
-
101
- // Assert
102
- response . Should ( ) . NotBeNull ( ) ;
103
- response . Data . Should ( ) . HaveCount ( 1 ) ;
104
- response . Data . ElementAt ( 0 ) . Id . Should ( ) . Be ( node . Children . ElementAt ( 1 ) . StringId ) ;
105
-
106
- response . Data . ElementAt ( 0 ) . Attributes . RefShould ( ) . NotBeNull ( ) . And . Subject . With ( attributes =>
107
- {
108
- attributes . Name . Should ( ) . Be ( node . Children . ElementAt ( 1 ) . Name ) ;
109
- attributes . Comment . Should ( ) . Be ( node . Children . ElementAt ( 1 ) . Comment ) ;
110
- } ) ;
111
-
112
- response . Meta . Should ( ) . NotBeNull ( ) ;
113
- response . Meta . AdditionalData . Should ( ) . ContainKey ( "total" ) . WhoseValue . Should ( ) . Be ( 1 ) ;
114
- }
103
+ attributes . Name . Should ( ) . Be ( node . Children . ElementAt ( 1 ) . Name ) ;
104
+ attributes . Comment . Should ( ) . Be ( node . Children . ElementAt ( 1 ) . Comment ) ;
105
+ } ) ;
106
+
107
+ response . Meta . Should ( ) . NotBeNull ( ) ;
108
+ response . Meta . AdditionalData . Should ( ) . ContainKey ( "total" ) . WhoseValue . Should ( ) . Be ( 1 ) ;
115
109
}
116
110
117
111
[ Fact ]
@@ -133,25 +127,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
133
127
using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory . CreateAdapter ( _testContext . Factory ) ;
134
128
var apiClient = new QueryStringsClient ( requestAdapter ) ;
135
129
136
- var queryString = new Dictionary < string , string ? >
130
+ using IDisposable scope = _requestAdapterFactory . WithQueryString ( new Dictionary < string , string ? >
137
131
{
138
132
[ "filter" ] = "greaterThan(count(children),'1')"
139
- } ;
133
+ } ) ;
140
134
141
- using ( _requestAdapterFactory . WithQueryString ( queryString ) )
142
- {
143
- // Act
144
- NodeIdentifierCollectionResponseDocument ? response = await apiClient . Nodes [ node . StringId ! ] . Relationships . Children . GetAsync ( ) ;
145
-
146
- // Assert
147
- response . Should ( ) . NotBeNull ( ) ;
148
- response . Data . Should ( ) . HaveCount ( 1 ) ;
149
- response . Data . ElementAt ( 0 ) . Id . Should ( ) . Be ( node . Children . ElementAt ( 1 ) . StringId ) ;
150
- response . Meta . Should ( ) . NotBeNull ( ) ;
151
- response . Meta . AdditionalData . Should ( ) . ContainKey ( "total" ) . WhoseValue . Should ( ) . Be ( 1 ) ;
152
- response . Links . Should ( ) . NotBeNull ( ) ;
153
- response . Links . Describedby . Should ( ) . Be ( "/swagger/v1/swagger.json" ) ;
154
- }
135
+ // Act
136
+ NodeIdentifierCollectionResponseDocument ? response = await apiClient . Nodes [ node . StringId ! ] . Relationships . Children . GetAsync ( ) ;
137
+
138
+ // Assert
139
+ response . Should ( ) . NotBeNull ( ) ;
140
+ response . Data . Should ( ) . HaveCount ( 1 ) ;
141
+ response . Data . ElementAt ( 0 ) . Id . Should ( ) . Be ( node . Children . ElementAt ( 1 ) . StringId ) ;
142
+ response . Meta . Should ( ) . NotBeNull ( ) ;
143
+ response . Meta . AdditionalData . Should ( ) . ContainKey ( "total" ) . WhoseValue . Should ( ) . Be ( 1 ) ;
144
+ response . Links . Should ( ) . NotBeNull ( ) ;
145
+ response . Links . Describedby . Should ( ) . Be ( "/swagger/v1/swagger.json" ) ;
155
146
}
156
147
157
148
[ Fact ]
@@ -161,31 +152,28 @@ public async Task Cannot_use_empty_filter()
161
152
using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory . CreateAdapter ( _testContext . Factory ) ;
162
153
var apiClient = new QueryStringsClient ( requestAdapter ) ;
163
154
164
- var queryString = new Dictionary < string , string ? >
155
+ using IDisposable scope = _requestAdapterFactory . WithQueryString ( new Dictionary < string , string ? >
165
156
{
166
157
[ "filter" ] = null
167
- } ;
158
+ } ) ;
168
159
169
- using ( _requestAdapterFactory . WithQueryString ( queryString ) )
170
- {
171
- // Act
172
- Func < Task > action = async ( ) => _ = await apiClient . Nodes [ Unknown . StringId . Int64 ] . GetAsync ( ) ;
173
-
174
- // Assert
175
- ErrorResponseDocument exception = ( await action . Should ( ) . ThrowExactlyAsync < ErrorResponseDocument > ( ) ) . Which ;
176
- exception . ResponseStatusCode . Should ( ) . Be ( ( int ) HttpStatusCode . BadRequest ) ;
177
- exception . Message . Should ( ) . Be ( $ "Exception of type '{ typeof ( ErrorResponseDocument ) . FullName } ' was thrown.") ;
178
- exception . Links . Should ( ) . NotBeNull ( ) ;
179
- exception . Links . Describedby . Should ( ) . Be ( "/swagger/v1/swagger.json" ) ;
180
- exception . Errors . Should ( ) . HaveCount ( 1 ) ;
181
-
182
- ErrorObject error = exception . Errors [ 0 ] ;
183
- error . Status . Should ( ) . Be ( "400" ) ;
184
- error . Title . Should ( ) . Be ( "Missing query string parameter value." ) ;
185
- error . Detail . Should ( ) . Be ( "Missing value for 'filter' query string parameter." ) ;
186
- error . Source . Should ( ) . NotBeNull ( ) ;
187
- error . Source . Parameter . Should ( ) . Be ( "filter" ) ;
188
- }
160
+ // Act
161
+ Func < Task > action = async ( ) => _ = await apiClient . Nodes [ Unknown . StringId . Int64 ] . GetAsync ( ) ;
162
+
163
+ // Assert
164
+ ErrorResponseDocument exception = ( await action . Should ( ) . ThrowExactlyAsync < ErrorResponseDocument > ( ) ) . Which ;
165
+ exception . ResponseStatusCode . Should ( ) . Be ( ( int ) HttpStatusCode . BadRequest ) ;
166
+ exception . Message . Should ( ) . Be ( $ "Exception of type '{ typeof ( ErrorResponseDocument ) . FullName } ' was thrown.") ;
167
+ exception . Links . Should ( ) . NotBeNull ( ) ;
168
+ exception . Links . Describedby . Should ( ) . Be ( "/swagger/v1/swagger.json" ) ;
169
+ exception . Errors . Should ( ) . HaveCount ( 1 ) ;
170
+
171
+ ErrorObject error = exception . Errors [ 0 ] ;
172
+ error . Status . Should ( ) . Be ( "400" ) ;
173
+ error . Title . Should ( ) . Be ( "Missing query string parameter value." ) ;
174
+ error . Detail . Should ( ) . Be ( "Missing value for 'filter' query string parameter." ) ;
175
+ error . Source . Should ( ) . NotBeNull ( ) ;
176
+ error . Source . Parameter . Should ( ) . Be ( "filter" ) ;
189
177
}
190
178
191
179
public void Dispose ( )
0 commit comments