@@ -15,7 +15,6 @@ class ThroughputCollector_Report_Throughput_Tests : ThroughputCollectorTestFixtu
1515{
1616 public override Task Setup ( )
1717 {
18-
1918 SetExtraDependencies = d => { } ;
2019 return base . Setup ( ) ;
2120 }
@@ -159,15 +158,15 @@ public async Task Should_return_correct_throughput_in_report_when_multiple_sourc
159158 // Arrange
160159 await DataStore . CreateBuilder ( )
161160 . AddEndpoint ( "Endpoint1" , sources : [ ThroughputSource . Broker , ThroughputSource . Monitoring ] )
162- . WithThroughput ( ThroughputSource . Broker , data : [ 50 , 55 ] )
163- . WithThroughput ( ThroughputSource . Monitoring , data : [ 60 , 65 ] )
161+ . WithThroughput ( ThroughputSource . Broker , data : [ 50 , 55 ] )
162+ . WithThroughput ( ThroughputSource . Monitoring , data : [ 60 , 65 ] )
164163 . AddEndpoint ( "Endpoint2" , sources : [ ThroughputSource . Broker , ThroughputSource . Audit ] )
165- . WithThroughput ( ThroughputSource . Broker , data : [ 60 , 65 ] )
166- . WithThroughput ( ThroughputSource . Audit , data : [ 61 , 64 ] )
164+ . WithThroughput ( ThroughputSource . Broker , data : [ 60 , 65 ] )
165+ . WithThroughput ( ThroughputSource . Audit , data : [ 61 , 64 ] )
167166 . AddEndpoint ( "Endpoint3" , sources : [ ThroughputSource . Broker , ThroughputSource . Monitoring , ThroughputSource . Audit ] )
168- . WithThroughput ( ThroughputSource . Broker , data : [ 50 , 57 ] )
169- . WithThroughput ( ThroughputSource . Monitoring , data : [ 40 , 45 ] )
170- . WithThroughput ( ThroughputSource . Audit , data : [ 42 , 47 ] )
167+ . WithThroughput ( ThroughputSource . Broker , data : [ 50 , 57 ] )
168+ . WithThroughput ( ThroughputSource . Monitoring , data : [ 40 , 45 ] )
169+ . WithThroughput ( ThroughputSource . Audit , data : [ 42 , 47 ] )
171170 . Build ( ) ;
172171
173172 // Act
@@ -218,10 +217,10 @@ public async Task Should_return_correct_throughput_in_report_when_data_from_mult
218217 // Arrange
219218 await DataStore . CreateBuilder ( )
220219 . AddEndpoint ( "Endpoint1" , sources : [ ThroughputSource . Broker ] )
221- . WithThroughput ( data : [ 50 , 75 ] )
220+ . WithThroughput ( data : [ 50 , 75 ] )
222221 . AddEndpoint ( "Endpoint1_" , sources : [ ThroughputSource . Audit ] )
223222 . ConfigureEndpoint ( endpoint => endpoint . SanitizedName = "Endpoint1" )
224- . WithThroughput ( data : [ 60 , 65 ] )
223+ . WithThroughput ( data : [ 60 , 65 ] )
225224 . Build ( ) ;
226225
227226 // Act
@@ -244,27 +243,55 @@ await DataStore.CreateBuilder()
244243 } ) ;
245244 }
246245
246+ [ TestCase ( ThroughputSource . Audit ) ]
247+ [ TestCase ( ThroughputSource . Broker ) ]
248+ [ TestCase ( ThroughputSource . Monitoring ) ]
249+ public async Task Should_return_correct_throughput_in_report_when_data_from_multiple_sources_of_same_type_exist ( ThroughputSource source )
250+ {
251+ // Arrange
252+ await DataStore . CreateBuilder ( )
253+ . AddEndpoint ( "Endpoint1" , sources : [ source ] )
254+ . WithThroughput ( data : [ 50 , 75 ] )
255+ . AddEndpoint ( "Endpoint1_" , sources : [ source ] )
256+ . ConfigureEndpoint ( endpoint => endpoint . SanitizedName = "Endpoint1" )
257+ . WithThroughput ( data : [ 60 , 65 ] )
258+ . Build ( ) ;
259+
260+ // Act
261+ var report = await ThroughputCollector . GenerateThroughputReport ( "" , null , default ) ;
262+
263+ // Assert
264+ Assert . That ( report , Is . Not . Null ) ;
265+ Assert . That ( report . ReportData . Queues . Count , Is . EqualTo ( 1 ) ) ;
266+
267+ Assert . Multiple ( ( ) =>
268+ {
269+ Assert . That ( report . ReportData . TotalThroughput , Is . EqualTo ( 75 ) , $ "Incorrect TotalThroughput recorded") ;
270+ Assert . That ( report . ReportData . TotalQueues , Is . EqualTo ( 1 ) , $ "Incorrect TotalQueues recorded") ;
271+ } ) ;
272+ }
273+
247274 [ Test ]
248275 public async Task Should_generate_correct_report ( )
249276 {
250277 // Arrange
251278 await DataStore . CreateBuilder ( )
252279 . AddEndpoint ( "Endpoint1" , sources : [ ThroughputSource . Broker , ThroughputSource . Monitoring ] )
253- . WithThroughput ( ThroughputSource . Broker , data : [ 50 , 55 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
254- . WithThroughput ( ThroughputSource . Monitoring , data : [ 60 , 65 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
255- . ConfigureEndpoint ( endpoint => endpoint . EndpointIndicators = [ EndpointIndicator . KnownEndpoint . ToString ( ) ] )
280+ . WithThroughput ( ThroughputSource . Broker , data : [ 50 , 55 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
281+ . WithThroughput ( ThroughputSource . Monitoring , data : [ 60 , 65 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
282+ . ConfigureEndpoint ( endpoint => endpoint . EndpointIndicators = [ EndpointIndicator . KnownEndpoint . ToString ( ) ] )
256283 . AddEndpoint ( "Endpoint2" , sources : [ ThroughputSource . Broker , ThroughputSource . Audit ] )
257- . WithThroughput ( ThroughputSource . Broker , data : [ 60 , 65 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
258- . WithThroughput ( ThroughputSource . Audit , data : [ 61 , 64 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
259- . ConfigureEndpoint ( endpoint => endpoint . EndpointIndicators = [ EndpointIndicator . KnownEndpoint . ToString ( ) ] )
284+ . WithThroughput ( ThroughputSource . Broker , data : [ 60 , 65 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
285+ . WithThroughput ( ThroughputSource . Audit , data : [ 61 , 64 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
286+ . ConfigureEndpoint ( endpoint => endpoint . EndpointIndicators = [ EndpointIndicator . KnownEndpoint . ToString ( ) ] )
260287 . AddEndpoint ( "Endpoint3" , sources : [ ThroughputSource . Broker , ThroughputSource . Monitoring , ThroughputSource . Audit ] )
261- . WithThroughput ( ThroughputSource . Broker , data : [ 50 , 57 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
262- . WithThroughput ( ThroughputSource . Monitoring , data : [ 40 , 45 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
263- . WithThroughput ( ThroughputSource . Audit , data : [ 42 , 47 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
264- . ConfigureEndpoint ( endpoint => endpoint . EndpointIndicators = [ EndpointIndicator . KnownEndpoint . ToString ( ) ] )
288+ . WithThroughput ( ThroughputSource . Broker , data : [ 50 , 57 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
289+ . WithThroughput ( ThroughputSource . Monitoring , data : [ 40 , 45 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
290+ . WithThroughput ( ThroughputSource . Audit , data : [ 42 , 47 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
291+ . ConfigureEndpoint ( endpoint => endpoint . EndpointIndicators = [ EndpointIndicator . KnownEndpoint . ToString ( ) ] )
265292 . AddEndpoint ( "Endpoint4" , sources : [ ThroughputSource . Broker ] )
266- . ConfigureEndpoint ( endpoint => endpoint . UserIndicator = UserIndicator . PlannedToDecommission . ToString ( ) )
267- . WithThroughput ( ThroughputSource . Broker , data : [ 42 , 47 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
293+ . ConfigureEndpoint ( endpoint => endpoint . UserIndicator = UserIndicator . PlannedToDecommission . ToString ( ) )
294+ . WithThroughput ( ThroughputSource . Broker , data : [ 42 , 47 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
268295 . AddEndpoint ( "Endpoint5" , sources : [ ThroughputSource . Broker ] )
269296 . ConfigureEndpoint ( endpoint => endpoint . UserIndicator = UserIndicator . NotNServiceBusEndpoint . ToString ( ) )
270297 . WithThroughput ( ThroughputSource . Broker , data : [ 15 , 4 ] , startDate : DateOnly . FromDateTime ( new DateTime ( 2024 , 4 , 24 ) ) )
0 commit comments