< Summary

Information
Class: Elsa.Http.UIHints.HttpContentTypeOptionsProvider
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/UIHints/HttpContentTypeOptionsProvider.cs
Line coverage
100%
Covered lines: 7
Uncovered lines: 0
Coverable lines: 7
Total lines: 32
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%
GetItemsAsync(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/UIHints/HttpContentTypeOptionsProvider.cs

#LineLine coverage
 1using System.Reflection;
 2using Elsa.Http.ContentWriters;
 3using Elsa.Workflows.UIHints.Dropdown;
 4
 5namespace Elsa.Http.UIHints;
 6
 7/// <summary>
 8/// Provides options for the <see cref="SendHttpRequest"/> activity's <see cref="SendHttpRequestBase.ContentType"/> prop
 9/// </summary>
 10public class HttpContentTypeOptionsProvider : DropDownOptionsProviderBase
 11{
 12    private readonly IEnumerable<IHttpContentFactory> _httpContentFactories;
 13
 14    /// <summary>
 15    /// Creates a new instance of the <see cref="HttpContentTypeOptionsProvider"/> class.
 16    /// </summary>
 112217    public HttpContentTypeOptionsProvider(IEnumerable<IHttpContentFactory> httpContentFactories)
 18    {
 112219        _httpContentFactories = httpContentFactories;
 112220    }
 21
 22    /// <inheritdoc />
 23    protected override ValueTask<ICollection<SelectListItem>> GetItemsAsync(PropertyInfo propertyInfo, object? context, 
 24    {
 56025        var contentTypes = _httpContentFactories.SelectMany(x => x.SupportedContentTypes).Distinct().OrderBy(x => x).ToA
 4026        var selectListItems = new List<SelectListItem> { new("", "") };
 27
 40028        selectListItems.AddRange(contentTypes.Select(x => new SelectListItem(x, x)));
 29
 4030        return new(selectListItems);
 31    }
 32}