1
1
#if ! ( NET452 || NET461 || NETCOREAPP3_1 )
2
2
using System ;
3
+ using System . Collections . Generic ;
3
4
using System . IO ;
4
5
using System . Linq ;
5
6
using System . Net ;
25
26
using WireMock . ResponseBuilders ;
26
27
using WireMock . Server ;
27
28
using WireMock . Settings ;
29
+ using WireMock . Types ;
28
30
using Xunit ;
29
31
30
32
namespace WireMock . Net . Tests ;
@@ -254,7 +256,7 @@ public async Task IWireMockAdminApi_FindRequestsAsync()
254
256
}
255
257
256
258
[ Fact ]
257
- public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_Found ( )
259
+ public async Task IWireMockAdminApi_FindRequestsByMappingGuidAsync_Found ( )
258
260
{
259
261
// Arrange
260
262
var mappingGuid = Guid . NewGuid ( ) ;
@@ -269,21 +271,33 @@ public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_Found()
269
271
. RespondWith ( Response . Create ( ) ) ;
270
272
271
273
var serverUrl = "http://localhost:" + server . Ports [ 0 ] ;
272
- await new HttpClient ( ) . GetAsync ( serverUrl + "/foo" ) . ConfigureAwait ( false ) ;
274
+ using var client = new HttpClient ( ) ;
275
+ await client . GetAsync ( serverUrl + "/foo" ) . ConfigureAwait ( false ) ;
276
+ await client . GetAsync ( serverUrl + "/foo?bar=baz" ) . ConfigureAwait ( false ) ;
273
277
var api = RestClient . For < IWireMockAdminApi > ( serverUrl ) ;
274
278
275
279
// Act
276
- var logEntryModel = await api . FindRequestByMappingGuidAsync ( mappingGuid ) . ConfigureAwait ( false ) ;
280
+ var logEntryModels = await api . FindRequestsByMappingGuidAsync ( mappingGuid ) . ConfigureAwait ( false ) ;
277
281
278
282
// Assert
279
- logEntryModel . Should ( ) . NotBeNull ( ) ;
280
- logEntryModel ! . Request . Method . Should ( ) . Be ( "GET" ) ;
281
- logEntryModel ! . Request . Body . Should ( ) . BeNull ( ) ;
282
- logEntryModel ! . Request . Path . Should ( ) . Be ( "/foo" ) ;
283
+ logEntryModels . Should ( ) . HaveCount ( 2 ) ;
284
+ logEntryModels [ 0 ] . Should ( ) . NotBeNull ( ) ;
285
+ logEntryModels [ 0 ] ! . Request . Method . Should ( ) . Be ( "GET" ) ;
286
+ logEntryModels [ 0 ] ! . Request . Body . Should ( ) . BeNull ( ) ;
287
+ logEntryModels [ 0 ] ! . Request . Path . Should ( ) . Be ( "/foo" ) ;
288
+ logEntryModels [ 0 ] ! . Request . Query . Should ( ) . BeNullOrEmpty ( ) ;
289
+ logEntryModels [ 1 ] . Should ( ) . NotBeNull ( ) ;
290
+ logEntryModels [ 1 ] ! . Request . Method . Should ( ) . Be ( "GET" ) ;
291
+ logEntryModels [ 1 ] ! . Request . Body . Should ( ) . BeNull ( ) ;
292
+ logEntryModels [ 1 ] ! . Request . Path . Should ( ) . Be ( "/foo" ) ;
293
+ logEntryModels [ 1 ] ! . Request . Query . Should ( ) . BeEquivalentTo ( new Dictionary < string , WireMockList < string > >
294
+ {
295
+ { "bar" , new WireMockList < string > ( "baz" ) }
296
+ } ) ;
283
297
}
284
298
285
299
[ Fact ]
286
- public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_NotFound ( )
300
+ public async Task IWireMockAdminApi_FindRequestsByMappingGuidAsync_NotFound ( )
287
301
{
288
302
// Arrange
289
303
var server = WireMockServer . Start ( new WireMockServerSettings
@@ -301,14 +315,14 @@ public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_NotFound()
301
315
var api = RestClient . For < IWireMockAdminApi > ( serverUrl ) ;
302
316
303
317
// Act
304
- var logEntryModel = await api . FindRequestByMappingGuidAsync ( Guid . NewGuid ( ) ) . ConfigureAwait ( false ) ;
318
+ var logEntryModels = await api . FindRequestsByMappingGuidAsync ( Guid . NewGuid ( ) ) . ConfigureAwait ( false ) ;
305
319
306
320
// Assert
307
- logEntryModel . Should ( ) . BeNull ( ) ;
321
+ logEntryModels . Should ( ) . BeEmpty ( ) ;
308
322
}
309
323
310
324
[ Fact ]
311
- public async Task IWireMockAdminApi_FindRequestByMappingGuidAsync_Invalid_ShouldReturnBadRequest ( )
325
+ public async Task IWireMockAdminApi_FindRequestsByMappingGuidAsync_Invalid_ShouldReturnBadRequest ( )
312
326
{
313
327
// Arrange
314
328
var server = WireMockServer . Start ( new WireMockServerSettings
@@ -1001,4 +1015,4 @@ public async Task IWireMockAdminApi_OpenApiSave_Yml()
1001
1015
server . Stop ( ) ;
1002
1016
}
1003
1017
}
1004
- #endif
1018
+ #endif
0 commit comments