Skip to content

Commit 65b1f03

Browse files
author
Bart Koelman
committed
Enhanced existing tests: Assert on resource type when included contains mixed types
1 parent 317f293 commit 65b1f03

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Filtering/FilterDepthTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
415415
responseDocument.Data.ManyValue.Should().HaveCount(1);
416416

417417
responseDocument.Included.Should().HaveCount(2);
418+
419+
responseDocument.Included[0].Type.Should().Be("webAccounts");
418420
responseDocument.Included[0].Id.Should().Be(blog.Owner.StringId);
421+
422+
responseDocument.Included[1].Type.Should().Be("blogPosts");
419423
responseDocument.Included[1].Id.Should().Be(blog.Owner.Posts[1].StringId);
420424
}
421425

@@ -530,8 +534,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
530534
responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId);
531535

532536
responseDocument.Included.Should().HaveCount(3);
537+
538+
responseDocument.Included[0].Type.Should().Be("webAccounts");
533539
responseDocument.Included[0].Id.Should().Be(blogs[1].Owner.StringId);
540+
541+
responseDocument.Included[1].Type.Should().Be("blogPosts");
534542
responseDocument.Included[1].Id.Should().Be(blogs[1].Owner.Posts[1].StringId);
543+
544+
responseDocument.Included[2].Type.Should().Be("comments");
535545
responseDocument.Included[2].Id.Should().Be(blogs[1].Owner.Posts[1].Comments.ElementAt(1).StringId);
536546
}
537547
}

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Pagination/PaginationWithTotalCountTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,8 +368,14 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
368368
responseDocument.Data.ManyValue[0].Id.Should().Be(blogs[1].StringId);
369369

370370
responseDocument.Included.Should().HaveCount(3);
371+
372+
responseDocument.Included[0].Type.Should().Be("webAccounts");
371373
responseDocument.Included[0].Id.Should().Be(blogs[1].Owner.StringId);
374+
375+
responseDocument.Included[1].Type.Should().Be("blogPosts");
372376
responseDocument.Included[1].Id.Should().Be(blogs[1].Owner.Posts[1].StringId);
377+
378+
responseDocument.Included[2].Type.Should().Be("comments");
373379
responseDocument.Included[2].Id.Should().Be(blogs[1].Owner.Posts[1].Comments.ElementAt(1).StringId);
374380

375381
string linkPrefix = $"{HostPrefix}/blogs?include=owner.posts.comments";

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/Sorting/SortTests.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -433,10 +433,20 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
433433
responseDocument.Data.ManyValue[1].Id.Should().Be(blogs[0].StringId);
434434

435435
responseDocument.Included.Should().HaveCount(5);
436+
437+
responseDocument.Included[0].Type.Should().Be("webAccounts");
436438
responseDocument.Included[0].Id.Should().Be(blogs[1].Owner.StringId);
439+
440+
responseDocument.Included[1].Type.Should().Be("blogPosts");
437441
responseDocument.Included[1].Id.Should().Be(blogs[1].Owner.Posts[1].StringId);
442+
443+
responseDocument.Included[2].Type.Should().Be("comments");
438444
responseDocument.Included[2].Id.Should().Be(blogs[1].Owner.Posts[1].Comments.ElementAt(1).StringId);
445+
446+
responseDocument.Included[3].Type.Should().Be("comments");
439447
responseDocument.Included[3].Id.Should().Be(blogs[1].Owner.Posts[1].Comments.ElementAt(0).StringId);
448+
449+
responseDocument.Included[4].Type.Should().Be("blogPosts");
440450
responseDocument.Included[4].Id.Should().Be(blogs[1].Owner.Posts[0].StringId);
441451
}
442452

test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SparseFieldSets/SparseFieldSetTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -445,19 +445,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
445445
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
446446

447447
responseDocument.Data.SingleValue.Should().NotBeNull();
448+
responseDocument.Data.SingleValue.Type.Should().Be("blogs");
448449
responseDocument.Data.SingleValue.Id.Should().Be(blog.StringId);
449450
responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1);
450451
responseDocument.Data.SingleValue.Attributes["title"].Should().Be(blog.Title);
451452
responseDocument.Data.SingleValue.Relationships.Should().BeNull();
452453

453454
responseDocument.Included.Should().HaveCount(2);
454455

456+
responseDocument.Included[0].Type.Should().Be("webAccounts");
455457
responseDocument.Included[0].Id.Should().Be(blog.Owner.StringId);
456458
responseDocument.Included[0].Attributes.Should().HaveCount(2);
457459
responseDocument.Included[0].Attributes["userName"].Should().Be(blog.Owner.UserName);
458460
responseDocument.Included[0].Attributes["displayName"].Should().Be(blog.Owner.DisplayName);
459461
responseDocument.Included[0].Relationships.Should().BeNull();
460462

463+
responseDocument.Included[1].Type.Should().Be("blogPosts");
461464
responseDocument.Included[1].Id.Should().Be(blog.Owner.Posts[0].StringId);
462465
responseDocument.Included[1].Attributes.Should().HaveCount(1);
463466
responseDocument.Included[1].Attributes["caption"].Should().Be(blog.Owner.Posts[0].Caption);
@@ -503,6 +506,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
503506
httpResponse.Should().HaveStatusCode(HttpStatusCode.OK);
504507

505508
responseDocument.Data.SingleValue.Should().NotBeNull();
509+
responseDocument.Data.SingleValue.Type.Should().Be("blogs");
506510
responseDocument.Data.SingleValue.Id.Should().Be(blog.StringId);
507511
responseDocument.Data.SingleValue.Attributes.Should().HaveCount(1);
508512
responseDocument.Data.SingleValue.Attributes["title"].Should().Be(blog.Title);
@@ -513,6 +517,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
513517

514518
responseDocument.Included.Should().HaveCount(2);
515519

520+
responseDocument.Included[0].Type.Should().Be("webAccounts");
516521
responseDocument.Included[0].Id.Should().Be(blog.Owner.StringId);
517522
responseDocument.Included[0].Attributes["userName"].Should().Be(blog.Owner.UserName);
518523
responseDocument.Included[0].Attributes["displayName"].Should().Be(blog.Owner.DisplayName);
@@ -522,6 +527,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
522527
responseDocument.Included[0].Relationships["posts"].Links.Self.Should().NotBeNull();
523528
responseDocument.Included[0].Relationships["posts"].Links.Related.Should().NotBeNull();
524529

530+
responseDocument.Included[1].Type.Should().Be("blogPosts");
525531
responseDocument.Included[1].Id.Should().Be(blog.Owner.Posts[0].StringId);
526532
responseDocument.Included[1].Attributes["caption"].Should().Be(blog.Owner.Posts[0].Caption);
527533
responseDocument.Included[1].Attributes["url"].Should().Be(blog.Owner.Posts[0].Url);

0 commit comments

Comments
 (0)