< Summary

Information
Class: Elsa.Workflows.Runtime.Notifications.DispatchWorkflowActivationDeniedRoute
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Notifications/DispatchWorkflowActivationDenied.cs
Line coverage
100%
Covered lines: 14
Uncovered lines: 0
Coverable lines: 14
Total lines: 48
Line coverage: 100%
Branch coverage
100%
Covered branches: 16
Total branches: 16
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Add(...)100%11100%
SanitizeAndRead(...)100%1616100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Notifications/DispatchWorkflowActivationDenied.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2
 3namespace Elsa.Workflows.Runtime.Notifications;
 4
 5/// <summary>
 6/// Signals that a queued child-workflow dispatch was accepted but activation was denied.
 7/// </summary>
 8internal sealed record DispatchWorkflowActivationDenied(
 9    string ParentWorkflowInstanceId,
 10    string WorkflowInstanceId,
 11    string ActivityTypeName,
 12    string StimulusHash) : INotification;
 13
 14/// <summary>
 15/// Carries an internal bookmark-resume route through queued definition dispatch without persisting it on a child instan
 16/// </summary>
 17internal static class DispatchWorkflowActivationDeniedRoute
 18{
 19    private const string ActivityTypeNameKey = "__elsa.internal.dispatch-activation-denied.activity-type-name";
 20    private const string StimulusHashKey = "__elsa.internal.dispatch-activation-denied.stimulus-hash";
 21
 22    public static void Add(IDictionary<string, object> properties, string activityTypeName, string stimulusHash)
 23    {
 1924        properties[ActivityTypeNameKey] = activityTypeName;
 1925        properties[StimulusHashKey] = stimulusHash;
 1926    }
 27
 28    public static IDictionary<string, object>? SanitizeAndRead(IDictionary<string, object>? properties, out (string Acti
 29    {
 4230        route = null;
 31
 4232        if (properties == null)
 1733            return null;
 34
 2535        if (!properties.ContainsKey(ActivityTypeNameKey) && !properties.ContainsKey(StimulusHashKey))
 636            return properties;
 37
 38        // Do not mutate the caller's property bag: it may be shared with dispatch notification handlers.
 1939        var sanitizedProperties = new Dictionary<string, object>(properties);
 1940        var hasActivityTypeName = sanitizedProperties.Remove(ActivityTypeNameKey, out var activityTypeNameValue);
 1941        var hasStimulusHash = sanitizedProperties.Remove(StimulusHashKey, out var stimulusHashValue);
 42
 1943        if (hasActivityTypeName && hasStimulusHash && activityTypeNameValue is string activityTypeName && !string.IsNull
 1944            route = (activityTypeName, stimulusHash);
 45
 1946        return sanitizedProperties;
 47    }
 48}