< Summary

Information
Class: Elsa.Workflows.Management.Providers.TypedActivityProvider
Assembly: Elsa.Workflows.Management
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Providers/TypedActivityProvider.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 43
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
GetDescriptorsAsync()100%11100%
DescribeActivityTypesAsync()100%44100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Providers/TypedActivityProvider.cs

#LineLine coverage
 1using System.Runtime.CompilerServices;
 2using Elsa.Workflows.Management.Options;
 3using Elsa.Workflows.Models;
 4using JetBrains.Annotations;
 5using Microsoft.Extensions.Options;
 6
 7namespace Elsa.Workflows.Management.Providers;
 8
 9/// <summary>
 10/// Provides activity descriptors based on a list of activity types registered in the <see cref="ManagementOptions"/>.
 11/// </summary>
 12[UsedImplicitly]
 13public class TypedActivityProvider : IActivityProvider
 14{
 15    private readonly IActivityDescriber _activityDescriber;
 16    private readonly ManagementOptions _options;
 17
 18    /// <summary>
 19    /// Initializes a new instance of the <see cref="TypedActivityProvider"/> class.
 20    /// </summary>
 32421    public TypedActivityProvider(IOptions<ManagementOptions> options, IActivityDescriber activityDescriber)
 22    {
 32423        _activityDescriber = activityDescriber;
 32424        _options = options.Value;
 32425    }
 26
 27    /// <inheritdoc />
 28    public async ValueTask<IEnumerable<ActivityDescriptor>> GetDescriptorsAsync(CancellationToken cancellationToken = de
 29    {
 230        var activityTypes = _options.ActivityTypes;
 231        var descriptors = await DescribeActivityTypesAsync(activityTypes, cancellationToken).ToListAsync(cancellationTok
 232        return descriptors;
 233    }
 34
 35    private async IAsyncEnumerable<ActivityDescriptor> DescribeActivityTypesAsync(IEnumerable<Type> activityTypes, [Enum
 36    {
 22437        foreach (var activityType in activityTypes)
 38        {
 11039            var descriptor = await _activityDescriber.DescribeActivityAsync(activityType, cancellationToken);
 11040            yield return descriptor;
 41        }
 242    }
 43}