@@ -202,6 +202,31 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
202
202
responseDocument . Should ( ) . NotContain ( toBeExcluded ) ;
203
203
}
204
204
205
+ [ Fact ]
206
+ public async Task Can_hide_secondary_resource_from_ToOne_relationship_using_OnReturn_hook ( )
207
+ {
208
+ // Arrange
209
+ var person = _fakers . Person . Generate ( ) ;
210
+ person . Passport = new Passport { IsLocked = true } ;
211
+
212
+ await _testContext . RunOnDatabaseAsync ( async dbContext =>
213
+ {
214
+ dbContext . People . Add ( person ) ;
215
+ await dbContext . SaveChangesAsync ( ) ;
216
+ } ) ;
217
+
218
+ var route = $ "/api/v1/people/{ person . Id } /passport";
219
+
220
+ // Act
221
+ var ( httpResponse , responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
222
+
223
+ // Assert
224
+ httpResponse . Should ( ) . HaveStatusCode ( HttpStatusCode . OK ) ;
225
+
226
+ responseDocument . Data . Should ( ) . BeNull ( ) ;
227
+ }
228
+
229
+
205
230
[ Fact ]
206
231
public async Task Can_hide_secondary_resource_from_ToMany_List_relationship_using_OnReturn_hook ( )
207
232
{
@@ -233,24 +258,27 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
233
258
public async Task Can_hide_secondary_resource_from_ToMany_Set_relationship_using_OnReturn_hook ( )
234
259
{
235
260
// Arrange
261
+ string toBeExcluded = "This should not be included" ;
262
+
236
263
var person = _fakers . Person . Generate ( ) ;
237
- person . Passport = new Passport { IsLocked = true } ;
264
+ person . TodoItems = _fakers . TodoItem . Generate ( 3 ) . ToHashSet ( ) ;
265
+ person . TodoItems . First ( ) . Description = toBeExcluded ;
238
266
239
267
await _testContext . RunOnDatabaseAsync ( async dbContext =>
240
268
{
241
269
dbContext . People . Add ( person ) ;
242
270
await dbContext . SaveChangesAsync ( ) ;
243
271
} ) ;
244
272
245
- var route = $ "/api/v1/people/{ person . Id } /passport ";
273
+ var route = $ "/api/v1/people/{ person . Id } /todoItems ";
246
274
247
275
// Act
248
- var ( httpResponse , responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
276
+ var ( httpResponse , responseDocument ) = await _testContext . ExecuteGetAsync < string > ( route ) ;
249
277
250
278
// Assert
251
279
httpResponse . Should ( ) . HaveStatusCode ( HttpStatusCode . OK ) ;
252
280
253
- responseDocument . Data . Should ( ) . BeNull ( ) ;
281
+ responseDocument . Should ( ) . NotContain ( toBeExcluded ) ;
254
282
}
255
283
256
284
[ Fact ]
0 commit comments