< Summary

Information
Class: Elsa.Workflows.Runtime.BookmarkExtensions
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Extensions/BookmarkExtensions.cs
Line coverage
60%
Covered lines: 12
Uncovered lines: 8
Coverable lines: 20
Total lines: 49
Line coverage: 60%
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
ToBookmarkInfo(...)100%210%
ToBookmarkInfos(...)100%210%
MapBookmarks(...)100%210%
MapBookmark(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Extensions/BookmarkExtensions.cs

#LineLine coverage
 1using Elsa.Workflows.Models;
 2using Elsa.Workflows.Runtime.Entities;
 3
 4namespace Elsa.Workflows.Runtime;
 5
 6/// <summary>
 7/// Contains extension methods for <see cref="Bookmark"/>.
 8/// </summary>
 9public static class BookmarkExtensions
 10{
 11    /// <summary>
 12    /// Converts a <see cref="Bookmark"/> to a <see cref="BookmarkInfo"/>.
 13    /// </summary>
 014    public static BookmarkInfo ToBookmarkInfo(this Bookmark source) => new()
 015    {
 016        Hash = source.Hash,
 017        Id = source.Id,
 018        Name = source.Name
 019    };
 20
 21    /// <summary>
 22    /// Converts a collection of <see cref="Bookmark"/> to a collection of <see cref="BookmarkInfo"/>.
 23    /// </summary>
 24    public static IEnumerable<BookmarkInfo> ToBookmarkInfos(this IEnumerable<Bookmark> source)
 25    {
 026        return source.Select(ToBookmarkInfo);
 27    }
 28
 29    public static IEnumerable<StoredBookmark> MapBookmarks(this WorkflowExecutionContext workflowExecutionContext, IEnum
 30    {
 031        return bookmarks.Select(workflowExecutionContext.MapBookmark);
 32    }
 33
 34    public static StoredBookmark MapBookmark(this WorkflowExecutionContext workflowExecutionContext, Bookmark bookmark)
 35    {
 5736        return new StoredBookmark
 5737        {
 5738            Id = bookmark.Id,
 5739            Name = bookmark.Name,
 5740            Hash = bookmark.Hash,
 5741            WorkflowInstanceId = workflowExecutionContext.Id,
 5742            CreatedAt = bookmark.CreatedAt,
 5743            ActivityInstanceId = bookmark.ActivityInstanceId,
 5744            CorrelationId = workflowExecutionContext.CorrelationId,
 5745            Payload = bookmark.Payload,
 5746            Metadata = bookmark.Metadata
 5747        };
 48    }
 49}