< Summary

Information
Class: Elsa.Workflows.Management.Options.HostMethodActivitiesOptions
Assembly: Elsa.Workflows.Management
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Options/HostMethodActivitiesOptions.cs
Line coverage
57%
Covered lines: 4
Uncovered lines: 3
Coverable lines: 7
Total lines: 36
Line coverage: 57.1%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_ActivityTypes()100%11100%
AddType(...)100%22100%
AddType(...)0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Options/HostMethodActivitiesOptions.cs

#LineLine coverage
 1namespace Elsa.Workflows.Management.Options;
 2
 3/// <summary>
 4/// Represents the options for managing host method-based activities in workflows.
 5/// </summary>
 6public class HostMethodActivitiesOptions
 7{
 8    /// <summary>
 9    /// Maps a registration key to a CLR type whose public async methods should be exposed as activities.
 10    /// </summary>
 3511    public IDictionary<string, Type> ActivityTypes { get; } = new Dictionary<string, Type>(StringComparer.OrdinalIgnoreC
 12
 13    /// <summary>
 14    /// Adds a new activity type to the collection of activity types.
 15    /// </summary>
 16    /// <typeparam name="T">The type of the activity to add.</typeparam>
 17    /// <param name="key">An optional key to associate with the activity type. If not provided, the type's name will be 
 18    public HostMethodActivitiesOptions AddType<T>(string? key = null) where T : class
 19    {
 1420        key ??= typeof(T).Name;
 1421        ActivityTypes[key] = typeof(T);
 1422        return this;
 23    }
 24
 25    /// <summary>
 26    /// Adds a new activity type to the collection of activity types.
 27    /// </summary>
 28    /// <param name="type">The type of the activity to add.</param>
 29    /// <param name="key">An optional key to associate with the activity type. If not provided, the type's name will be 
 30    public HostMethodActivitiesOptions AddType(Type type, string? key = null)
 31    {
 032        key ??= type.Name;
 033        ActivityTypes[key] = type;
 034        return this;
 35    }
 36}