diff --git a/.editorconfig b/.editorconfig index e446d1bb..2a559ae3 100644 --- a/.editorconfig +++ b/.editorconfig @@ -13,6 +13,7 @@ indent_size = 4 [*.cs] indent_size = 4 csharp_style_namespace_declarations = file_scoped:warning +csharp_prefer_braces = true:warning [*.json] indent_size = 2 diff --git a/src/Motor.Extensions.Conversion.JsonNet/JsonNetDeserializer.cs b/src/Motor.Extensions.Conversion.JsonNet/JsonNetDeserializer.cs index 3198f1b9..b1c52535 100644 --- a/src/Motor.Extensions.Conversion.JsonNet/JsonNetDeserializer.cs +++ b/src/Motor.Extensions.Conversion.JsonNet/JsonNetDeserializer.cs @@ -10,7 +10,9 @@ public class JsonNetDeserializer : IMessageDeserializer where T : notnull public T Deserialize(byte[] message) { if (message == null || message.Length == 0) + { throw new ArgumentNullException(nameof(message)); + } var json = Encoding.UTF8.GetString(message); try diff --git a/src/Motor.Extensions.Conversion.JsonNet/JsonNetSerializer.cs b/src/Motor.Extensions.Conversion.JsonNet/JsonNetSerializer.cs index ff963539..dff12198 100644 --- a/src/Motor.Extensions.Conversion.JsonNet/JsonNetSerializer.cs +++ b/src/Motor.Extensions.Conversion.JsonNet/JsonNetSerializer.cs @@ -10,7 +10,9 @@ public class JsonNetSerializer : IMessageSerializer where T : notnull public byte[] Serialize(T message) { if (Equals(message, default(T))) + { throw new ArgumentNullException(nameof(message)); + } return Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(message)); } diff --git a/src/Motor.Extensions.Conversion.Protobuf/ProtobufDeserializer.cs b/src/Motor.Extensions.Conversion.Protobuf/ProtobufDeserializer.cs index 56a08363..d7cd5199 100644 --- a/src/Motor.Extensions.Conversion.Protobuf/ProtobufDeserializer.cs +++ b/src/Motor.Extensions.Conversion.Protobuf/ProtobufDeserializer.cs @@ -10,7 +10,10 @@ namespace Motor.Extensions.Conversion.Protobuf; public T Deserialize(byte[] inMessage) { - if (inMessage == null || inMessage.Length == 0) throw new ArgumentNullException(nameof(inMessage)); + if (inMessage == null || inMessage.Length == 0) + { + throw new ArgumentNullException(nameof(inMessage)); + } T deserializedMsg; try diff --git a/src/Motor.Extensions.Conversion.SystemJson/SystemJsonDeserializer.cs b/src/Motor.Extensions.Conversion.SystemJson/SystemJsonDeserializer.cs index cf5fc1d4..b177cdef 100644 --- a/src/Motor.Extensions.Conversion.SystemJson/SystemJsonDeserializer.cs +++ b/src/Motor.Extensions.Conversion.SystemJson/SystemJsonDeserializer.cs @@ -9,7 +9,10 @@ public class SystemJsonDeserializer : IMessageDeserializer where T : notnu public T Deserialize(byte[] message) { if (message == null || message.Length == 0) + { throw new ArgumentNullException(nameof(message)); + } + try { return JsonSerializer.Deserialize(message) ?? throw new ArgumentNullException(nameof(message)); diff --git a/src/Motor.Extensions.Conversion.SystemJson/SystemJsonSerializer.cs b/src/Motor.Extensions.Conversion.SystemJson/SystemJsonSerializer.cs index 7cd793f8..5f903493 100644 --- a/src/Motor.Extensions.Conversion.SystemJson/SystemJsonSerializer.cs +++ b/src/Motor.Extensions.Conversion.SystemJson/SystemJsonSerializer.cs @@ -9,7 +9,9 @@ public class SystemJsonSerializer : IMessageSerializer where T : notnull public byte[] Serialize(T message) { if (Equals(message, default(T))) + { throw new ArgumentNullException(nameof(message)); + } return JsonSerializer.SerializeToUtf8Bytes(message); } diff --git a/src/Motor.Extensions.Diagnostics.Telemetry/TelemetryDelegatingMessageHandler.cs b/src/Motor.Extensions.Diagnostics.Telemetry/TelemetryDelegatingMessageHandler.cs index 924477de..44021b56 100644 --- a/src/Motor.Extensions.Diagnostics.Telemetry/TelemetryDelegatingMessageHandler.cs +++ b/src/Motor.Extensions.Diagnostics.Telemetry/TelemetryDelegatingMessageHandler.cs @@ -27,7 +27,10 @@ public override async Task HandleMessageAsync(MotorCloud { var parentContext = dataCloudEvent.GetActivityContext(); using var activity = OpenTelemetryOptions.ActivitySource.StartActivity(nameof(HandleMessageAsync), ActivityKind.Server, parentContext); - if (activity is null) return await base.HandleMessageAsync(dataCloudEvent, token); + if (activity is null) + { + return await base.HandleMessageAsync(dataCloudEvent, token); + } using (activity.Start()) using (_logger.BeginScope("TraceId: {traceid}, SpanId: {spanid}", diff --git a/src/Motor.Extensions.Hosting.Abstractions/IMessageConsumer.cs b/src/Motor.Extensions.Hosting.Abstractions/IMessageConsumer.cs index afb71625..7bd08c9e 100644 --- a/src/Motor.Extensions.Hosting.Abstractions/IMessageConsumer.cs +++ b/src/Motor.Extensions.Hosting.Abstractions/IMessageConsumer.cs @@ -17,7 +17,10 @@ public interface IMessageConsumer where TInput : notnull async Task ExecuteAsync(CancellationToken token = default) { - while (!token.IsCancellationRequested) await Task.Delay(TimeSpan.FromSeconds(100), token).ConfigureAwait(false); + while (!token.IsCancellationRequested) + { + await Task.Delay(TimeSpan.FromSeconds(100), token).ConfigureAwait(false); + } } Task StopAsync(CancellationToken token = default); diff --git a/src/Motor.Extensions.Hosting.CloudEvents/MotorCloudEvent.cs b/src/Motor.Extensions.Hosting.CloudEvents/MotorCloudEvent.cs index 7c67cd15..7e368cc1 100644 --- a/src/Motor.Extensions.Hosting.CloudEvents/MotorCloudEvent.cs +++ b/src/Motor.Extensions.Hosting.CloudEvents/MotorCloudEvent.cs @@ -50,7 +50,11 @@ public MotorCloudEvent( params KeyValuePair[] extensions) { BaseEvent = new CloudEvent(CloudEventsSpecVersion.Default); - foreach (var (key, value) in extensions) BaseEvent[key] = value; + foreach (var (key, value) in extensions) + { + BaseEvent[key] = value; + } + BaseEvent.Id = id ?? Guid.NewGuid().ToString(); BaseEvent.Type = type ?? typeof(TData).Name; BaseEvent.Source = source; diff --git a/src/Motor.Extensions.Hosting.Kafka/KafkaMessageConsumer.cs b/src/Motor.Extensions.Hosting.Kafka/KafkaMessageConsumer.cs index 6585c6ef..e84bb6e7 100644 --- a/src/Motor.Extensions.Hosting.Kafka/KafkaMessageConsumer.cs +++ b/src/Motor.Extensions.Hosting.Kafka/KafkaMessageConsumer.cs @@ -50,7 +50,10 @@ public Func, CancellationToken, Task(_options) .SetLogHandler((_, logMessage) => WriteLog(logMessage)) @@ -66,13 +69,18 @@ public async Task ExecuteAsync(CancellationToken token = default) await Task.Run(() => { while (!token.IsCancellationRequested) + { try { var msg = _consumer?.Consume(token); if (msg != null && !msg.IsPartitionEOF) + { SingleMessageHandling(token, msg); + } else + { _logger.LogDebug("No messages received"); + } } catch (OperationCanceledException) { @@ -83,6 +91,7 @@ await Task.Run(() => { _logger.LogError(e, "Failed to receive message.", e); } + } }, token).ConfigureAwait(false); } @@ -132,11 +141,18 @@ private void WriteStatistics(string json) .Select(t => t.Value) .SelectMany(t => t.Partitions ?? new Dictionary()) .Select(t => (Parition: t.Key.ToString(), t.Value.ConsumerLag)); - if (partitionConsumerLags is null) return; + if (partitionConsumerLags is null) + { + return; + } + foreach (var (partition, consumerLag) in partitionConsumerLags) { var lag = consumerLag; - if (lag == -1) lag = 0; + if (lag == -1) + { + lag = 0; + } _consumerLagSummary?.WithLabels(_options.Topic, partition)?.Observe(lag); _consumerLagGauge?.WithLabels(_options.Topic, partition)?.Set(lag); @@ -167,7 +183,10 @@ private void SingleMessageHandling(CancellationToken token, ConsumeResult KafkaMessageToCloudEvent(Message private void Dispose(bool disposing) { - if (disposing) _consumer?.Dispose(); + if (disposing) + { + _consumer?.Dispose(); + } } public void Dispose() diff --git a/src/Motor.Extensions.Hosting.RabbitMQ/BasicPropertiesExtensions.cs b/src/Motor.Extensions.Hosting.RabbitMQ/BasicPropertiesExtensions.cs index 50a34a93..25f02438 100644 --- a/src/Motor.Extensions.Hosting.RabbitMQ/BasicPropertiesExtensions.cs +++ b/src/Motor.Extensions.Hosting.RabbitMQ/BasicPropertiesExtensions.cs @@ -32,8 +32,9 @@ public static void SetPriority(this IBasicProperties self, MotorCloudEvent cloudEvent) { diff --git a/src/Motor.Extensions.Hosting.RabbitMQ/RabbitMQMessageConsumer.cs b/src/Motor.Extensions.Hosting.RabbitMQ/RabbitMQMessageConsumer.cs index 1b2072a6..6456f342 100644 --- a/src/Motor.Extensions.Hosting.RabbitMQ/RabbitMQMessageConsumer.cs +++ b/src/Motor.Extensions.Hosting.RabbitMQ/RabbitMQMessageConsumer.cs @@ -47,7 +47,10 @@ public Func, CancellationToken, Task t.Key, t => t.Value); - if (_options.Queue.MaxPriority is not null) arguments.Add("x-max-priority", _options.Queue.MaxPriority); + if (_options.Queue.MaxPriority is not null) + { + arguments.Add("x-max-priority", _options.Queue.MaxPriority); + } - if (_options.Queue.MaxLength is not null) arguments.Add("x-max-length", _options.Queue.MaxLength); + if (_options.Queue.MaxLength is not null) + { + arguments.Add("x-max-length", _options.Queue.MaxLength); + } - if (_options.Queue.MaxLengthBytes is not null) arguments.Add("x-max-length-bytes", _options.Queue.MaxLengthBytes); + if (_options.Queue.MaxLengthBytes is not null) + { + arguments.Add("x-max-length-bytes", _options.Queue.MaxLengthBytes); + } - if (_options.Queue.MessageTtl is not null) arguments.Add("x-message-ttl", _options.Queue.MessageTtl); + if (_options.Queue.MessageTtl is not null) + { + arguments.Add("x-message-ttl", _options.Queue.MessageTtl); + } switch (_options.Queue.Mode) { @@ -121,11 +140,13 @@ private void DeclareQueue() arguments ); foreach (var routingKeyConfig in _options.Queue.Bindings) + { _channel?.QueueBind( _options.Queue.Name, routingKeyConfig.Exchange, routingKeyConfig.RoutingKey, routingKeyConfig.Arguments); + } } private void StartConsumerOnChannel() @@ -147,7 +168,10 @@ private void ConsumerCallback(BasicDeliverEventArgs args) .GetAwaiter(); task?.OnCompleted(() => { - if (_stoppingToken.IsCancellationRequested) return; + if (_stoppingToken.IsCancellationRequested) + { + return; + } var processedMessageStatus = task?.GetResult(); switch (processedMessageStatus) diff --git a/src/Motor.Extensions.Hosting.Timer/Timer.cs b/src/Motor.Extensions.Hosting.Timer/Timer.cs index 43617dbc..147d49f3 100644 --- a/src/Motor.Extensions.Hosting.Timer/Timer.cs +++ b/src/Motor.Extensions.Hosting.Timer/Timer.cs @@ -30,14 +30,19 @@ public Timer(IOptions config, private async Task StartTimer(CancellationToken token) { - if (_scheduler is not null) await _scheduler.Start(token); + if (_scheduler is not null) + { + await _scheduler.Start(token).ConfigureAwait(false); + } _started = true; } private void ThrowIfTimerAlreadyStarted() { if (_started) + { throw new InvalidOperationException("Cannot start timer as the timer was already started!"); + } } private async Task ConfigureTimer() @@ -69,11 +74,14 @@ public async Task StartAsync(CancellationToken token) { ThrowIfTimerAlreadyStarted(); await ConfigureTimer().ConfigureAwait(false); - await StartTimer(token); + await StartTimer(token).ConfigureAwait(false); } public async Task StopAsync(CancellationToken token) { - if (_scheduler is not null) await _scheduler.Shutdown(token); + if (_scheduler is not null) + { + await _scheduler.Shutdown(token); + } } } diff --git a/src/Motor.Extensions.Hosting/HealthChecks/MessageProcessingHealthCheck.cs b/src/Motor.Extensions.Hosting/HealthChecks/MessageProcessingHealthCheck.cs index 17bb5fac..a0214259 100644 --- a/src/Motor.Extensions.Hosting/HealthChecks/MessageProcessingHealthCheck.cs +++ b/src/Motor.Extensions.Hosting/HealthChecks/MessageProcessingHealthCheck.cs @@ -23,7 +23,10 @@ public MessageProcessingHealthCheck(IOptions options, public Task CheckHealthAsync(HealthCheckContext context, CancellationToken token = default) { - if (_queue.ItemCount == 0) return Task.FromResult(HealthCheckResult.Healthy()); + if (_queue.ItemCount == 0) + { + return Task.FromResult(HealthCheckResult.Healthy()); + } return Task.FromResult(DateTimeOffset.UtcNow - _queue.LastDequeuedAt > _maxTimeWithoutAcknowledgedMessage ? HealthCheckResult.Unhealthy() diff --git a/src/Motor.Extensions.Hosting/Internal/BackgroundTaskQueue.cs b/src/Motor.Extensions.Hosting/Internal/BackgroundTaskQueue.cs index 4bac4f27..ab4da270 100644 --- a/src/Motor.Extensions.Hosting/Internal/BackgroundTaskQueue.cs +++ b/src/Motor.Extensions.Hosting/Internal/BackgroundTaskQueue.cs @@ -24,7 +24,10 @@ public BackgroundTaskQueue(IMetricsFactory>? metricsFacto public Task QueueBackgroundWorkItem(T item) { - if (item is null) throw new ArgumentNullException(nameof(item)); + if (item is null) + { + throw new ArgumentNullException(nameof(item)); + } var taskCompletionStatus = new TaskCompletionSource(); diff --git a/src/Motor.Extensions.Http/PrometheusDelegatingHandler.cs b/src/Motor.Extensions.Http/PrometheusDelegatingHandler.cs index 9b288dc3..7cbaf8e0 100644 --- a/src/Motor.Extensions.Http/PrometheusDelegatingHandler.cs +++ b/src/Motor.Extensions.Http/PrometheusDelegatingHandler.cs @@ -27,7 +27,11 @@ protected override async Task SendAsync( stopwatch.Start(); var response = await base.SendAsync(request, token); var uri = request.RequestUri; - if (uri is null) return response; + if (uri is null) + { + return response; + } + _requestTotal.WithLabels(uri.Host, response.StatusCode.ToString()).Inc(); _requestLatency.WithLabels(uri.Host).Observe(stopwatch.ElapsedMilliseconds); return response; diff --git a/src/Motor.Extensions.Utilities/MotorHostBuilder.cs b/src/Motor.Extensions.Utilities/MotorHostBuilder.cs index 4abd15ba..b579c905 100644 --- a/src/Motor.Extensions.Utilities/MotorHostBuilder.cs +++ b/src/Motor.Extensions.Utilities/MotorHostBuilder.cs @@ -93,6 +93,7 @@ public IHostBuilder ConfigureContainer( public IHost Build() { if (_enableConfigureWebDefaults) + { _builder .ConfigureWebHostDefaults(builder => { @@ -101,6 +102,7 @@ public IHost Build() .ConfigureHealthChecks(builder => { foreach (var healthCheck in _healthChecks) + { builder.Add(new HealthCheckRegistration( healthCheck.Name, s => (IHealthCheck)ActivatorUtilities.GetServiceOrCreateInstance(s, healthCheck.Type), @@ -108,7 +110,9 @@ public IHost Build() healthCheck.Tags, healthCheck.Timeout) ); + } }); + } return _builder.Build(); } diff --git a/src/Motor.Extensions.Utilities/MotorHostBuilderHelper.cs b/src/Motor.Extensions.Utilities/MotorHostBuilderHelper.cs index ca672fc3..13ab6257 100644 --- a/src/Motor.Extensions.Utilities/MotorHostBuilderHelper.cs +++ b/src/Motor.Extensions.Utilities/MotorHostBuilderHelper.cs @@ -11,25 +11,38 @@ public static class MotorHostBuilderHelper public static void ConfigureWebHost(IWebHostBuilder builder, Func getSetting, Type? motorStartup) { IMotorStartup? startup = null; - if (motorStartup is not null) startup = Activator.CreateInstance(motorStartup) as IMotorStartup; + if (motorStartup is not null) + { + startup = Activator.CreateInstance(motorStartup) as IMotorStartup; + } var urls = builder.GetSetting(WebHostDefaults.ServerUrlsKey); const string defaultUrl = "http://0.0.0.0:9110"; if (string.IsNullOrEmpty(urls)) + { builder.UseUrls(defaultUrl); - else if (!urls.Contains(defaultUrl)) builder.UseUrls($"{urls};{defaultUrl}"); + } + else if (!urls.Contains(defaultUrl)) + { + builder.UseUrls($"{urls};{defaultUrl}"); + } builder.Configure((context, applicationBuilder) => { applicationBuilder.UseRouting(); var enablePrometheusSetting = getSetting(MotorHostDefaults.EnablePrometheusEndpointKey); if (string.IsNullOrEmpty(enablePrometheusSetting) || bool.Parse(enablePrometheusSetting)) + { applicationBuilder.UsePrometheusServer(); + } + startup?.Configure(context, applicationBuilder); applicationBuilder.UseEndpoints(endpoints => { endpoints.MapHealthChecks("/health"); }); }); if (motorStartup is not null) + { builder.UseSetting(WebHostDefaults.ApplicationKey, motorStartup.Assembly.GetName().Name); + } builder.ConfigureServices((context, collection) => { diff --git a/test/Motor.Extensions.Hosting.RabbitMQ_IntegrationTest/RabbitMQTestBuilder.cs b/test/Motor.Extensions.Hosting.RabbitMQ_IntegrationTest/RabbitMQTestBuilder.cs index 5f8d4a8c..c1c494c3 100644 --- a/test/Motor.Extensions.Hosting.RabbitMQ_IntegrationTest/RabbitMQTestBuilder.cs +++ b/test/Motor.Extensions.Hosting.RabbitMQ_IntegrationTest/RabbitMQTestBuilder.cs @@ -88,7 +88,10 @@ public RabbitMQTestBuilder WithSingleRandomPublishedMessage() public RabbitMQTestBuilder WithMultipleRandomPublishedMessage(ushort number = PrefetchCount) { - for (var i = 0; i < number; i++) WithSingleRandomPublishedMessage(); + for (var i = 0; i < number; i++) + { + WithSingleRandomPublishedMessage(); + } return this; } @@ -101,7 +104,10 @@ public RabbitMQTestBuilder Build(int retries = 3) using (var channel = Fixture.Connection.CreateModel()) { DeclareQueue(config, channel); - foreach (var message in messages) PublishSingleMessage(channel, message, config); + foreach (var message in messages) + { + PublishSingleMessage(channel, message, config); + } } Policy @@ -147,11 +153,13 @@ private void DeclareQueue(RabbitMQConsumerOptions options, IModel channel) arguments ); foreach (var routingKeyConfig in options.Queue.Bindings) + { channel.QueueBind( options.Queue.Name, routingKeyConfig.Exchange, routingKeyConfig.RoutingKey, routingKeyConfig.Arguments); + } } private RabbitMQConsumerOptions GetConsumerConfig() @@ -181,7 +189,9 @@ private RabbitMQConsumerOptions GetConsumerConfig() public IMessageConsumer GetConsumer(IHostApplicationLifetime applicationLifetime = null) { if (!isBuilt) + { throw new InvalidOperationException(); + } var rabbitConnectionFactoryMock = new Mock>(); @@ -222,7 +232,10 @@ public IMessageConsumer GetConsumer(IHostApplicationLifetime applicationLi public bool IsConsumerQueueDeclared() { if (!isBuilt) + { throw new InvalidOperationException(); + } + using var channel = Fixture.Connection.CreateModel(); channel.QueueDeclarePassive(QueueName); return true; @@ -238,7 +251,10 @@ public uint MessageInConsumerQueue() public IRawMessagePublisher GetPublisher() { if (!isBuilt) + { throw new InvalidOperationException(); + } + var rabbitConnectionFactoryMock = new Mock>(); var channel = Fixture.Connection.CreateModel(); diff --git a/test/Motor.Extensions.Utilities_IntegrationTest/DefaultHostingTest.cs b/test/Motor.Extensions.Utilities_IntegrationTest/DefaultHostingTest.cs index 90a0d6af..7ca62995 100644 --- a/test/Motor.Extensions.Utilities_IntegrationTest/DefaultHostingTest.cs +++ b/test/Motor.Extensions.Utilities_IntegrationTest/DefaultHostingTest.cs @@ -20,7 +20,9 @@ public class HomeController : Controller public HomeController(TestService testService) { if (testService is null) + { throw new ArgumentNullException(); + } } // diff --git a/test/Motor.Extensions.Utilities_IntegrationTest/DemonstrationTests.cs b/test/Motor.Extensions.Utilities_IntegrationTest/DemonstrationTests.cs index eff7793f..05e7832f 100644 --- a/test/Motor.Extensions.Utilities_IntegrationTest/DemonstrationTests.cs +++ b/test/Motor.Extensions.Utilities_IntegrationTest/DemonstrationTests.cs @@ -83,7 +83,10 @@ private static async Task GetMessageFromDestinationQueue(IModel channel) messageFromDestinationQueue = Encoding.UTF8.GetString(bytes.ToArray()); }; channel.BasicConsume(destinationQueueName, false, consumer); - while (messageFromDestinationQueue == string.Empty) await Task.Delay(TimeSpan.FromMilliseconds(50)).ConfigureAwait(false); + while (messageFromDestinationQueue == string.Empty) + { + await Task.Delay(TimeSpan.FromMilliseconds(50)).ConfigureAwait(false); + } return messageFromDestinationQueue; } diff --git a/test/Motor.Extensions.Utilities_IntegrationTest/GenericHostingTestBase.cs b/test/Motor.Extensions.Utilities_IntegrationTest/GenericHostingTestBase.cs index 66d0ac90..6b668096 100644 --- a/test/Motor.Extensions.Utilities_IntegrationTest/GenericHostingTestBase.cs +++ b/test/Motor.Extensions.Utilities_IntegrationTest/GenericHostingTestBase.cs @@ -49,7 +49,10 @@ protected static void PublishMessageIntoQueueOfService(IModel channel, string me { var basicProperties = channel.CreateBasicProperties(); - if (rabbitMqHeaders is not null) basicProperties.Headers = rabbitMqHeaders; + if (rabbitMqHeaders is not null) + { + basicProperties.Headers = rabbitMqHeaders; + } channel.BasicPublish("amq.topic", "serviceQueue", true, basicProperties, Encoding.UTF8.GetBytes(messageToPublish)); diff --git a/test/Motor.Extensions.Utilities_IntegrationTest/GenericHostingTests.cs b/test/Motor.Extensions.Utilities_IntegrationTest/GenericHostingTests.cs index 59ac0958..595cacc6 100644 --- a/test/Motor.Extensions.Utilities_IntegrationTest/GenericHostingTests.cs +++ b/test/Motor.Extensions.Utilities_IntegrationTest/GenericHostingTests.cs @@ -45,7 +45,11 @@ public async Task var channel = Fixture.Connection.CreateModel(); await CreateQueueForServicePublisherWithPublisherBindingFromConfig(channel).ConfigureAwait(false); await host.StartAsync().ConfigureAwait(false); - for (var i = 0; i < messageCount; i++) PublishMessageIntoQueueOfService(channel, message); + for (var i = 0; i < messageCount; i++) + { + PublishMessageIntoQueueOfService(channel, message); + } + var httpClient = new HttpClient(); await Task.Delay(TimeSpan.Parse(maxTimeSinceLastProcessedMessage) * 2).ConfigureAwait(false); @@ -71,7 +75,11 @@ public async Task var channel = Fixture.Connection.CreateModel(); await CreateQueueForServicePublisherWithPublisherBindingFromConfig(channel).ConfigureAwait(false); await host.StartAsync().ConfigureAwait(false); - for (var i = 0; i < messageCount; i++) PublishMessageIntoQueueOfService(channel, message); + for (var i = 0; i < messageCount; i++) + { + PublishMessageIntoQueueOfService(channel, message); + } + var httpClient = new HttpClient(); var healthResponse = await httpClient.GetAsync("http://localhost:9110/health"); @@ -92,7 +100,11 @@ public async Task var channel = Fixture.Connection.CreateModel(); await CreateQueueForServicePublisherWithPublisherBindingFromConfig(channel).ConfigureAwait(false); await host.StartAsync().ConfigureAwait(false); - for (var i = 0; i < messageCount; i++) PublishMessageIntoQueueOfService(channel, message); + for (var i = 0; i < messageCount; i++) + { + PublishMessageIntoQueueOfService(channel, message); + } + var httpClient = new HttpClient(); await Task.Delay(TimeSpan.FromSeconds(10)).ConfigureAwait(false); @@ -114,7 +126,11 @@ public async Task var channel = Fixture.Connection.CreateModel(); await CreateQueueForServicePublisherWithPublisherBindingFromConfig(channel).ConfigureAwait(false); await host.StartAsync().ConfigureAwait(false); - for (var i = 0; i < messageCount; i++) PublishMessageIntoQueueOfService(channel, message); + for (var i = 0; i < messageCount; i++) + { + PublishMessageIntoQueueOfService(channel, message); + } + var httpClient = new HttpClient(); await Task.Delay(TimeSpan.FromSeconds(10)).ConfigureAwait(false);