< Summary

Information
Class: Elsa.Workflows.ActivityRegistryLookupService
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Services/ActivityRegistryLookupService.cs
Line coverage
81%
Covered lines: 9
Uncovered lines: 2
Coverable lines: 11
Total lines: 43
Line coverage: 81.8%
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%
FindAsync(...)100%11100%
FindAsync(...)100%11100%
FindAsync(...)100%210%
FindMany(...)100%210%
FindAsync()100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Services/ActivityRegistryLookupService.cs

#LineLine coverage
 1using Elsa.Workflows.Models;
 2
 3namespace Elsa.Workflows;
 4
 5/// <summary>
 6/// Represents a service used to lookup activity descriptors in the activity registry.
 7/// </summary>
 8518public class ActivityRegistryLookupService(IActivityRegistry activityRegistry, IEnumerable<IActivityProvider> providers)
 9{
 10    /// <inheritdoc />
 11    public Task<ActivityDescriptor?> FindAsync(string type)
 12    {
 10213        return FindAsync(() => activityRegistry.Find(type));
 14    }
 15
 16    /// <inheritdoc />
 17    public Task<ActivityDescriptor?> FindAsync(string type, int version)
 18    {
 4114819        return FindAsync(() => activityRegistry.Find(type, version));
 20    }
 21
 22    /// <inheritdoc />
 23    public Task<ActivityDescriptor?> FindAsync(Func<ActivityDescriptor, bool> predicate)
 24    {
 025        return FindAsync(() => activityRegistry.Find(predicate));
 26    }
 27
 28    /// <inheritdoc />
 29    public IEnumerable<ActivityDescriptor> FindMany(Func<ActivityDescriptor, bool> predicate)
 30    {
 031        return activityRegistry.FindMany(predicate);
 32    }
 33
 34    private async Task<ActivityDescriptor?> FindAsync(Func<ActivityDescriptor?> findPredicate)
 35    {
 2030436        var descriptor = findPredicate.Invoke();
 2030437        if (descriptor is not null)
 1966238            return descriptor;
 39
 64240        await activityRegistry.RefreshDescriptorsAsync(providers);
 64241        return findPredicate.Invoke();
 2030442    }
 43}