@@ -32,19 +32,51 @@ 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 ')" ;
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')";
48
80
49
81
// Act
50
82
( HttpResponseMessage httpResponse , Document responseDocument ) = await _testContext . ExecuteGetAsync < Document > ( route ) ;
0 commit comments