< Summary

Information
Class: Elsa.Http.ContentWriters.BinaryContentFactory
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/ContentWriters/BinaryContentFactory.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 23
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
get_SupportedContentTypes()100%210%
CreateHttpContent(...)0%2040%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/ContentWriters/BinaryContentFactory.cs

#LineLine coverage
 1using System.Net.Mime;
 2
 3namespace Elsa.Http.ContentWriters;
 4
 5/// <summary>
 6/// Creates a <see cref="HttpContent"/> object for application/octet-stream.
 7/// </summary>
 8public class BinaryContentFactory : IHttpContentFactory
 9{
 10    /// <inheritdoc />
 011    public IEnumerable<string> SupportedContentTypes => [MediaTypeNames.Application.Octet];
 12
 13    /// <inheritdoc />
 14    public HttpContent CreateHttpContent(object content, string contentType)
 15    {
 016        return content switch
 017        {
 018            byte[] bytes => new ByteArrayContent(bytes),
 019            Stream stream => new StreamContent(stream),
 020            _ => throw new NotSupportedException($"Content of type {content.GetType()} is not supported.")
 021        };
 22    }
 23}