< Summary

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

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Alterations.Core/Stores/MemoryAlterationPlanStore.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 plans.
 10/// </summary>
 11public class MemoryAlterationPlanStore : IAlterationPlanStore
 12{
 13    private readonly MemoryStore<AlterationPlan> _store;
 14
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="MemoryAlterationPlanStore"/> class.
 17    /// </summary>
 018    public MemoryAlterationPlanStore(MemoryStore<AlterationPlan> store)
 19    {
 020        _store = store;
 021    }
 22
 23    /// <inheritdoc />
 24    public Task SaveAsync(AlterationPlan plan, CancellationToken cancellationToken = default)
 25    {
 026        _store.Save(plan, x => x.Id);
 027        return Task.CompletedTask;
 28    }
 29
 30    /// <inheritdoc />
 31    public Task<AlterationPlan?> FindAsync(AlterationPlanFilter filter, CancellationToken cancellationToken = default)
 32    {
 033        var entity = _store.Query(query => Filter(query, filter)).FirstOrDefault();
 034        return Task.FromResult(entity);
 35    }
 36
 37    /// <inheritdoc />
 38    public Task<long> CountAsync(AlterationPlanFilter filter, CancellationToken cancellationToken = default)
 39    {
 040        var count = _store.Query(query => Filter(query, filter)).LongCount();
 041        return Task.FromResult(count);
 42    }
 43
 044    private static IQueryable<AlterationPlan> Filter(IQueryable<AlterationPlan> query, AlterationPlanFilter filter) => f
 45}