11namespace Particular . LicensingComponent . UnitTests ;
22
3+ using System ;
34using System . Linq ;
5+ using System . Threading ;
46using System . Threading . Tasks ;
57using NUnit . Framework ;
68using Particular . LicensingComponent . Contracts ;
@@ -81,7 +83,7 @@ await DataStore.CreateBuilder()
8183 [ TestCase ( ThroughputSource . Audit ) ]
8284 [ TestCase ( ThroughputSource . Broker ) ]
8385 [ TestCase ( ThroughputSource . Monitoring ) ]
84- public async Task Should_return_correct_max_throughput_in_summary_when_data_only_from_one_source ( ThroughputSource source )
86+ public async Task Should_return_correct_max_daily_throughput_in_summary_when_data_only_from_one_source ( ThroughputSource source )
8587 {
8688 // Arrange
8789 await DataStore . CreateBuilder ( )
@@ -106,7 +108,7 @@ await DataStore.CreateBuilder()
106108 }
107109
108110 [ Test ]
109- public async Task Should_return_correct_max_throughput_in_summary_when_multiple_sources ( )
111+ public async Task Should_return_correct_max_daily_throughput_in_summary_when_multiple_sources ( )
110112 {
111113 // Arrange
112114 await DataStore . CreateBuilder ( )
@@ -138,7 +140,44 @@ await DataStore.CreateBuilder()
138140 }
139141
140142 [ Test ]
141- public async Task Should_return_correct_max_throughput_in_summary_when_endpoint_has_no_throughput ( )
143+ public async Task Should_return_correct_max_monthly_throughput_in_summary_when_multiple_sources ( )
144+ {
145+ // Arrange
146+ await DataStore . CreateBuilder ( )
147+ . AddEndpoint ( "Endpoint1" , sources : [ ThroughputSource . Broker ] )
148+ . WithThroughput ( new ThroughputData ( [
149+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 1 , 10 ) , 50 ) ,
150+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 1 , 15 ) , 50 ) ,
151+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 1 , 16 ) , 150 ) ,
152+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 2 , 20 ) , 160 ) ,
153+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 3 , 25 ) , 65 ) ,
154+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 4 , 30 ) , 70 ) ,
155+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 5 , 1 ) , 75 ) ] ) )
156+ . AddEndpoint ( "Endpoint2" , sources : [ ThroughputSource . Broker ] )
157+ . WithThroughput ( new ThroughputData ( [
158+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 1 , 10 ) , 60 ) ,
159+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 1 , 15 ) , 65 ) ,
160+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 5 , 20 ) , 165 ) ,
161+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 3 , 25 ) , 65 ) ,
162+ new EndpointDailyThroughput ( new DateOnly ( 2025 , 9 , 30 ) , 70 ) ] ) )
163+ . Build ( ) ;
164+
165+ // Act
166+ var summary = await ThroughputCollector . GetThroughputSummary ( CancellationToken . None ) ;
167+
168+ // Assert
169+ Assert . That ( summary , Is . Not . Null ) ;
170+ Assert . That ( summary , Has . Count . EqualTo ( 2 ) ) ;
171+
172+ Assert . Multiple ( ( ) =>
173+ {
174+ Assert . That ( summary . First ( w => w . Name == "Endpoint1" ) . MaxMonthlyThroughput , Is . EqualTo ( 250 ) , $ "Incorrect MaxDailyThroughput recorded for Endpoint1") ;
175+ Assert . That ( summary . First ( w => w . Name == "Endpoint2" ) . MaxMonthlyThroughput , Is . EqualTo ( 165 ) , $ "Incorrect MaxDailyThroughput recorded for Endpoint2") ;
176+ } ) ;
177+ }
178+
179+ [ Test ]
180+ public async Task Should_return_correct_max_daily_throughput_in_summary_when_endpoint_has_no_throughput ( )
142181 {
143182 // Arrange
144183 await DataStore . CreateBuilder ( ) . AddEndpoint ( ) . Build ( ) ;
@@ -153,7 +192,7 @@ public async Task Should_return_correct_max_throughput_in_summary_when_endpoint_
153192 }
154193
155194 [ Test ]
156- public async Task Should_return_correct_max_throughput_in_summary_when_data_from_multiple_sources_and_name_is_different ( )
195+ public async Task Should_return_correct_max_daily_throughput_in_summary_when_data_from_multiple_sources_and_name_is_different ( )
157196 {
158197 // Arrange
159198 await DataStore . CreateBuilder ( )
0 commit comments