< Summary

Information
Class: Elsa.Mediator.CommandStrategies.BackgroundStrategy
Assembly: Elsa.Mediator
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Mediator/CommandStrategies/BackgroundStrategy.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 28
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ExecuteAsync()100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Mediator/CommandStrategies/BackgroundStrategy.cs

#LineLine coverage
 1using Elsa.Mediator.Contexts;
 2using Elsa.Mediator.Contracts;
 3using Elsa.Mediator.Middleware.Command;
 4using Microsoft.Extensions.DependencyInjection;
 5
 6namespace Elsa.Mediator.CommandStrategies;
 7
 8/// <summary>
 9/// Invokes command handlers in the background and does not wait for the result.
 10/// </summary>
 11public class BackgroundStrategy : ICommandStrategy
 12{
 13    /// <inheritdoc />
 14    public async Task<TResult> ExecuteAsync<TResult>(CommandStrategyContext context)
 15    {
 2616        var commandsChannel = context.ServiceProvider.GetRequiredService<ICommandsChannel>();
 2617        var commandContext = context.CommandContext;
 2618        var queuedContext = new CommandContext(
 2619            commandContext.Command,
 2620            CommandStrategy.Default,
 2621            commandContext.ResultType,
 2622            commandContext.Headers,
 2623            commandContext.ServiceProvider,
 2624            CancellationToken.None);
 2625        await commandsChannel.Writer.WriteAsync(queuedContext, context.CancellationToken);
 2626        return default!;
 2627    }
 28}

Methods/Properties

ExecuteAsync()