< Summary

Information
Class: Elsa.Expressions.Python.Handlers.ConfigurePythonFromOptions
Assembly: Elsa.Expressions.Python
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/Handlers/ConfigurePythonFromOptions.cs
Line coverage
50%
Covered lines: 3
Uncovered lines: 3
Coverable lines: 6
Total lines: 33
Line coverage: 50%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
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(...)0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.Python/Handlers/ConfigurePythonFromOptions.cs

#LineLine coverage
 1using Elsa.Mediator.Contracts;
 2using Elsa.Expressions.Python.Notifications;
 3using Elsa.Expressions.Python.Options;
 4using JetBrains.Annotations;
 5using Microsoft.Extensions.Options;
 6
 7namespace Elsa.Expressions.Python.Handlers;
 8
 9/// <summary>
 10/// This handler configures the Python engine based on the <see cref="PythonOptions"/>.
 11/// </summary>
 12[UsedImplicitly]
 13public class ConfigurePythonFromOptions : INotificationHandler<EvaluatingPython>
 14{
 15    private readonly PythonOptions _options;
 16
 17    /// <summary>
 18    /// Initializes a new instance of the <see cref="ConfigurePythonFromOptions"/> class.
 19    /// </summary>
 31920    public ConfigurePythonFromOptions(IOptions<PythonOptions> options)
 21    {
 31922        _options = options.Value;
 31923    }
 24
 25    /// <inheritdoc />
 26    public Task HandleAsync(EvaluatingPython notification, CancellationToken cancellationToken)
 27    {
 028        foreach (var action in _options.Scopes) action(notification.Scope);
 029        foreach (var script in _options.Scripts) notification.AppendScript(script);
 30
 031        return Task.CompletedTask;
 32    }
 33}