< Summary

Information
Class: Elsa.Workflows.Management.Stores.MemoryWorkflowDefinitionStore
Assembly: Elsa.Workflows.Management
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Stores/MemoryWorkflowDefinitionStore.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 41
Coverable lines: 41
Total lines: 141
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
FindAsync(...)100%210%
FindAsync(...)100%210%
FindManyAsync(...)100%210%
FindManyAsync(...)100%210%
FindManyAsync(...)100%210%
FindManyAsync(...)100%210%
FindSummariesAsync(...)100%210%
FindSummariesAsync(...)100%210%
FindSummariesAsync(...)100%210%
FindSummariesAsync(...)100%210%
FindLastVersionAsync(...)100%210%
SaveAsync(...)100%210%
SaveManyAsync(...)100%210%
DeleteAsync(...)100%210%
AnyAsync(...)100%210%
CountDistinctAsync(...)100%210%
GetIsNameUnique(...)0%620%
Filter(...)100%210%
GetId(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Management/Stores/MemoryWorkflowDefinitionStore.cs

#LineLine coverage
 1using Elsa.Common.Models;
 2using Elsa.Common.Services;
 3using Elsa.Extensions;
 4using Elsa.Workflows.Management.Entities;
 5using Elsa.Workflows.Management.Filters;
 6using Elsa.Workflows.Management.Models;
 7
 8namespace Elsa.Workflows.Management.Stores;
 9
 10/// <summary>
 11/// A memory implementation of <see cref="IWorkflowDefinitionStore"/>.
 12/// </summary>
 013public class MemoryWorkflowDefinitionStore(MemoryStore<WorkflowDefinition> store) : IWorkflowDefinitionStore
 14{
 15    /// <inheritdoc />
 16    public Task<WorkflowDefinition?> FindAsync(WorkflowDefinitionFilter filter, CancellationToken cancellationToken = de
 17    {
 018        var result = store.Query(query => Filter(query, filter)).FirstOrDefault();
 019        return Task.FromResult(result);
 20    }
 21
 22    /// <inheritdoc />
 23    public Task<WorkflowDefinition?> FindAsync<TOrderBy>(WorkflowDefinitionFilter filter, WorkflowDefinitionOrder<TOrder
 24    {
 025        var result = store.Query(query => Filter(query, filter).OrderBy(order)).FirstOrDefault();
 026        return Task.FromResult(result);
 27    }
 28
 29    /// <inheritdoc />
 30    public Task<Page<WorkflowDefinition>> FindManyAsync(WorkflowDefinitionFilter filter, PageArgs pageArgs, Cancellation
 31    {
 032        var count = store.Query(query => Filter(query, filter)).LongCount();
 033        var result = store.Query(query => Filter(query, filter).Paginate(pageArgs)).ToList();
 034        return Task.FromResult(Page.Of(result, count));
 35    }
 36
 37    /// <inheritdoc />
 38    public Task<Page<WorkflowDefinition>> FindManyAsync<TOrderBy>(WorkflowDefinitionFilter filter, WorkflowDefinitionOrd
 39    {
 040        var count = store.Query(query => Filter(query, filter).OrderBy(order)).LongCount();
 041        var result = store.Query(query => Filter(query, filter).Paginate(pageArgs)).ToList();
 042        return Task.FromResult(Page.Of(result, count));
 43    }
 44
 45    /// <inheritdoc />
 46    public Task<IEnumerable<WorkflowDefinition>> FindManyAsync(WorkflowDefinitionFilter filter, CancellationToken cancel
 47    {
 048        var result = store.Query(query => Filter(query, filter)).ToList().AsEnumerable();
 049        return Task.FromResult(result);
 50    }
 51
 52    /// <inheritdoc />
 53    public Task<IEnumerable<WorkflowDefinition>> FindManyAsync<TOrderBy>(WorkflowDefinitionFilter filter, WorkflowDefini
 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<Page<WorkflowDefinitionSummary>> FindSummariesAsync(WorkflowDefinitionFilter filter, PageArgs pageArgs, 
 61    {
 062        var count = store.Query(query => Filter(query, filter)).LongCount();
 063        var result = store.Query(query => Filter(query, filter).Paginate(pageArgs)).Select(WorkflowDefinitionSummary.Fro
 064        return Task.FromResult(Page.Of(result, count));
 65    }
 66
 67    /// <inheritdoc />
 68    public Task<Page<WorkflowDefinitionSummary>> FindSummariesAsync<TOrderBy>(WorkflowDefinitionFilter filter, WorkflowD
 69    {
 070        var count = store.Query(query => Filter(query, filter).OrderBy(order)).LongCount();
 071        var result = store.Query(query => Filter(query, filter).Paginate(pageArgs)).Select(WorkflowDefinitionSummary.Fro
 072        return Task.FromResult(Page.Of(result, count));
 73    }
 74
 75    /// <inheritdoc />
 76    public Task<IEnumerable<WorkflowDefinitionSummary>> FindSummariesAsync(WorkflowDefinitionFilter filter, Cancellation
 77    {
 078        var result = store.Query(query => Filter(query, filter)).Select(WorkflowDefinitionSummary.FromDefinition).ToList
 079        return Task.FromResult(result);
 80    }
 81
 82    /// <inheritdoc />
 83    public Task<IEnumerable<WorkflowDefinitionSummary>> FindSummariesAsync<TOrderBy>(WorkflowDefinitionFilter filter, Wo
 84    {
 085        var result = store.Query(query => Filter(query, filter).OrderBy(order)).Select(WorkflowDefinitionSummary.FromDef
 086        return Task.FromResult(result);
 87    }
 88
 89    /// <inheritdoc />
 90    public Task<WorkflowDefinition?> FindLastVersionAsync(WorkflowDefinitionFilter filter, CancellationToken cancellatio
 91    {
 092        var result = store.Query(query => Filter(query, filter)).MaxBy(x => x.Version);
 093        return Task.FromResult(result);
 94    }
 95
 96    /// <inheritdoc />
 97    public Task SaveAsync(WorkflowDefinition definition, CancellationToken cancellationToken = default)
 98    {
 099        store.Save(definition, GetId);
 0100        return Task.CompletedTask;
 101    }
 102
 103    /// <inheritdoc />
 104    public Task SaveManyAsync(IEnumerable<WorkflowDefinition> definitions, CancellationToken cancellationToken = default
 105    {
 0106        store.SaveMany(definitions, GetId);
 0107        return Task.CompletedTask;
 108    }
 109
 110    /// <inheritdoc />
 111    public Task<long> DeleteAsync(WorkflowDefinitionFilter filter, CancellationToken cancellationToken = default)
 112    {
 0113        var workflowDefinitionIds = store.Query(query => Filter(query, filter)).Select(x => x.DefinitionId).Distinct().T
 0114        store.DeleteWhere(x => workflowDefinitionIds.Contains(x.DefinitionId));
 0115        return Task.FromResult(workflowDefinitionIds.LongCount());
 116    }
 117
 118    /// <inheritdoc />
 119    public Task<bool> AnyAsync(WorkflowDefinitionFilter filter, CancellationToken cancellationToken = default)
 120    {
 0121        var exists = store.Query(query => Filter(query, filter)).Any();
 0122        return Task.FromResult(exists);
 123    }
 124
 125    /// <inheritdoc />
 126    public Task<long> CountDistinctAsync(CancellationToken cancellationToken = default)
 127    {
 0128        return Task.FromResult(store.Count(x => true, x => x.DefinitionId));
 129    }
 130
 131    /// <inheritdoc />
 132    public Task<bool> GetIsNameUnique(string name, string? definitionId = default, CancellationToken cancellationToken =
 133    {
 0134        var exists = store.Any(x => x.Name == name && x.DefinitionId != definitionId);
 0135        return Task.FromResult(!exists);
 136    }
 137
 0138    private IQueryable<WorkflowDefinition> Filter(IQueryable<WorkflowDefinition> queryable, WorkflowDefinitionFilter fil
 139
 0140    private string GetId(WorkflowDefinition workflowDefinition) => workflowDefinition.Id;
 141}

Methods/Properties

.ctor(Elsa.Common.Services.MemoryStore`1<Elsa.Workflows.Management.Entities.WorkflowDefinition>)
FindAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,System.Threading.CancellationToken)
FindAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,Elsa.Workflows.Management.Filters.WorkflowDefinitionOrder`1<TOrderBy>,System.Threading.CancellationToken)
FindManyAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,Elsa.Common.Models.PageArgs,System.Threading.CancellationToken)
FindManyAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,Elsa.Workflows.Management.Filters.WorkflowDefinitionOrder`1<TOrderBy>,Elsa.Common.Models.PageArgs,System.Threading.CancellationToken)
FindManyAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,System.Threading.CancellationToken)
FindManyAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,Elsa.Workflows.Management.Filters.WorkflowDefinitionOrder`1<TOrderBy>,System.Threading.CancellationToken)
FindSummariesAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,Elsa.Common.Models.PageArgs,System.Threading.CancellationToken)
FindSummariesAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,Elsa.Workflows.Management.Filters.WorkflowDefinitionOrder`1<TOrderBy>,Elsa.Common.Models.PageArgs,System.Threading.CancellationToken)
FindSummariesAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,System.Threading.CancellationToken)
FindSummariesAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,Elsa.Workflows.Management.Filters.WorkflowDefinitionOrder`1<TOrderBy>,System.Threading.CancellationToken)
FindLastVersionAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,System.Threading.CancellationToken)
SaveAsync(Elsa.Workflows.Management.Entities.WorkflowDefinition,System.Threading.CancellationToken)
SaveManyAsync(System.Collections.Generic.IEnumerable`1<Elsa.Workflows.Management.Entities.WorkflowDefinition>,System.Threading.CancellationToken)
DeleteAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,System.Threading.CancellationToken)
AnyAsync(Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter,System.Threading.CancellationToken)
CountDistinctAsync(System.Threading.CancellationToken)
GetIsNameUnique(System.String,System.String,System.Threading.CancellationToken)
Filter(System.Linq.IQueryable`1<Elsa.Workflows.Management.Entities.WorkflowDefinition>,Elsa.Workflows.Management.Filters.WorkflowDefinitionFilter)
GetId(Elsa.Workflows.Management.Entities.WorkflowDefinition)