1+ using System ;
12using System . Collections . Generic ;
23using System . Linq ;
34using System . Net ;
45using System . Net . Http ;
56using System . Net . Http . Headers ;
67using System . Threading . Tasks ;
78using Bogus ;
9+ using JsonApiDotNetCore . Models ;
810using JsonApiDotNetCore . Serialization ;
911using JsonApiDotNetCoreExample . Data ;
1012using JsonApiDotNetCoreExample . Models ;
@@ -50,27 +52,26 @@ public async Task Can_Fetch_Many_To_Many_Through_All()
5052
5153 var route = $ "/api/v1/articles?include=tags";
5254
53-
54-
5555 // act
5656 var response = await _fixture . Client . GetAsync ( route ) ;
5757
5858 // assert
5959 var body = await response . Content . ReadAsStringAsync ( ) ;
6060 Assert . True ( HttpStatusCode . OK == response . StatusCode , $ "{ route } returned { response . StatusCode } status code with payload: { body } ") ;
6161
62- Assert . True ( body . Contains ( "include" ) ) ;
62+ var document = JsonConvert . DeserializeObject < Documents > ( body ) ;
63+ Assert . NotEmpty ( document . Included ) ;
6364
6465 var articleResponseList = _fixture . GetService < IJsonApiDeSerializer > ( ) . DeserializeList < Article > ( body ) ;
6566 Assert . NotNull ( articleResponseList ) ;
67+
6668 var articleResponse = articleResponseList . FirstOrDefault ( a => a . Id == article . Id ) ;
6769 Assert . NotNull ( articleResponse ) ;
6870 Assert . Equal ( article . Name , articleResponse . Name ) ;
6971
7072 var tagResponse = Assert . Single ( articleResponse . Tags ) ;
7173 Assert . Equal ( tag . Id , tagResponse . Id ) ;
7274 Assert . Equal ( tag . Name , tagResponse . Name ) ;
73-
7475 }
7576
7677 [ Fact ]
@@ -96,7 +97,9 @@ public async Task Can_Fetch_Many_To_Many_Through_GetById()
9697 // assert
9798 var body = await response . Content . ReadAsStringAsync ( ) ;
9899 Assert . True ( HttpStatusCode . OK == response . StatusCode , $ "{ route } returned { response . StatusCode } status code with payload: { body } ") ;
99- Assert . True ( body . Contains ( "include" ) ) ;
100+
101+ var document = JsonConvert . DeserializeObject < Document > ( body ) ;
102+ Assert . NotEmpty ( document . Included ) ;
100103
101104 var articleResponse = _fixture . GetService < IJsonApiDeSerializer > ( ) . Deserialize < Article > ( body ) ;
102105 Assert . NotNull ( articleResponse ) ;
@@ -105,7 +108,6 @@ public async Task Can_Fetch_Many_To_Many_Through_GetById()
105108 var tagResponse = Assert . Single ( articleResponse . Tags ) ;
106109 Assert . Equal ( tag . Id , tagResponse . Id ) ;
107110 Assert . Equal ( tag . Name , tagResponse . Name ) ;
108-
109111 }
110112
111113 [ Fact ]
0 commit comments