< Summary

Information
Class: Elsa.Dsl.ElsaScript.Materializers.ElsaScriptWorkflowMaterializer
Assembly: Elsa.Dsl.ElsaScript
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Dsl.ElsaScript/Materializers/ElsaScriptWorkflowMaterializer.cs
Line coverage
16%
Covered lines: 2
Uncovered lines: 10
Coverable lines: 12
Total lines: 37
Line coverage: 16.6%
Branch coverage
0%
Covered branches: 0
Total branches: 2
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%
get_Name()100%11100%
MaterializeAsync()0%620%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Dsl.ElsaScript/Materializers/ElsaScriptWorkflowMaterializer.cs

#LineLine coverage
 1using Elsa.Dsl.ElsaScript.Contracts;
 2using Elsa.Workflows.Activities;
 3using Elsa.Workflows.Management;
 4using Elsa.Workflows.Management.Entities;
 5
 6namespace Elsa.Dsl.ElsaScript.Materializers;
 7
 8/// <summary>
 9/// Materializes a <see cref="Workflow"/> from a <see cref="WorkflowDefinition"/>'s ElsaScript source code.
 10/// </summary>
 26611public class ElsaScriptWorkflowMaterializer(IElsaScriptCompiler compiler) : IWorkflowMaterializer
 12{
 13    /// <summary>
 14    /// The name of the materializer.
 15    /// </summary>
 16    public const string MaterializerName = "ElsaScript";
 17
 18    /// <inheritdoc />
 819    public string Name => MaterializerName;
 20
 21    /// <inheritdoc />
 22    public async ValueTask<Workflow> MaterializeAsync(WorkflowDefinition definition, CancellationToken cancellationToken
 23    {
 024        var source = definition.OriginalSource ?? string.Empty;
 025        var workflow = await compiler.CompileAsync(source, cancellationToken);
 26
 27        // Preserve the workflow definition ID and version
 028        workflow.Identity = new(
 029            definition.DefinitionId,
 030            definition.Version,
 031            definition.Id,
 032            definition.TenantId
 033        );
 34
 035        return workflow;
 036    }
 37}