@@ -124,7 +124,56 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
124
124
125
125
hitCounter . HitExtensibilityPoints . Should ( ) . BeEquivalentTo ( new [ ]
126
126
{
127
- ( typeof ( Moon ) , ResourceDefinitionHitCounter . ExtensibilityPoint . OnApplyIncludes )
127
+ ( typeof ( Moon ) , ResourceDefinitionHitCounter . ExtensibilityPoint . OnApplyIncludes ) ,
128
+ ( typeof ( Planet ) , ResourceDefinitionHitCounter . ExtensibilityPoint . OnApplyIncludes )
129
+ } , options => options . WithStrictOrdering ( ) ) ;
130
+ }
131
+
132
+ [ Fact ]
133
+ public async Task Include_from_included_resource_definition_is_added ( )
134
+ {
135
+ // Arrange
136
+ var hitCounter = _testContext . Factory . Services . GetRequiredService < ResourceDefinitionHitCounter > ( ) ;
137
+
138
+ var settingsProvider = ( TestClientSettingsProvider ) _testContext . Factory . Services . GetRequiredService < IClientSettingsProvider > ( ) ;
139
+ settingsProvider . AutoIncludeOrbitingPlanetForMoons ( ) ;
140
+
141
+ Planet planet = _fakers . Planet . Generate ( ) ;
142
+ planet . Moons = _fakers . Moon . Generate ( 1 ) . ToHashSet ( ) ;
143
+ planet . Moons . ElementAt ( 0 ) . OrbitsAround = _fakers . Planet . Generate ( ) ;
144
+
145
+ await _testContext . RunOnDatabaseAsync ( async dbContext =>
146
+ {
147
+ dbContext . Planets . Add ( planet ) ;
148
+ await dbContext . SaveChangesAsync ( ) ;
149
+ } ) ;
150
+
151
+ string route = $ "/planets/{ planet . StringId } ?include=moons";
152
+
153
+ // Act
154
+ ( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
155
+
156
+ // Assert
157
+ httpResponse . Should ( ) . HaveStatusCode ( HttpStatusCode . OK ) ;
158
+
159
+ responseDocument . Data . SingleValue . Should ( ) . NotBeNull ( ) ;
160
+
161
+ responseDocument . Included . Should ( ) . HaveCount ( 2 ) ;
162
+
163
+ responseDocument . Included [ 0 ] . Type . Should ( ) . Be ( "moons" ) ;
164
+ responseDocument . Included [ 0 ] . Id . Should ( ) . Be ( planet . Moons . ElementAt ( 0 ) . StringId ) ;
165
+ responseDocument . Included [ 0 ] . Attributes [ "name" ] . Should ( ) . Be ( planet . Moons . ElementAt ( 0 ) . Name ) ;
166
+
167
+ responseDocument . Included [ 1 ] . Type . Should ( ) . Be ( "planets" ) ;
168
+ responseDocument . Included [ 1 ] . Id . Should ( ) . Be ( planet . Moons . ElementAt ( 0 ) . OrbitsAround . StringId ) ;
169
+ responseDocument . Included [ 1 ] . Attributes [ "publicName" ] . Should ( ) . Be ( planet . Moons . ElementAt ( 0 ) . OrbitsAround . PublicName ) ;
170
+
171
+ hitCounter . HitExtensibilityPoints . Should ( ) . BeEquivalentTo ( new [ ]
172
+ {
173
+ ( typeof ( Planet ) , ResourceDefinitionHitCounter . ExtensibilityPoint . OnApplyFilter ) ,
174
+ ( typeof ( Planet ) , ResourceDefinitionHitCounter . ExtensibilityPoint . OnApplyIncludes ) ,
175
+ ( typeof ( Moon ) , ResourceDefinitionHitCounter . ExtensibilityPoint . OnApplyIncludes ) ,
176
+ ( typeof ( Planet ) , ResourceDefinitionHitCounter . ExtensibilityPoint . OnApplyIncludes )
128
177
} , options => options . WithStrictOrdering ( ) ) ;
129
178
}
130
179
0 commit comments