< Summary

Information
Class: Elsa.Alterations.Core.Stores.MemoryAlterationJobStore
Assembly: Elsa.Alterations.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Stores/MemoryAlterationJobStore.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 67
Line coverage: 0%
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%210%
SaveAsync(...)100%210%
SaveManyAsync(...)100%210%
FindAsync(...)100%210%
FindManyAsync(...)100%210%
FindManyIdsAsync(...)100%210%
CountAsync(...)100%210%
Filter(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Stores/MemoryAlterationJobStore.cs

#LineLine coverage
 1using Elsa.Alterations.Core.Contracts;
 2using Elsa.Alterations.Core.Entities;
 3using Elsa.Alterations.Core.Filters;
 4using Elsa.Common.Services;
 5
 6namespace Elsa.Alterations.Core.Stores;
 7
 8/// <summary>
 9/// A memory-based store for alteration jobs.
 10/// </summary>
 11public class MemoryAlterationJobStore : IAlterationJobStore
 12{
 13    private readonly MemoryStore<AlterationJob> _store;
 14
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="MemoryAlterationJobStore"/> class.
 17    /// </summary>
 018    public MemoryAlterationJobStore(MemoryStore<AlterationJob> store)
 19    {
 020        _store = store;
 021    }
 22
 23    /// <inheritdoc />
 24    public Task SaveAsync(AlterationJob job, CancellationToken cancellationToken = default)
 25    {
 026        _store.Save(job, x => x.Id);
 027        return Task.CompletedTask;
 28    }
 29
 30    /// <inheritdoc />
 31    public Task SaveManyAsync(IEnumerable<AlterationJob> jobs, CancellationToken cancellationToken = default)
 32    {
 033        _store.SaveMany(jobs, x => x.Id);
 034        return Task.CompletedTask;
 35    }
 36
 37    /// <inheritdoc />
 38    public Task<AlterationJob?> FindAsync(AlterationJobFilter filter, CancellationToken cancellationToken = default)
 39    {
 040        var entity = _store.Query(query => Filter(query, filter)).FirstOrDefault();
 041        return Task.FromResult(entity);
 42    }
 43
 44    /// <inheritdoc />
 45    public Task<IEnumerable<AlterationJob>> FindManyAsync(AlterationJobFilter filter, CancellationToken cancellationToke
 46    {
 047        var entities = _store.Query(query => Filter(query, filter)).ToList().AsEnumerable();
 048        return Task.FromResult(entities);
 49    }
 50
 51    /// <inheritdoc />
 52    public Task<IEnumerable<string>> FindManyIdsAsync(AlterationJobFilter filter, CancellationToken cancellationToken = 
 53    {
 054        var ids = _store.Query(query => Filter(query, filter)).Select(x => x.Id).ToList().AsEnumerable();
 055        return Task.FromResult(ids);
 56    }
 57
 58    /// <inheritdoc />
 59    public Task<long> CountAsync(AlterationJobFilter filter, CancellationToken cancellationToken = default)
 60    {
 061        var count = _store.Query(query => Filter(query, filter)).LongCount();
 062        return Task.FromResult(count);
 63    }
 64
 65
 066    private static IQueryable<AlterationJob> Filter(IQueryable<AlterationJob> query, AlterationJobFilter filter) => filt
 67}