@@ -7,46 +7,26 @@ namespace Example.OpenApi32.IntegrationTests;
77
88public class ExportFooEventsTests ( FooApplicationFactory app , ITestOutputHelper testOutput ) : FooTestSpecification , IClassFixture < FooApplicationFactory >
99{
10- [ Fact ]
11- public async Task ExportingFooEvents_ShouldReturnOkWithJsonl ( )
10+ [ Theory ]
11+ [ InlineData ( "application/jsonl" ) ]
12+ [ InlineData ( "application/x-jsonlines" ) ]
13+ [ InlineData ( "application/x-ndjson" ) ]
14+ [ InlineData ( "application/json-seq" ) ]
15+ [ InlineData ( "application/geo+json-seq" ) ]
16+ public async Task ExportingFooEvents_ShouldReturnOkWithSequentialJson ( string mediaType )
1217 {
1318 using var client = app . CreateClient ( ) ;
1419 var request = new HttpRequestMessage
1520 {
1621 RequestUri = new Uri ( client . BaseAddress ! , "/foo/1/events" ) ,
1722 Method = HttpMethod . Get
1823 } ;
19- request . Headers . Accept . ParseAdd ( "application/jsonl" ) ;
24+ request . Headers . Accept . ParseAdd ( mediaType ) ;
2025
2126 var result = await client . SendAsync ( request , CancellationToken ) ;
2227
2328 result . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
24- result . Content . Headers . ContentType ? . MediaType . Should ( ) . Be ( "application/jsonl" ) ;
25-
26- var content = await result . Content . ReadAsStringAsync ( CancellationToken ) ;
27- testOutput . WriteLine ( "Content:" ) ;
28- testOutput . WriteLine ( content ) ;
29- var lines = content . Split ( '\n ' , StringSplitOptions . RemoveEmptyEntries ) ;
30- lines . Should ( ) . HaveCount ( 2 ) ;
31- JsonNode . Parse ( lines [ 0 ] ) . GetValue < string > ( "#/Name" ) . Should ( ) . Be ( "foo1" ) ;
32- JsonNode . Parse ( lines [ 1 ] ) . GetValue < string > ( "#/Name" ) . Should ( ) . Be ( "foo2" ) ;
33- }
34-
35- [ Fact ]
36- public async Task ExportingFooEvents_ShouldReturnOkWithJsonSeq ( )
37- {
38- using var client = app . CreateClient ( ) ;
39- var request = new HttpRequestMessage
40- {
41- RequestUri = new Uri ( client . BaseAddress ! , "/foo/1/events" ) ,
42- Method = HttpMethod . Get
43- } ;
44- request . Headers . Accept . ParseAdd ( "application/json-seq" ) ;
45-
46- var result = await client . SendAsync ( request , CancellationToken ) ;
47-
48- result . StatusCode . Should ( ) . Be ( HttpStatusCode . OK ) ;
49- result . Content . Headers . ContentType ? . MediaType . Should ( ) . Be ( "application/json-seq" ) ;
29+ result . Content . Headers . ContentType ? . MediaType . Should ( ) . Be ( mediaType ) ;
5030
5131 var content = await result . Content . ReadAsStringAsync ( CancellationToken ) ;
5232 testOutput . WriteLine ( "Content:" ) ;
@@ -58,4 +38,4 @@ public async Task ExportingFooEvents_ShouldReturnOkWithJsonSeq()
5838 JsonNode . Parse ( lines [ 0 ] ) . GetValue < string > ( "#/Name" ) . Should ( ) . Be ( "foo1" ) ;
5939 JsonNode . Parse ( lines [ 1 ] ) . GetValue < string > ( "#/Name" ) . Should ( ) . Be ( "foo2" ) ;
6040 }
61- }
41+ }
0 commit comments