File tree 1 file changed +29
-0
lines changed
test/JsonApiDotNetCoreTests/IntegrationTests/QueryStrings/SparseFieldSets
1 file changed +29
-0
lines changed Original file line number Diff line number Diff line change @@ -727,5 +727,34 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
727
727
postCaptured . Caption . Should ( ) . Be ( post . Caption ) ;
728
728
postCaptured . Url . Should ( ) . Be ( postCaptured . Url ) ;
729
729
}
730
+
731
+ [ Fact ]
732
+ public async Task Returns_related_resources_on_broken_resource_linkage ( )
733
+ {
734
+ // Arrange
735
+ WebAccount account = _fakers . WebAccount . Generate ( ) ;
736
+ account . Posts = _fakers . BlogPost . Generate ( 2 ) ;
737
+
738
+ await _testContext . RunOnDatabaseAsync ( async dbContext =>
739
+ {
740
+ dbContext . Accounts . Add ( account ) ;
741
+ await dbContext . SaveChangesAsync ( ) ;
742
+ } ) ;
743
+
744
+ string route = $ "/webAccounts/{ account . StringId } ?include=posts&fields[webAccounts]=displayName";
745
+
746
+ // Act
747
+ ( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
748
+
749
+ // Assert
750
+ httpResponse . Should ( ) . HaveStatusCode ( HttpStatusCode . OK ) ;
751
+
752
+ responseDocument . Data . SingleValue . Should ( ) . NotBeNull ( ) ;
753
+ responseDocument . Data . SingleValue . Id . Should ( ) . Be ( account . StringId ) ;
754
+ responseDocument . Data . SingleValue . Relationships . Should ( ) . BeNull ( ) ;
755
+
756
+ responseDocument . Included . Should ( ) . HaveCount ( 2 ) ;
757
+ responseDocument . Included . Should ( ) . OnlyContain ( resourceObject => resourceObject . Type == "blogPosts" ) ;
758
+ }
730
759
}
731
760
}
You can’t perform that action at this time.
0 commit comments