< Summary

Information
Class: Elsa.Testing.Shared.Activities.TestContainer
Assembly: Elsa.Testing.Shared
File(s): /home/runner/work/elsa-core/elsa-core/src/common/Elsa.Testing.Shared/Activities/TestContainer.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 13
Coverable lines: 13
Total lines: 38
Line coverage: 0%
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
ScheduleChildrenAsync()100%210%
HandleItemAsync()0%620%
OnChildCompleted()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/common/Elsa.Testing.Shared/Activities/TestContainer.cs

#LineLine coverage
 1using Elsa.Workflows;
 2using Elsa.Workflows.Activities;
 3
 4namespace Elsa.Testing.Shared.Activities;
 5
 6/// <summary>
 7/// Concrete implementation of Container for testing that schedules children sequentially.
 8/// </summary>
 9public class TestContainer : Container
 10{
 11    private const string CurrentIndexProperty = "CurrentIndex";
 12
 13    protected override async ValueTask ScheduleChildrenAsync(ActivityExecutionContext context)
 14    {
 015        await HandleItemAsync(context);
 016    }
 17
 18    private async ValueTask HandleItemAsync(ActivityExecutionContext context)
 19    {
 020        var currentIndex = context.GetProperty<int>(CurrentIndexProperty);
 021        var childActivities = Activities.ToList();
 22
 023        if (currentIndex >= childActivities.Count)
 24        {
 025            await context.CompleteActivityAsync();
 026            return;
 27        }
 28
 029        var nextActivity = childActivities.ElementAt(currentIndex);
 030        await context.ScheduleActivityAsync(nextActivity, OnChildCompleted);
 031        context.UpdateProperty<int>(CurrentIndexProperty, x => x + 1);
 032    }
 33
 34    private async ValueTask OnChildCompleted(ActivityCompletedContext context)
 35    {
 036        await HandleItemAsync(context.TargetContext);
 037    }
 38}