< Summary

Information
Class: Elsa.Persistence.EFCore.Modules.Runtime.EFBookmarkQueueStore
Assembly: Elsa.Persistence.EFCore
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore/Modules/Runtime/BookmarkQueueStore.cs
Line coverage
60%
Covered lines: 14
Uncovered lines: 9
Coverable lines: 23
Total lines: 80
Line coverage: 60.8%
Branch coverage
50%
Covered branches: 3
Total branches: 6
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
SaveAsync(...)100%210%
AddAsync(...)100%11100%
FindAsync(...)100%210%
FindManyAsync()100%210%
PageAsync()100%22100%
PageAsync()100%210%
DeleteAsync()100%11100%
OnSaveAsync(...)50%22100%
OnLoadAsync(...)50%4480%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore/Modules/Runtime/BookmarkQueueStore.cs

#LineLine coverage
 1using Elsa.Common.Models;
 2using Elsa.Extensions;
 3using Elsa.Workflows;
 4using Elsa.Workflows.Runtime;
 5using Elsa.Workflows.Runtime.Entities;
 6using Elsa.Workflows.Runtime.Filters;
 7using Elsa.Workflows.Runtime.Options;
 8using Elsa.Workflows.Runtime.OrderDefinitions;
 9using JetBrains.Annotations;
 10using Open.Linq.AsyncExtensions;
 11
 12namespace Elsa.Persistence.EFCore.Modules.Runtime;
 13
 14/// <summary>
 15/// An EF Core implementation of <see cref="IBookmarkQueueStore"/>.
 16/// </summary>
 17[UsedImplicitly]
 35118public class EFBookmarkQueueStore(Store<RuntimeElsaDbContext, BookmarkQueueItem> store, IPayloadSerializer serializer) :
 19{
 20    /// <inheritdoc />
 21    public Task SaveAsync(BookmarkQueueItem record, CancellationToken cancellationToken = default)
 22    {
 023        return store.SaveAsync(record, s => s.Id, OnSaveAsync, cancellationToken);
 24    }
 25
 26    /// <inheritdoc />
 27    public Task AddAsync(BookmarkQueueItem record, CancellationToken cancellationToken = default)
 28    {
 4829        return store.AddAsync(record, OnSaveAsync, cancellationToken);
 30    }
 31
 32    /// <inheritdoc />
 33    public Task<BookmarkQueueItem?> FindAsync(BookmarkQueueFilter filter, CancellationToken cancellationToken = default)
 34    {
 035        return store.FindAsync(filter.Apply, OnLoadAsync, cancellationToken);
 36    }
 37
 38    /// <inheritdoc />
 39    public async Task<IEnumerable<BookmarkQueueItem>> FindManyAsync(BookmarkQueueFilter filter, CancellationToken cancel
 40    {
 041        return await store.QueryAsync(filter.Apply, OnLoadAsync, filter.TenantAgnostic, cancellationToken);
 042    }
 43
 44    public async Task<Page<BookmarkQueueItem>> PageAsync<TOrderBy>(PageArgs pageArgs, BookmarkQueueItemOrder<TOrderBy> o
 45    {
 7646        var count = await store.QueryAsync(queryable => queryable, cancellationToken).LongCount();
 7647        var results = await store.QueryAsync(queryable => queryable.OrderBy(orderBy).Paginate(pageArgs), OnLoadAsync, ca
 3848        return new(results, count);
 3849    }
 50
 51    public async Task<Page<BookmarkQueueItem>> PageAsync<TOrderBy>(PageArgs pageArgs, BookmarkQueueFilter filter, Bookma
 52    {
 053        var count = await store.QueryAsync(filter.Apply, cancellationToken).LongCount();
 054        var results = await store.QueryAsync(queryable => filter.Apply(queryable).OrderBy(orderBy).Paginate(pageArgs), O
 055        return new(results, count);
 056    }
 57
 58    /// <inheritdoc />
 59    public async Task<long> DeleteAsync(BookmarkQueueFilter filter, CancellationToken cancellationToken = default)
 60    {
 1561        return await store.DeleteWhereAsync(filter.Apply, cancellationToken);
 1562    }
 63
 64    private ValueTask OnSaveAsync(RuntimeElsaDbContext dbContext, BookmarkQueueItem entity, CancellationToken cancellati
 65    {
 4866        dbContext.Entry(entity).Property("SerializedOptions").CurrentValue = entity.Options != null ? serializer.Seriali
 4867        return default;
 68    }
 69
 70    private ValueTask OnLoadAsync(RuntimeElsaDbContext dbContext, BookmarkQueueItem? entity, CancellationToken cancellat
 71    {
 109772        if (entity is null)
 073            return default;
 74
 109775        var optionsJson = dbContext.Entry(entity).Property<string>("SerializedOptions").CurrentValue;
 109776        entity.Options = !string.IsNullOrEmpty(optionsJson) ? serializer.Deserialize<ResumeBookmarkOptions>(optionsJson)
 77
 109778        return default;
 79    }
 80}