Skip to content

Commit 4af95d1

Browse files
committed
assert included counts
1 parent bea642d commit 4af95d1

File tree

1 file changed

+9
-18
lines changed

1 file changed

+9
-18
lines changed

test/JsonApiDotNetCoreExampleTests/Acceptance/Spec/DeeplyNestedInclusionTests.cs

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
using System.Net.Http;
44
using System.Threading.Tasks;
55
using Bogus;
6+
using JsonApiDotNetCore.Models;
67
using JsonApiDotNetCoreExample;
78
using JsonApiDotNetCoreExample.Data;
89
using 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

Comments
 (0)