< Summary

Information
Class: Elsa.Extensions.ObjectDictionaryExtensions
Assembly: Elsa.Api.Common
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Api.Common/Extensions/ObjectDictionaryExtensions.cs
Line coverage
80%
Covered lines: 4
Uncovered lines: 1
Coverable lines: 5
Total lines: 15
Line coverage: 80%
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
GetOrAdd(...)100%22100%
Get(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Api.Common/Extensions/ObjectDictionaryExtensions.cs

#LineLine coverage
 1// ReSharper disable once CheckNamespace
 2namespace Elsa.Extensions;
 3
 4static class ObjectDictionaryExtensions
 5{
 6    public static T GetOrAdd<T>(this IDictionary<object, object> dictionary, object key, Func<T> valueFactory)
 7    {
 118        if (dictionary.TryGetValue(key, out var value)) return (T)value;
 19        value = valueFactory();
 110        dictionary.Add(key, value!);
 111        return (T)value!;
 12    }
 13
 014    public static T Get<T>(this IDictionary<object, object> dictionary, object key) => (T)dictionary[key];
 15}