< Summary

Information
Class: Elsa.Extensions.CollectionExtensions
Assembly: Elsa.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Extensions/CollectionExtensions.cs
Line coverage
83%
Covered lines: 5
Uncovered lines: 1
Coverable lines: 6
Total lines: 39
Line coverage: 83.3%
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
AddRange(...)100%22100%
AddRange(...)100%210%
RemoveWhere(...)100%22100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Common/Extensions/CollectionExtensions.cs

#LineLine coverage
 1// ReSharper disable once CheckNamespace
 2namespace Elsa.Extensions;
 3
 4/// <summary>
 5/// Provides extension methods for collections.
 6/// </summary>
 7public static class CollectionExtensions
 8{
 9    /// <summary>
 10    /// Adds a range of items to a collection.
 11    /// </summary>
 12    /// <param name="target">The target collection.</param>
 13    /// <param name="source">The source collection.</param>
 14    /// <typeparam name="T">The type of items in the collection.</typeparam>
 15    public static void AddRange<T>(this ICollection<T> target, IEnumerable<T> source)
 16    {
 495617        foreach (var item in source) target.Add(item);
 61818    }
 19
 20    /// <summary>
 21    /// Adds a range of items to a collection.
 22    /// </summary>
 23    /// <param name="target">The target collection.</param>
 24    /// <param name="source">The source collection.</param>
 25    /// <typeparam name="T">The type of items in the collection.</typeparam>
 026    public static void AddRange<T>(this ICollection<T> target, params T[] source) => AddRange(target, source.AsEnumerabl
 27
 28    /// <summary>
 29    /// Removes all items from a collection that match the specified predicate.
 30    /// </summary>
 31    /// <param name="collection">The collection.</param>
 32    /// <param name="predicate">The predicate.</param>
 33    /// <typeparam name="T">The type of items in the collection.</typeparam>
 34    public static void RemoveWhere<T>(this ICollection<T> collection, Func<T, bool> predicate)
 35    {
 661236        var itemsToRemove = collection.Where(predicate).ToList();
 1555537        foreach (var item in itemsToRemove) collection.Remove(item);
 661238    }
 39}