< Summary

Information
Class: Elsa.Extensions.VariableCollectionExtensions
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Extensions/VariableCollectionExtensions.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 21
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
Declare(...)100%22100%

File(s)

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

#LineLine coverage
 1using Elsa.Workflows.Memory;
 2
 3// ReSharper disable once CheckNamespace
 4namespace Elsa.Extensions;
 5
 6/// <summary>
 7/// Adds extension methods to <see cref="ICollection{Variable}"/>.
 8/// </summary>
 9public static class VariableCollectionExtensions
 10{
 11    /// <summary>
 12    /// Adds the specified variable to the collection if it doesn't already exist.
 13    /// </summary>
 14    public static void Declare(this ICollection<Variable> variables, Variable variable)
 15    {
 9616        var existingVariable = variables.FirstOrDefault(x => x.Name == variable.Name);
 17
 6418        if (existingVariable == null)
 6419            variables.Add(variable);
 6420    }
 21}