< Summary

Information
Class: Elsa.KeyValues.Stores.MemoryKeyValueStore
Assembly: Elsa.KeyValues
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.KeyValues/Stores/MemoryKeyValueStore.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 11
Coverable lines: 11
Total lines: 50
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%
FindManyAsync(...)100%210%
DeleteAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.KeyValues/Stores/MemoryKeyValueStore.cs

#LineLine coverage
 1using Elsa.Common.Services;
 2using Elsa.KeyValues.Contracts;
 3using Elsa.KeyValues.Entities;
 4using Elsa.KeyValues.Models;
 5
 6namespace Elsa.KeyValues.Stores;
 7
 8/// <summary>
 9/// Stores key value records in memory.
 10/// </summary>
 11public class MemoryKeyValueStore : IKeyValueStore
 12{
 13    private readonly MemoryStore<SerializedKeyValuePair> _store;
 14
 15    /// <summary>
 16    /// Initializes a new instance of the <see cref="MemoryKeyValueStore"/> class.
 17    /// </summary>
 018    public MemoryKeyValueStore(MemoryStore<SerializedKeyValuePair> store)
 19    {
 020        _store = store;
 021    }
 22
 23    /// <inheritdoc />
 24    public Task SaveAsync(SerializedKeyValuePair keyValuePair, CancellationToken cancellationToken)
 25    {
 026        _store.Save(keyValuePair, kv => kv.Id);
 027        return Task.CompletedTask;
 28    }
 29
 30    /// <inheritdoc />
 31    public Task<SerializedKeyValuePair?> FindAsync(KeyValueFilter filter, CancellationToken cancellationToken)
 32    {
 033        var result = _store.Query(filter.Apply).FirstOrDefault();
 034        return Task.FromResult(result);
 35    }
 36
 37    /// <inheritdoc />
 38    public Task<IEnumerable<SerializedKeyValuePair>> FindManyAsync(KeyValueFilter filter, CancellationToken cancellation
 39    {
 040        var result = _store.Query(filter.Apply);
 041        return Task.FromResult(result);
 42    }
 43
 44    /// <inheritdoc />
 45    public Task DeleteAsync(string key, CancellationToken cancellationToken)
 46    {
 047        _store.DeleteWhere(x => x.Key == key);
 048        return Task.CompletedTask;
 49    }
 50}