< Summary

Information
Class: Gateway.Apis.Amqp.RegistrationExtensions.ConsumerHost
Assembly: Gateway
File(s): /home/runner/work/dotnet-microservice/dotnet-microservice/Gateway/Apis/Amqp/RegistrationExtensions/ConsumerHost.cs
Tag: 34_11887803474
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 27
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
StartAsync(...)100%210%
StopAsync(...)0%2040%

File(s)

/home/runner/work/dotnet-microservice/dotnet-microservice/Gateway/Apis/Amqp/RegistrationExtensions/ConsumerHost.cs

#LineLine coverage
 1using RabbitMQ.Client;
 2
 3namespace Gateway.Apis.Amqp.RegistrationExtensions;
 4
 05public class ConsumerHost(IConnectionFactory connectionFactory, IServiceProvider serviceProvider)
 6    : IHostedService
 7{
 08    private readonly IConnectionFactory _connectionFactory = connectionFactory;
 09    private readonly IServiceProvider _serviceProvider = serviceProvider;
 10    private IConnection? _connection;
 11    private IModel? _channel;
 12
 13    public Task StartAsync(CancellationToken cancellationToken)
 14    {
 015        _connection = _connectionFactory.CreateConnection();
 016        _channel = _connection.CreateModel();
 017        AsyncApiConsumerFactoryBag.CreateConsumers(_channel, _serviceProvider);
 018        return Task.CompletedTask;
 19    }
 20
 21    public Task StopAsync(CancellationToken cancellationToken)
 22    {
 023        _connection?.Dispose();
 024        _channel?.Dispose();
 025        return Task.CompletedTask;
 26    }
 27}