< Summary

Information
Class: Elsa.Extensions.BehaviorCollectionExtensions
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/BehaviorCollectionExtensions.cs
Line coverage
25%
Covered lines: 1
Uncovered lines: 3
Coverable lines: 4
Total lines: 19
Line coverage: 25%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Add(...)100%11100%
Remove(...)0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/BehaviorCollectionExtensions.cs

#LineLine coverage
 1using Elsa.Workflows;
 2
 3// ReSharper disable once CheckNamespace
 4namespace Elsa.Extensions;
 5
 6public static class BehaviorCollectionExtensions
 7{
 8    extension(ICollection<IBehavior> behaviors)
 9    {
 1563710        public void Add<T>(IActivity owner) where T : IBehavior => behaviors.Add((T)Activator.CreateInstance(typeof(T), 
 11
 12        public void Remove<T>() where T : IBehavior
 13        {
 014            var behaviorsToRemove = behaviors.Where(x => x is T).ToList();
 15
 016            foreach (var behavior in behaviorsToRemove) behaviors.Remove(behavior);
 017        }
 18    }
 19}