< Summary

Information
Class: Elsa.Http.ContentWriters.TextContentFactory
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/ContentWriters/TextContentFactory.cs
Line coverage
90%
Covered lines: 9
Uncovered lines: 1
Coverable lines: 10
Total lines: 29
Line coverage: 90%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_SupportedContentTypes()100%11100%
CreateHttpContent(...)50%4475%

File(s)

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

#LineLine coverage
 1using System.Net.Mime;
 2using System.Text;
 3
 4namespace Elsa.Http.ContentWriters;
 5
 6/// <summary>
 7/// Creates a <see cref="StringContent"/> object for text/plain, text/richtext and text/html content types.
 8/// </summary>
 9public class TextContentFactory : IHttpContentFactory
 10{
 11    /// <inheritdoc />
 4512    public IEnumerable<string> SupportedContentTypes => new[]
 4513    {
 4514        MediaTypeNames.Text.Plain,
 4515        MediaTypeNames.Text.RichText,
 4516        MediaTypeNames.Text.Html,
 4517    };
 18
 19    /// <inheritdoc />
 20    public HttpContent CreateHttpContent(object content, string contentType)
 21    {
 522        var text = content as string ?? content.ToString();
 23
 524        if (string.IsNullOrWhiteSpace(contentType))
 025            contentType = MediaTypeNames.Text.Plain;
 26
 527        return new RawStringContent(text!, Encoding.UTF8, contentType);
 28    }
 29}