< Summary

Information
Class: Gateway.Apis.Amqp.RegistrationExtensions.AsyncApiConsumerFactoryBag
Assembly: Gateway
File(s): /home/runner/work/dotnet-microservice/dotnet-microservice/Gateway/Apis/Amqp/RegistrationExtensions/AsyncApiConsumerFactoryBag.cs
Tag: 34_11887803474
Line coverage
0%
Covered lines: 0
Uncovered lines: 24
Coverable lines: 24
Total lines: 41
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
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
.cctor()100%210%
AddQueueConsumer(...)100%210%
CreateConsumers(...)0%620%

File(s)

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

#LineLine coverage
 1using RabbitMQ.Client;
 2using Saunter.AsyncApiSchema.v2;
 3using Saunter.Utils;
 4
 5namespace Gateway.Apis.Amqp.RegistrationExtensions;
 6
 7public static class AsyncApiConsumerFactoryBag
 8{
 09    private static readonly Queue<Action<IModel, IServiceProvider>> DocumentationActions = new();
 10
 11    public static void AddQueueConsumer<TMessage>(VersionState versionState)
 12    {
 013        string queueName = $"{versionState.Version:'v'VVV}/{typeof(TMessage).Name}";
 014        DocumentationActions.Enqueue(
 015            (model, sp) =>
 016            {
 017                QueueConsumerFactory.CreateQueueConsumer<TMessage>(sp, model, queueName);
 018            }
 019        );
 020        AsyncApiDocumentationGenerationBag.AddDocumentation(x =>
 021        {
 022            x.AsyncApi.Channels.AddOrAppend(
 023                queueName,
 024                new Saunter.AsyncApiSchema.v2.ChannelItem()
 025                {
 026                    Subscribe = new Saunter.AsyncApiSchema.v2.Operation() { },
 027                    Publish = new Operation() { Message = new Message() }
 028                }
 029            );
 030        });
 031    }
 32
 33    public static void CreateConsumers(IModel model, IServiceProvider serviceProvider)
 34    {
 035        while (DocumentationActions.Count > 0)
 36        {
 037            var consumerFactory = DocumentationActions.Dequeue();
 038            consumerFactory(model, serviceProvider);
 39        }
 040    }
 41}