< Summary

Information
Class: Elsa.Workflows.Runtime.Stores.MemoryActivityExecutionStore
Assembly: Elsa.Workflows.Runtime
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Stores/MemoryActivityExecutionStore.cs
Line coverage
29%
Covered lines: 8
Uncovered lines: 19
Coverable lines: 27
Total lines: 96
Line coverage: 29.6%
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
.ctor(...)100%11100%
SaveAsync(...)100%210%
SaveManyAsync(...)100%11100%
AddManyAsync(...)100%210%
FindAsync(...)100%11100%
FindManyAsync(...)100%210%
FindManyAsync(...)100%210%
FindManySummariesAsync()100%210%
FindManySummariesAsync()100%210%
CountAsync(...)100%210%
DeleteManyAsync(...)100%210%
Filter(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Runtime/Stores/MemoryActivityExecutionStore.cs

#LineLine coverage
 1using Elsa.Common.Services;
 2using Elsa.Extensions;
 3using Elsa.Workflows.Runtime.Entities;
 4using Elsa.Workflows.Runtime.Filters;
 5using Elsa.Workflows.Runtime.OrderDefinitions;
 6
 7namespace Elsa.Workflows.Runtime.Stores;
 8
 9/// <summary>
 10/// Stores activity execution records in memory.
 11/// </summary>
 12public class MemoryActivityExecutionStore : IActivityExecutionStore
 13{
 14    private readonly MemoryStore<ActivityExecutionRecord> _store;
 15
 16    /// <summary>
 17    /// Initializes a new instance of the <see cref="MemoryActivityExecutionStore"/> class.
 18    /// </summary>
 14119    public MemoryActivityExecutionStore(MemoryStore<ActivityExecutionRecord> store)
 20    {
 14121        _store = store;
 14122    }
 23
 24    /// <inheritdoc />
 25    public Task SaveAsync(ActivityExecutionRecord record, CancellationToken cancellationToken = default)
 26    {
 027        _store.Save(record, x => x.Id);
 028        return Task.CompletedTask;
 29    }
 30
 31    /// <inheritdoc />
 32    public Task SaveManyAsync(IEnumerable<ActivityExecutionRecord> records, CancellationToken cancellationToken = defaul
 33    {
 145334        _store.SaveMany(records, x => x.Id);
 14335        return Task.CompletedTask;
 36    }
 37
 38    /// <inheritdoc />
 39    public Task AddManyAsync(IEnumerable<ActivityExecutionRecord> records, CancellationToken cancellationToken = default
 40    {
 041        _store.AddMany(records, x => x.Id);
 042        return Task.CompletedTask;
 43    }
 44
 45    /// <inheritdoc />
 46    public Task<ActivityExecutionRecord?> FindAsync(ActivityExecutionRecordFilter filter, CancellationToken cancellation
 47    {
 1248        var result = _store.Query(query => Filter(query, filter)).FirstOrDefault();
 649        return Task.FromResult(result);
 50    }
 51
 52    /// <inheritdoc />
 53    public Task<IEnumerable<ActivityExecutionRecord>> FindManyAsync<TOrderBy>(ActivityExecutionRecordFilter filter, Acti
 54    {
 055        var result = _store.Query(query => Filter(query, filter).OrderBy(order)).ToList().AsEnumerable();
 056        return Task.FromResult(result);
 57    }
 58
 59    /// <inheritdoc />
 60    public Task<IEnumerable<ActivityExecutionRecord>> FindManyAsync(ActivityExecutionRecordFilter filter, CancellationTo
 61    {
 062        var result = _store.Query(query => Filter(query, filter)).ToList().AsEnumerable();
 063        return Task.FromResult(result);
 64    }
 65
 66    /// <inheritdoc />
 67    public async Task<IEnumerable<ActivityExecutionRecordSummary>> FindManySummariesAsync<TOrderBy>(ActivityExecutionRec
 68    {
 069        var entities = await FindManyAsync(filter, order, cancellationToken);
 070        return entities.Select(ActivityExecutionRecordSummary.FromRecord);
 071    }
 72
 73    /// <inheritdoc />
 74    public async Task<IEnumerable<ActivityExecutionRecordSummary>> FindManySummariesAsync(ActivityExecutionRecordFilter 
 75    {
 076        var entities = await FindManyAsync(filter, cancellationToken);
 077        return entities.Select(ActivityExecutionRecordSummary.FromRecord);
 078    }
 79
 80    /// <inheritdoc />
 81    public Task<long> CountAsync(ActivityExecutionRecordFilter filter, CancellationToken cancellationToken = default)
 82    {
 083        var count = _store.Query(query => Filter(query, filter)).LongCount();
 084        return Task.FromResult(count);
 85    }
 86
 87    /// <inheritdoc />
 88    public Task<long> DeleteManyAsync(ActivityExecutionRecordFilter filter, CancellationToken cancellationToken = defaul
 89    {
 090        var records = _store.Query(query => Filter(query, filter)).ToList();
 091        _store.DeleteMany(records, x => x.Id);
 092        return Task.FromResult(records.LongCount());
 93    }
 94
 695    private static IQueryable<ActivityExecutionRecord> Filter(IQueryable<ActivityExecutionRecord> queryable, ActivityExe
 96}