< Summary

Information
Class: Elsa.Persistence.EFCore.Modules.Runtime.EFCoreBookmarkStore
Assembly: Elsa.Persistence.EFCore
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore/Modules/Runtime/BookmarkStore.cs
Line coverage
76%
Covered lines: 16
Uncovered lines: 5
Coverable lines: 21
Total lines: 64
Line coverage: 76.1%
Branch coverage
70%
Covered branches: 7
Total branches: 10
Branch coverage: 70%
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%11100%
SaveManyAsync()100%210%
FindAsync()100%210%
FindManyAsync()100%11100%
DeleteAsync()100%11100%
OnSaveAsync(...)75%44100%
OnLoadAsync(...)66.66%6685.71%

File(s)

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

#LineLine coverage
 1using Elsa.Workflows;
 2using Elsa.Workflows.Runtime;
 3using Elsa.Workflows.Runtime.Entities;
 4using Elsa.Workflows.Runtime.Filters;
 5using JetBrains.Annotations;
 6
 7namespace Elsa.Persistence.EFCore.Modules.Runtime;
 8
 9/// <summary>
 10/// An EF Core implementation of <see cref="IBookmarkStore"/>.
 11/// </summary>
 12[UsedImplicitly]
 35313public class EFCoreBookmarkStore(Store<RuntimeElsaDbContext, StoredBookmark> store, IPayloadSerializer serializer) : IBo
 14{
 15    /// <inheritdoc />
 16    public async ValueTask SaveAsync(StoredBookmark record, CancellationToken cancellationToken = default)
 17    {
 3618        await store.SaveAsync(record, s => s.Id, OnSaveAsync, cancellationToken);
 3619    }
 20
 21    /// <inheritdoc />
 22    public async ValueTask SaveManyAsync(IEnumerable<StoredBookmark> records, CancellationToken cancellationToken)
 23    {
 024        await store.SaveManyAsync(records, s => s.Id, OnSaveAsync, cancellationToken);
 025    }
 26
 27    /// <inheritdoc />
 28    public async ValueTask<StoredBookmark?> FindAsync(BookmarkFilter filter, CancellationToken cancellationToken = defau
 29    {
 030        return await store.FindAsync(filter.Apply, OnLoadAsync, filter.TenantAgnostic, cancellationToken);
 031    }
 32
 33    /// <inheritdoc />
 34    public async ValueTask<IEnumerable<StoredBookmark>> FindManyAsync(BookmarkFilter filter, CancellationToken cancellat
 35    {
 120636        return await store.QueryAsync(filter.Apply, OnLoadAsync, filter.TenantAgnostic, cancellationToken);
 120637    }
 38
 39    /// <inheritdoc />
 40    public async ValueTask<long> DeleteAsync(BookmarkFilter filter, CancellationToken cancellationToken = default)
 41    {
 4142        return await store.DeleteWhereAsync(filter.Apply, cancellationToken);
 4143    }
 44
 45    private ValueTask OnSaveAsync(RuntimeElsaDbContext dbContext, StoredBookmark entity, CancellationToken cancellationT
 46    {
 3647        dbContext.Entry(entity).Property("SerializedPayload").CurrentValue = entity.Payload != null ? serializer.Seriali
 3648        dbContext.Entry(entity).Property("SerializedMetadata").CurrentValue = entity.Metadata != null ? serializer.Seria
 3649        return default;
 50    }
 51
 52    private ValueTask OnLoadAsync(RuntimeElsaDbContext dbContext, StoredBookmark? entity, CancellationToken cancellation
 53    {
 9354        if (entity is null)
 055            return default;
 56
 9357        var payloadJson = dbContext.Entry(entity).Property<string>("SerializedPayload").CurrentValue;
 9358        var metadataJson = dbContext.Entry(entity).Property<string>("SerializedMetadata").CurrentValue;
 9359        entity.Payload = !string.IsNullOrEmpty(payloadJson) ? serializer.Deserialize(payloadJson) : null;
 9360        entity.Metadata = !string.IsNullOrEmpty(metadataJson) ? serializer.Deserialize<Dictionary<string, string>>(metad
 61
 9362        return default;
 63    }
 64}