Skip to content

Commit e7f0175

Browse files
committed
Get QueueLengthProvider tests working
1 parent d72038a commit e7f0175

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

src/ServiceControl.Transports.Tests/QueueLengthMonitoringTests.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ class QueueLengthMonitoringTests : TransportTestFixture
1010
[Test]
1111
public async Task Should_report_queue_length()
1212
{
13-
var queueName = GetTestQueueName("queuelenght");
13+
var queueName = GetTestQueueName("queuelength");
1414

1515
await CreateTestQueue(queueName);
1616

src/ServiceControl.Transports.Tests/TransportTestFixture.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
using System.Threading;
99
using System.Threading.Tasks;
1010
using Microsoft.Extensions.DependencyInjection;
11+
using NServiceBus;
1112
using NServiceBus.Logging;
1213
using NServiceBus.Transport;
1314
using NUnit.Framework;
@@ -87,21 +88,24 @@ protected async Task<IAsyncDisposable> StartQueueLengthProvider(string queueName
8788
// currently working around by creating a service collection per start call and then disposing the provider
8889
// as part of the method scope. This could lead to potential problems later once we add disposable resources
8990
// but this code probably requires a major overhaul anyway.
90-
var serviceCollection = new ServiceCollection();
91+
9192
var transportSettings = new TransportSettings
9293
{
9394
ConnectionString = configuration.ConnectionString,
9495
EndpointName = queueName,
9596
MaxConcurrency = 1
9697
};
98+
99+
var serviceCollection = new ServiceCollection();
100+
97101
configuration.TransportCustomization.AddTransportForMonitoring(serviceCollection, transportSettings);
98-
serviceCollection.AddSingleton<Action<QueueLengthEntry[], EndpointToQueueMapping>>((qlt, _) =>
99-
onQueueLengthReported(qlt.First()));
102+
configuration.TransportCustomization.CustomizeMonitoringEndpoint(new EndpointConfiguration("queueName"), transportSettings);
103+
104+
serviceCollection.AddSingleton<Action<QueueLengthEntry[], EndpointToQueueMapping>>((qlt, _) => onQueueLengthReported(qlt.First()));
100105
var serviceProvider = serviceCollection.BuildServiceProvider();
101-
queueLengthProvider = serviceProvider.GetRequiredService<IProvideQueueLength>();
102106

107+
queueLengthProvider = serviceProvider.GetRequiredService<IProvideQueueLength>();
103108
await queueLengthProvider.StartAsync(CancellationToken.None);
104-
105109
queueLengthProvider.TrackEndpointInputQueue(new EndpointToQueueMapping(queueName, queueName));
106110

107111
return new QueueLengthProviderScope(serviceProvider);

0 commit comments

Comments
 (0)