< Summary

Information
Class: Elsa.Workflows.Management.Materializers.JsonWorkflowMaterializer
Assembly: Elsa.Workflows.Management
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Materializers/JsonWorkflowMaterializer.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 38
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
get_Name()100%11100%
.ctor(...)100%11100%
MaterializeAsync(...)100%11100%
ToWorkflow(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Materializers/JsonWorkflowMaterializer.cs

#LineLine coverage
 1using Elsa.Workflows.Activities;
 2using Elsa.Workflows.Management.Entities;
 3using Elsa.Workflows.Management.Mappers;
 4
 5namespace Elsa.Workflows.Management.Materializers;
 6
 7/// <summary>
 8/// Materializes a <see cref="Workflow"/> from a <see cref="WorkflowDefinition"/>'s JSON data.
 9/// </summary>
 10public class JsonWorkflowMaterializer : IWorkflowMaterializer
 11{
 12    private readonly WorkflowDefinitionMapper _workflowDefinitionMapper;
 13
 14    /// <summary>
 15    /// The name of the materializer.
 16    /// </summary>
 17    public const string MaterializerName = "Json";
 18
 19    /// <inheritdoc />
 90920    public string Name => MaterializerName;
 21
 22    /// <summary>
 23    /// Initializes a new instance of the <see cref="JsonWorkflowMaterializer"/> class.
 24    /// </summary>
 26625    public JsonWorkflowMaterializer(WorkflowDefinitionMapper workflowDefinitionMapper)
 26    {
 26627        _workflowDefinitionMapper = workflowDefinitionMapper;
 26628    }
 29
 30    /// <inheritdoc />
 31    public ValueTask<Workflow> MaterializeAsync(WorkflowDefinition definition, CancellationToken cancellationToken)
 32    {
 90133        var workflow = ToWorkflow(definition);
 90134        return new(workflow);
 35    }
 36
 90137    private Workflow ToWorkflow(WorkflowDefinition definition) => _workflowDefinitionMapper.Map(definition);
 38}