@@ -43,30 +43,27 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
4343 using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory . CreateAdapter ( _testContext . Factory ) ;
4444 var apiClient = new QueryStringsClient ( requestAdapter ) ;
4545
46- var queryString = new Dictionary < string , string ? >
46+ using IDisposable scope = _requestAdapterFactory . WithQueryString ( new Dictionary < string , string ? >
4747 {
4848 [ "filter" ] = "equals(name,'Brian O''Quote')"
49- } ;
49+ } ) ;
50+
51+ // Act
52+ NodeCollectionResponseDocument ? response = await apiClient . Nodes . GetAsync ( ) ;
5053
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 =>
5260 {
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 ) ;
7067 }
7168
7269 [ Fact ]
@@ -88,30 +85,27 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
8885 using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory . CreateAdapter ( _testContext . Factory ) ;
8986 var apiClient = new QueryStringsClient ( requestAdapter ) ;
9087
91- var queryString = new Dictionary < string , string ? >
88+ using IDisposable scope = _requestAdapterFactory . WithQueryString ( new Dictionary < string , string ? >
9289 {
9390 [ "filter" ] = "and(startsWith(comment,'Discount:'),contains(comment,'%'))"
94- } ;
91+ } ) ;
92+
93+ // Act
94+ NodeCollectionResponseDocument ? response = await apiClient . Nodes [ node . StringId ! ] . Children . GetAsync ( ) ;
9595
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 =>
97102 {
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 ) ;
115109 }
116110
117111 [ Fact ]
@@ -133,25 +127,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
133127 using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory . CreateAdapter ( _testContext . Factory ) ;
134128 var apiClient = new QueryStringsClient ( requestAdapter ) ;
135129
136- var queryString = new Dictionary < string , string ? >
130+ using IDisposable scope = _requestAdapterFactory . WithQueryString ( new Dictionary < string , string ? >
137131 {
138132 [ "filter" ] = "greaterThan(count(children),'1')"
139- } ;
133+ } ) ;
140134
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" ) ;
155146 }
156147
157148 [ Fact ]
@@ -161,31 +152,28 @@ public async Task Cannot_use_empty_filter()
161152 using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory . CreateAdapter ( _testContext . Factory ) ;
162153 var apiClient = new QueryStringsClient ( requestAdapter ) ;
163154
164- var queryString = new Dictionary < string , string ? >
155+ using IDisposable scope = _requestAdapterFactory . WithQueryString ( new Dictionary < string , string ? >
165156 {
166157 [ "filter" ] = null
167- } ;
158+ } ) ;
168159
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" ) ;
189177 }
190178
191179 public void Dispose ( )
0 commit comments