< Summary

Information
Class: Elsa.Resilience.Modifiers.ResilientActivityDescriptorModifier
Assembly: Elsa.Resilience
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Resilience/Modifiers/ResilientActivityDescriptorModifier.cs
Line coverage
90%
Covered lines: 10
Uncovered lines: 1
Coverable lines: 11
Total lines: 29
Line coverage: 90.9%
Branch coverage
70%
Covered branches: 7
Total branches: 10
Branch coverage: 70%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Modify(...)70%101090.9%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Resilience/Modifiers/ResilientActivityDescriptorModifier.cs

#LineLine coverage
 1using Elsa.Workflows;
 2using Elsa.Workflows.Models;
 3
 4namespace Elsa.Resilience.Modifiers;
 5
 6/// <summary>
 7/// Modifies the <see cref="ActivityDescriptor"/> for resilient activities.
 8/// </summary>
 9public class ResilientActivityDescriptorModifier : IActivityDescriptorModifier
 10{
 11    /// <inheritdoc />
 12    public void Modify(ActivityDescriptor descriptor)
 13    {
 29014        if (!descriptor.CustomProperties.TryGetValue("Type", out var typeObj))
 7315            return;
 16
 21717        if(typeObj is not Type type)
 018            return;
 19
 20        // Check if this type implements IResilientActivity.
 21721        if (!typeof(IResilientActivity).IsAssignableFrom(type))
 20922            return;
 23
 4824        var categoryAttr = descriptor.Attributes.FirstOrDefault(x => x is ResilienceCategoryAttribute) as ResilienceCate
 825        var category = categoryAttr?.Category ?? "Default";
 826        descriptor.CustomProperties["Resilient"] = true;
 827        descriptor.CustomProperties["ResilienceCategory"] = category;
 828    }
 29}