< Summary

Information
Class: Elsa.Workflows.Runtime.Handlers.DispatchStimulusCommandHandler
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/DispatchStimulusCommandHandler.cs
Line coverage
60%
Covered lines: 6
Uncovered lines: 4
Coverable lines: 10
Total lines: 29
Line coverage: 60%
Branch coverage
25%
Covered branches: 1
Total branches: 4
Branch coverage: 25%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
HandleAsync()25%5455.55%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Handlers/DispatchStimulusCommandHandler.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Mediator.Models;
 3using Elsa.Workflows.Runtime.Commands;
 4using JetBrains.Annotations;
 5
 6namespace Elsa.Workflows.Runtime.Handlers;
 7
 8[UsedImplicitly]
 539public class DispatchStimulusCommandHandler(IStimulusSender stimulusSender) : ICommandHandler<DispatchStimulusCommand>
 10{
 11    public async Task<Unit> HandleAsync(DispatchStimulusCommand command, CancellationToken cancellationToken)
 12    {
 313        var request = command.Request;
 14
 315        if (request.ActivityTypeName != null)
 16        {
 317            await stimulusSender.SendAsync(request.ActivityTypeName, request.Stimulus!, request.Metadata, cancellationTo
 318            return Unit.Instance;
 19        }
 20
 021        if (request.StimulusHash != null)
 22        {
 023            await stimulusSender.SendAsync(request.StimulusHash!, request.Metadata, cancellationToken);
 024            return Unit.Instance;
 25        }
 26
 027        throw new InvalidOperationException("Either ActivityTypeName or StimulusHash must be specified.");
 328    }
 29}