< Summary

Information
Class: Elsa.Http.DownloadableContentHandlers.StringDownloadableContentHandler
Assembly: Elsa.Http
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/DownloadableContentHandlers/StringDownloadableContentHandler.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 3
Coverable lines: 3
Total lines: 21
Line coverage: 0%
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
GetSupportsContent(...)100%210%
GetDownloadable(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Http/DownloadableContentHandlers/StringDownloadableContentHandler.cs

#LineLine coverage
 1using System.Text;
 2using Elsa.Http.Abstractions;
 3using Elsa.Http.Contexts;
 4
 5namespace Elsa.Http.DownloadableContentHandlers;
 6
 7/// <summary>
 8/// Handles content that represents a downloadable string file.
 9/// </summary>
 10public class StringDownloadableContentHandler : DownloadableContentHandlerBase
 11{
 12    /// <inheritdoc />
 013    public override bool GetSupportsContent(object content) => content is string;
 14
 15    /// <inheritdoc />
 16    protected override Downloadable GetDownloadable(DownloadableContext context)
 17    {
 018        var stream = new MemoryStream(Encoding.UTF8.GetBytes((string)context.Content));
 019        return new(stream, "file.txt", "text/plain");
 20    }
 21}