33using System . Net . Http ;
44using System . Threading . Tasks ;
55using Bogus ;
6+ using JsonApiDotNetCore . Models ;
67using JsonApiDotNetCoreExample ;
78using JsonApiDotNetCoreExample . Data ;
89using JsonApiDotNetCoreExample . Models ;
@@ -83,15 +84,10 @@ public async Task Can_Include_Nested_HasMany_Relationships()
8384 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
8485
8586 var body = await response . Content . ReadAsStringAsync ( ) ;
86- var todoItems = _fixture . DeSerializer . DeserializeList < TodoItem > ( body ) ;
87-
88- var responseTodoItem = todoItems [ 0 ] ;
89- Assert . NotNull ( responseTodoItem ) ;
90- Assert . NotNull ( responseTodoItem . Collection ) ;
91- Assert . NotNull ( responseTodoItem . Collection . TodoItems ) ;
92- Assert . Equal ( 2 , responseTodoItem . Collection . TodoItems . Count ) ;
93-
94- // TODO: assert number of things in included
87+ var documents = JsonConvert . DeserializeObject < Documents > ( body ) ;
88+ var included = documents . Included ;
89+
90+ Assert . Equal ( 3 , included . Count ) ; // 1 collection, 2 todos
9591 }
9692
9793 [ Fact ]
@@ -124,15 +120,10 @@ public async Task Can_Include_Nested_HasMany_Relationships_BelongsTo()
124120 Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
125121
126122 var body = await response . Content . ReadAsStringAsync ( ) ;
127- var todoItems = _fixture . DeSerializer . DeserializeList < TodoItem > ( body ) ;
128-
129- var responseTodoItem = todoItems [ 0 ] ;
130- Assert . NotNull ( responseTodoItem ) ;
131- Assert . NotNull ( responseTodoItem . Collection ) ;
132- Assert . NotNull ( responseTodoItem . Collection . TodoItems ) ;
133- Assert . Equal ( 2 , responseTodoItem . Collection . TodoItems . Count ) ;
134-
135- // TODO: assert number of things in included
123+ var documents = JsonConvert . DeserializeObject < Documents > ( body ) ;
124+ var included = documents . Included ;
125+
126+ Assert . Equal ( 4 , included . Count ) ; // 1 collection, 2 todos, 1 owner
136127 }
137128 }
138129}
0 commit comments