< Summary

Information
Class: Elsa.Scheduling.TriggerPayloadValidators.CronTriggerPayloadValidator
Assembly: Elsa.Scheduling
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/TriggerPayloadValidators/CronTriggerPayloadValidator.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 30
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%
ValidateAsync(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Scheduling/TriggerPayloadValidators/CronTriggerPayloadValidator.cs

#LineLine coverage
 1using Cronos;
 2using Elsa.Scheduling.Bookmarks;
 3using Elsa.Workflows.Activities;
 4using Elsa.Workflows.Management.Models;
 5using Elsa.Workflows.Runtime.Contracts;
 6using Elsa.Workflows.Runtime.Entities;
 7
 8namespace Elsa.Scheduling.TriggerPayloadValidators;
 9
 210public class CronTriggerPayloadValidator(ICronParser cronParser) : ITriggerPayloadValidator<CronTriggerPayload>
 11{
 12    public Task ValidateAsync(
 13        CronTriggerPayload payload,
 14        Workflow workflow,
 15        StoredTrigger trigger,
 16        ICollection<WorkflowValidationError> validationErrors,
 17        CancellationToken cancellationToken)
 18    {
 19        try
 20        {
 421            cronParser.GetNextOccurrence(payload.CronExpression);
 222        }
 223        catch (CronFormatException ex)
 24        {
 225            validationErrors.Add(new("Error when parsing cron expression: " + ex.Message,
 226                trigger.ActivityId));
 227        }
 428        return Task.CompletedTask;
 29    }
 30}