< Summary

Information
Class: Elsa.Http.PortResolvers.SendHttpRequestActivityResolver
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/PortResolvers/SendHttpRequestActivityPortResolver.cs
Line coverage
13%
Covered lines: 2
Uncovered lines: 13
Coverable lines: 15
Total lines: 42
Line coverage: 13.3%
Branch coverage
0%
Covered branches: 0
Total branches: 8
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Priority()100%11100%
GetSupportsActivity(...)100%11100%
GetActivityPortsAsync(...)100%210%
GetPortsInternal()0%7280%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/PortResolvers/SendHttpRequestActivityPortResolver.cs

#LineLine coverage
 1using Elsa.Workflows;
 2using Elsa.Workflows.Models;
 3
 4namespace Elsa.Http.PortResolvers;
 5
 6/// <summary>
 7/// Returns a list of outbound activities for a given <see cref="SendHttpRequest"/> activity's expected status codes.
 8/// </summary>
 9public class SendHttpRequestActivityResolver : IActivityResolver
 10{
 11    /// <inheritdoc />
 32812    public int Priority => 0;
 13
 14    /// <inheritdoc />
 1354015    public bool GetSupportsActivity(IActivity activity) => activity is SendHttpRequest;
 16
 17
 18    /// <inheritdoc />
 19    public ValueTask<IEnumerable<ActivityPort>> GetActivityPortsAsync(IActivity activity, CancellationToken cancellation
 20    {
 021        var ports = GetPortsInternal(activity);
 022        return new(ports);
 23    }
 24
 25    private IEnumerable<ActivityPort> GetPortsInternal(IActivity activity)
 26    {
 027        var sendHttpRequest = (SendHttpRequest)activity;
 028        var cases = sendHttpRequest.ExpectedStatusCodes.Where(x => x.Activity != null);
 29
 030        foreach (var @case in cases)
 031            yield return ActivityPort.FromActivity(@case.Activity!, @case.StatusCode.ToString());
 32
 033        if (sendHttpRequest.Timeout != null)
 034            yield return ActivityPort.FromActivity(sendHttpRequest.Timeout, nameof(SendHttpRequest.Timeout));
 35
 036        if (sendHttpRequest.FailedToConnect != null)
 037            yield return ActivityPort.FromActivity(sendHttpRequest.FailedToConnect, nameof(SendHttpRequest.FailedToConne
 38
 039        if (sendHttpRequest.UnmatchedStatusCode != null)
 040            yield return ActivityPort.FromActivity(sendHttpRequest.UnmatchedStatusCode, nameof(SendHttpRequest.Unmatched
 041    }
 42}