< Summary

Information
Class: Elsa.Scheduling.Services.CronosCronParser
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Services/CronosCronParser.cs
Line coverage
100%
Covered lines: 6
Uncovered lines: 0
Coverable lines: 6
Total lines: 28
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
.ctor(...)100%11100%
GetNextOccurrence(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/Services/CronosCronParser.cs

#LineLine coverage
 1using Cronos;
 2using Elsa.Common;
 3
 4namespace Elsa.Scheduling.Services;
 5
 6/// <summary>
 7/// A cron parser that uses Cronos.
 8/// </summary>
 9public class CronosCronParser : ICronParser
 10{
 11    private readonly ISystemClock _systemClock;
 12
 13    /// <summary>
 14    /// Initializes a new instance of the <see cref="CronosCronParser"/> class.
 15    /// </summary>
 1916    public CronosCronParser(ISystemClock systemClock)
 17    {
 1918        _systemClock = systemClock;
 1919    }
 20
 21    /// <inheritdoc />
 22    public DateTimeOffset GetNextOccurrence(string expression)
 23    {
 2324        var parsedExpression = CronExpression.Parse(expression, CronFormat.IncludeSeconds);
 1625        var now = _systemClock.UtcNow;
 1626        return parsedExpression.GetNextOccurrence(now, TimeZoneInfo.Utc).GetValueOrDefault();
 27    }
 28}