< Summary

Information
Class: Elsa.Extensions.EngineExtensions
Assembly: Elsa.Expressions.JavaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Extensions/EngineExtensions.cs
Line coverage
87%
Covered lines: 7
Uncovered lines: 1
Coverable lines: 8
Total lines: 35
Line coverage: 87.5%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
RegisterType(...)100%11100%
RegisterType(...)100%11100%
SyncVariablesContainer(...)50%4483.33%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Expressions.JavaScript/Extensions/EngineExtensions.cs

#LineLine coverage
 1using Elsa.Expressions.JavaScript.Helpers;
 2using Elsa.Expressions.JavaScript.Options;
 3using Jint;
 4using Jint.Runtime.Interop;
 5using Microsoft.Extensions.Options;
 6
 7// ReSharper disable once CheckNamespace
 8namespace Elsa.Extensions;
 9
 10/// <summary>
 11/// Extends <see cref="Engine"/>.
 12/// </summary>
 13public static class EngineExtensions
 14{
 15    /// <summary>
 16    /// Register the specified type <c>T</c> with the engine.
 17    /// </summary>
 118518    public static void RegisterType<T>(this Engine engine) => engine.SetValue(typeof(T).Name, TypeReference.CreateTypeRe
 19
 20    /// <summary>
 21    /// Register the specified type <c>T</c> with the engine.
 22    /// </summary>
 278423    public static void RegisterType(this Engine engine, Type type) => engine.SetValue(type.Name, TypeReference.CreateTyp
 24
 25    internal static void SyncVariablesContainer(this Engine engine, IOptions<JintOptions> options, string name, object? 
 26    {
 527        if (options.Value.DisableWrappers || options.Value.DisableVariableCopying)
 028            return;
 29
 30        // To ensure both variable accessor syntaxes work, we need to update the variables container in the engine as we
 531        var variablesContainer = (IDictionary<string, object?>)engine.GetValue("variables").ToObject()!;
 532        variablesContainer[name] = ObjectConverterHelper.ProcessVariableValue(engine, value);
 533        engine.SetValue("variables", variablesContainer);
 534    }
 35}