< Summary

Information
Class: Elsa.Extensions.HttpActivityExecutionContextExtensions
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Extensions/HttpActivityExecutionContextExtensions.cs
Line coverage
71%
Covered lines: 10
Uncovered lines: 4
Coverable lines: 14
Total lines: 35
Line coverage: 71.4%
Branch coverage
20%
Covered branches: 2
Total branches: 10
Branch coverage: 20%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ParseContentAsync()50%2280%
GetHeaders(...)12.5%11862.5%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/Extensions/HttpActivityExecutionContextExtensions.cs

#LineLine coverage
 1using Elsa.Http;
 2using Elsa.Http.Contexts;
 3using Elsa.Workflows;
 4using Elsa.Workflows.Models;
 5
 6// ReSharper disable once CheckNamespace
 7namespace Elsa.Extensions;
 8
 9internal static class HttpActivityExecutionContextExtensions
 10{
 11    public static async Task<object?> ParseContentAsync(this ActivityExecutionContext context, Stream content, string co
 12    {
 13        var parsers = context.GetServices<IHttpContentParser>().OrderByDescending(x => x.Priority).ToList();
 20614        var httpResponseParserContext = new HttpResponseParserContext(content, contentType, returnType, headers, cancell
 81215        var contentParser = parsers.FirstOrDefault(x => x.GetSupportsContentType(httpResponseParserContext));
 16
 20617        if (contentParser == null)
 018            return null;
 19
 20620        return await contentParser.ReadAsync(httpResponseParserContext);
 20621    }
 22
 23    public static IEnumerable<KeyValuePair<string, string[]>> GetHeaders(this ActivityExecutionContext context, Input in
 24    {
 6825        var value = context.Get(input.MemoryBlockReference());
 26
 6827        return value switch
 6828        {
 6829            IDictionary<string, string[]> dictionary1 => dictionary1,
 030            IDictionary<string, string> dictionary2 => dictionary2.ToDictionary(x => x.Key, x => new[] { x.Value }),
 031            IDictionary<string, object> dictionary3 => dictionary3.ToDictionary(pair => pair.Key, pair => pair.Value is 
 032            _ => Array.Empty<KeyValuePair<string, string[]>>()
 6833        };
 34    }
 35}