@@ -32,19 +32,51 @@ public TopLevelCountTests(IntegrationTestContext<TestableStartup<MetaDbContext>,
3232 }
3333
3434 [ Fact ]
35- public async Task Renders_resource_count_for_collection ( )
35+ public async Task Renders_resource_count_for_primary_resources_endpoint_with_filter ( )
3636 {
3737 // Arrange
38- SupportTicket ticket = _fakers . SupportTicket . Generate ( ) ;
38+ List < SupportTicket > tickets = _fakers . SupportTicket . Generate ( 2 ) ;
39+
40+ tickets [ 1 ] . Description = "Update firmware version" ;
3941
4042 await _testContext . RunOnDatabaseAsync ( async dbContext =>
4143 {
4244 await dbContext . ClearTableAsync < SupportTicket > ( ) ;
43- dbContext . SupportTickets . Add ( ticket ) ;
45+ dbContext . SupportTickets . AddRange ( tickets ) ;
4446 await dbContext . SaveChangesAsync ( ) ;
4547 } ) ;
4648
47- const string route = "/supportTickets" ;
49+ const string route = "/supportTickets?filter=startsWith(description,'Update ')" ;
50+
51+ // Act
52+ ( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
53+
54+ // Assert
55+ httpResponse . ShouldHaveStatusCode ( HttpStatusCode . OK ) ;
56+
57+ responseDocument . Meta . ShouldContainKey ( "total" ) . With ( value =>
58+ {
59+ JsonElement element = value . Should ( ) . BeOfType < JsonElement > ( ) . Subject ;
60+ element . GetInt32 ( ) . Should ( ) . Be ( 1 ) ;
61+ } ) ;
62+ }
63+
64+ [ Fact ]
65+ public async Task Renders_resource_count_for_secondary_resources_endpoint_with_filter ( )
66+ {
67+ // Arrange
68+ ProductFamily family = _fakers . ProductFamily . Generate ( ) ;
69+ family . Tickets = _fakers . SupportTicket . Generate ( 2 ) ;
70+
71+ family . Tickets [ 1 ] . Description = "Update firmware version" ;
72+
73+ await _testContext . RunOnDatabaseAsync ( async dbContext =>
74+ {
75+ dbContext . ProductFamilies . Add ( family ) ;
76+ await dbContext . SaveChangesAsync ( ) ;
77+ } ) ;
78+
79+ string route = $ "/productFamilies/{ family . StringId } /tickets?filter=contains(description,'firmware')";
4880
4981 // Act
5082 ( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
0 commit comments