< Summary

Information
Class: Elsa.Workflows.Models.NamedTriggerPayload
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Models/NamedTriggerPayload.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 40
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 4
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)0%2040%
get_Name()100%210%
get_Payload()100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Models/NamedTriggerPayload.cs

#LineLine coverage
 1namespace Elsa.Workflows.Models;
 2
 3/// <summary>
 4/// A trigger payload that carries its own stimulus name.
 5/// </summary>
 6/// <remarks>
 7/// Return instances of this type from <see cref="ITrigger.GetTriggerPayloadsAsync"/> when a single trigger needs to reg
 8/// more than one stimulus name. The wrapper is unwrapped during indexing: the stored trigger's name and hash are derive
 9/// and its payload from <see cref="Payload"/>. Payloads that are not wrapped are named using <see cref="TriggerIndexing
 10/// </remarks>
 11public record NamedTriggerPayload
 12{
 13    /// <summary>
 14    /// Initializes a new instance of the <see cref="NamedTriggerPayload"/> class.
 15    /// </summary>
 16    /// <param name="name">The stimulus name to register the payload under.</param>
 17    /// <param name="payload">The payload to register.</param>
 018    public NamedTriggerPayload(string name, object payload)
 19    {
 020        if (string.IsNullOrWhiteSpace(name))
 021            throw new ArgumentException("A stimulus name is required.", nameof(name));
 22
 023        if (payload is NamedTriggerPayload)
 024            throw new ArgumentException("A NamedTriggerPayload cannot wrap another NamedTriggerPayload.", nameof(payload
 25
 026        Name = name;
 027        Payload = payload;
 028    }
 29
 30    /// <summary>
 31    /// The stimulus name to register the payload under. Publishers of this stimulus compute their hash from this same n
 32    /// </summary>
 033    public string Name { get; }
 34
 35    /// <summary>
 36    /// The payload to register. This is what gets stored; the wrapper itself never is, since the constructor refuses to
 37    /// <see cref="NamedTriggerPayload"/>.
 38    /// </summary>
 039    public object Payload { get; }
 40}