< Summary

Information
Class: Elsa.Expressions.JavaScript.Handlers.ConfigureEngineWithCommonTypes
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Handlers/ConfigureEngineWithCommonTypes.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 30
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
HandleAsync(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Handlers/ConfigureEngineWithCommonTypes.cs

#LineLine coverage
 1using Elsa.Extensions;
 2using Elsa.Expressions.JavaScript.Notifications;
 3using Elsa.Mediator.Contracts;
 4using Elsa.Workflows.LogPersistence;
 5using JetBrains.Annotations;
 6
 7namespace Elsa.Expressions.JavaScript.Handlers;
 8
 9/// <summary>
 10/// A handler that configures the Jint engine with common types.
 11/// </summary>
 12[UsedImplicitly]
 13public class ConfigureEngineWithCommonTypes : INotificationHandler<EvaluatingJavaScript>
 14{
 15    /// <inheritdoc />
 16    public Task HandleAsync(EvaluatingJavaScript notification, CancellationToken cancellationToken)
 17    {
 18818        var engine = notification.Engine;
 19
 20        // Add common .NET types.
 18821        engine.RegisterType<DateTime>();
 18822        engine.RegisterType<DateTimeOffset>();
 18823        engine.RegisterType<TimeSpan>();
 18824        engine.RegisterType<Guid>();
 18825        engine.RegisterType<Random>();
 18826        engine.RegisterType<LogPersistenceMode>();
 27
 18828        return Task.CompletedTask;
 29    }
 30}