< Summary

Information
Class: Elsa.Identity.Services.MemoryApplicationStore
Assembly: Elsa.Identity
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Services/MemoryApplicationStore.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 11
Coverable lines: 11
Total lines: 46
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%
DeleteAsync(...)100%210%
FindAsync(...)100%210%
Filter(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Identity/Services/MemoryApplicationStore.cs

#LineLine coverage
 1using Elsa.Common.Services;
 2using Elsa.Identity.Contracts;
 3using Elsa.Identity.Entities;
 4using Elsa.Identity.Models;
 5
 6namespace Elsa.Identity.Services;
 7
 8/// <summary>
 9/// Represents an in-memory application store.
 10/// </summary>
 11public class MemoryApplicationStore : IApplicationStore
 12{
 13    private readonly MemoryStore<Application> _store;
 14
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="MemoryApplicationStore"/> class.
 17    /// </summary>
 018    public MemoryApplicationStore(MemoryStore<Application> store)
 19    {
 020        _store = store;
 021    }
 22
 23    /// <inheritdoc />
 24    public Task SaveAsync(Application application, CancellationToken cancellationToken = default)
 25    {
 026        _store.Save(application, x => x.Id);
 027        return Task.CompletedTask;
 28    }
 29
 30    /// <inheritdoc />
 31    public Task DeleteAsync(ApplicationFilter filter, CancellationToken cancellationToken = default)
 32    {
 033        var ids = _store.Query(query => Filter(query, filter)).Select(x => x.Id).Distinct().ToList();
 034        _store.DeleteWhere(x => ids.Contains(x.Id));
 035        return Task.CompletedTask;
 36    }
 37
 38    /// <inheritdoc />
 39    public Task<Application?> FindAsync(ApplicationFilter filter, CancellationToken cancellationToken = default)
 40    {
 041        var result = _store.Query(query => Filter(query, filter)).FirstOrDefault();
 042        return Task.FromResult(result);
 43    }
 44
 045    private IQueryable<Application> Filter(IQueryable<Application> queryable, ApplicationFilter filter) => filter.Apply(
 46}