< Summary

Information
Class: Elsa.Workflows.Management.Activities.WorkflowDefinitionActivity.WorkflowDefinitionActivityProvider
Assembly: Elsa.Workflows.Management
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Activities/WorkflowDefinitionActivity/WorkflowDefinitionActivityProvider.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 38
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
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%
CreateDescriptors(...)100%11100%
CreateDescriptor(...)100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Activities/WorkflowDefinitionActivity/WorkflowDefinitionActivityProvider.cs

#LineLine coverage
 1using Elsa.Common.Models;
 2using Elsa.Workflows.Management.Entities;
 3using Elsa.Workflows.Management.Filters;
 4using Elsa.Workflows.Models;
 5
 6namespace Elsa.Workflows.Management.Activities.WorkflowDefinitionActivity;
 7
 8/// <summary>
 9/// Provides activity descriptors based on <see cref="WorkflowDefinition"/>s stored in the database.
 10/// </summary>
 32411public class WorkflowDefinitionActivityProvider(IWorkflowDefinitionStore store, WorkflowDefinitionActivityDescriptorFact
 12{
 13    /// <inheritdoc />
 14    public async ValueTask<IEnumerable<ActivityDescriptor>> GetDescriptorsAsync(CancellationToken cancellationToken = de
 15    {
 6516        var filter = new WorkflowDefinitionFilter
 6517        {
 6518            UsableAsActivity = true,
 6519            VersionOptions = VersionOptions.All
 6520        };
 21
 6522        var definitions = (await store.FindManyAsync(filter, cancellationToken)).ToList();
 6523        return CreateDescriptors(definitions).ToList();
 6524    }
 25
 26    private IEnumerable<ActivityDescriptor> CreateDescriptors(ICollection<WorkflowDefinition> definitions)
 27    {
 82928        return definitions.Select(x => CreateDescriptor(x, definitions));
 29    }
 30
 31    private ActivityDescriptor CreateDescriptor(WorkflowDefinition definition, ICollection<WorkflowDefinition> allDefini
 32    {
 76433        var latestPublishedVersion = allDefinitions
 917834            .Where(x => x.DefinitionId == definition.DefinitionId && x.IsPublished)
 137935            .MaxBy(x => x.Version);
 76436        return workflowDefinitionActivityDescriptorFactory.CreateDescriptor(definition, latestPublishedVersion);
 37    }
 38}