@@ -32,19 +32,21 @@ public TopLevelCountTests(IntegrationTestContext<TestableStartup<MetaDbContext>,
32
32
}
33
33
34
34
[ Fact ]
35
- public async Task Renders_resource_count_for_collection ( )
35
+ public async Task Renders_resource_count_for_primary_resources_endpoint_with_filter ( )
36
36
{
37
37
// Arrange
38
- SupportTicket ticket = _fakers . SupportTicket . Generate ( ) ;
38
+ List < SupportTicket > tickets = _fakers . SupportTicket . Generate ( 2 ) ;
39
+
40
+ tickets [ 1 ] . Description = "Update firmware version" ;
39
41
40
42
await _testContext . RunOnDatabaseAsync ( async dbContext =>
41
43
{
42
44
await dbContext . ClearTableAsync < SupportTicket > ( ) ;
43
- dbContext . SupportTickets . Add ( ticket ) ;
45
+ dbContext . SupportTickets . AddRange ( tickets ) ;
44
46
await dbContext . SaveChangesAsync ( ) ;
45
47
} ) ;
46
48
47
- const string route = "/supportTickets" ;
49
+ const string route = "/supportTickets?filter=startsWith(description,'Update ') " ;
48
50
49
51
// Act
50
52
( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
@@ -61,6 +63,36 @@ await _testContext.RunOnDatabaseAsync(async dbContext =>
61
63
} ) ;
62
64
}
63
65
66
+ [ Fact ]
67
+ public async Task Renders_resource_count_for_secondary_resources_endpoint_with_filter ( )
68
+ {
69
+ // Arrange
70
+ ProductFamily family = _fakers . ProductFamily . Generate ( ) ;
71
+ family . Tickets = _fakers . SupportTicket . Generate ( 2 ) ;
72
+
73
+ family . Tickets [ 1 ] . Description = "Update firmware version" ;
74
+
75
+ await _testContext . RunOnDatabaseAsync ( async dbContext =>
76
+ {
77
+ dbContext . ProductFamilies . Add ( family ) ;
78
+ await dbContext . SaveChangesAsync ( ) ;
79
+ } ) ;
80
+
81
+ string route = $ "/productFamilies/{ family . StringId } /tickets?filter=contains(description,'firmware')";
82
+
83
+ // Act
84
+ ( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
85
+
86
+ // Assert
87
+ httpResponse . ShouldHaveStatusCode ( HttpStatusCode . OK ) ;
88
+
89
+ responseDocument . Meta . ShouldContainKey ( "total" ) . With ( value =>
90
+ {
91
+ JsonElement element = value . Should ( ) . BeOfType < JsonElement > ( ) . Subject ;
92
+ element . GetInt32 ( ) . Should ( ) . Be ( 1 ) ;
93
+ } ) ;
94
+ }
95
+
64
96
[ Fact ]
65
97
public async Task Renders_resource_count_for_empty_collection ( )
66
98
{
0 commit comments