< Summary

Information
Class: Elsa.Scheduling.Activities.Delay
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Activities/Delay.cs
Line coverage
60%
Covered lines: 15
Uncovered lines: 10
Coverable lines: 25
Total lines: 113
Line coverage: 60%
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
.ctor(...)100%11100%
.ctor(...)100%210%
.ctor(...)100%210%
.ctor(...)100%210%
.ctor(...)100%11100%
.ctor(...)100%210%
get_TimeSpan()100%11100%
Execute(...)100%11100%
FromMilliseconds(...)100%11100%
FromSeconds(...)100%11100%
FromMinutes(...)100%11100%
FromHours(...)100%11100%
FromDays(...)100%11100%
Elsa.Workflows.IActivityPropertyDefaultValueProvider.GetDefaultValue(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Activities/Delay.cs

#LineLine coverage
 1using System.Reflection;
 2using System.Runtime.CompilerServices;
 3using Elsa.Expressions.Models;
 4using Elsa.Extensions;
 5using Elsa.Workflows;
 6using Elsa.Workflows.Attributes;
 7using Elsa.Workflows.Memory;
 8using Elsa.Workflows.Models;
 9
 10namespace Elsa.Scheduling.Activities;
 11
 12/// <summary>
 13/// Delay execution for the specified amount of time.
 14/// </summary>
 15[Activity("Elsa", "Scheduling", "Delay execution for the specified amount of time.")]
 16public class Delay : Activity, IActivityPropertyDefaultValueProvider
 17{
 18    /// <inheritdoc />
 29819    public Delay([CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
 20    {
 29821    }
 22
 23    /// <inheritdoc />
 24    public Delay(
 25        Func<ExpressionExecutionContext, TimeSpan> timeSpan,
 026        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(new Input<TimeSpan>(timeSpan
 27    {
 028    }
 29
 30    /// <inheritdoc />
 31    public Delay(
 32        Func<ExpressionExecutionContext, ValueTask<TimeSpan>> timeSpan,
 033        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : this(new Input<TimeSpan>(timeSpan
 34    {
 035    }
 36
 37    /// <inheritdoc />
 38    public Delay(
 39        Input<TimeSpan> timeSpan,
 040        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
 41    {
 042        TimeSpan = timeSpan;
 043    }
 44
 45    /// <inheritdoc />
 46    public Delay(
 47        TimeSpan timeSpan,
 13948        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
 49    {
 13950        TimeSpan = new Input<TimeSpan>(timeSpan);
 13951    }
 52
 53    /// <inheritdoc />
 54    public Delay(
 55        Variable<TimeSpan> timeSpan,
 056        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) : base(source, line)
 57    {
 058        TimeSpan = new Input<TimeSpan>(timeSpan);
 059    }
 60
 61    /// <summary>
 62    /// The amount of time to delay execution.
 63    /// </summary>
 64    [Input(
 65        Description = "The timespan to delay workflow execution.",
 66        DefaultValueProvider = typeof(Delay)
 67    )]
 58068    public Input<TimeSpan> TimeSpan { get; set; } = null!;
 69
 70    /// <inheritdoc />
 71    protected override void Execute(ActivityExecutionContext context)
 72    {
 2373        var timeSpan = context.ExpressionExecutionContext.Get(TimeSpan);
 2374        context.DelayFor(timeSpan);
 2375    }
 76
 77    /// <summary>
 78    /// Creates a new <see cref="Delay"/> from the specified number of milliseconds.
 79    /// </summary>
 80    public static Delay FromMilliseconds(
 81        double value,
 5682        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromMillisec
 83
 84    /// <summary>
 85    /// Creates a new <see cref="Delay"/> from the specified number of seconds.
 86    /// </summary>
 87    public static Delay FromSeconds(
 88        double value,
 2089        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromSeconds(
 90
 91    /// <summary>
 92    /// Creates a new <see cref="Delay"/> from the specified number of minutes.
 93    /// </summary>
 94    public static Delay FromMinutes(
 95        double value,
 296        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromMinutes(
 97
 98    /// <summary>
 99    /// Creates a new <see cref="Delay"/> from the specified number of hours.
 100    /// </summary>
 101    public static Delay FromHours(
 102        double value,
 2103        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromHours(va
 104
 105    /// <summary>
 106    /// Creates a new <see cref="Delay"/> from the specified number of days.
 107    /// </summary>
 108    public static Delay FromDays(
 109        double value,
 2110        [CallerFilePath] string? source = null, [CallerLineNumber] int? line = null) => new(System.TimeSpan.FromDays(val
 111
 268112    object IActivityPropertyDefaultValueProvider.GetDefaultValue(PropertyInfo property) => System.TimeSpan.FromMinutes(1
 113}