3
3
using System . Net . Http ;
4
4
using System . Threading . Tasks ;
5
5
using Bogus ;
6
+ using JsonApiDotNetCore . Models ;
6
7
using JsonApiDotNetCoreExample ;
7
8
using JsonApiDotNetCoreExample . Data ;
8
9
using JsonApiDotNetCoreExample . Models ;
@@ -83,15 +84,10 @@ public async Task Can_Include_Nested_HasMany_Relationships()
83
84
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
84
85
85
86
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
95
91
}
96
92
97
93
[ Fact ]
@@ -124,15 +120,10 @@ public async Task Can_Include_Nested_HasMany_Relationships_BelongsTo()
124
120
Assert . Equal ( HttpStatusCode . OK , response . StatusCode ) ;
125
121
126
122
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
136
127
}
137
128
}
138
129
}
0 commit comments