< Summary

Information
Class: Elsa.Workflows.MemoryStorageDriver
Assembly: Elsa.Workflows.Core
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Services/MemoryStorageDriver.cs
Line coverage
11%
Covered lines: 1
Uncovered lines: 8
Coverable lines: 9
Total lines: 37
Line coverage: 11.1%
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%11100%
get_Priority()100%210%
get_Tags()100%210%
WriteAsync(...)100%210%
ReadAsync(...)0%620%
DeleteAsync(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Workflows.Core/Services/MemoryStorageDriver.cs

#LineLine coverage
 1using System.ComponentModel.DataAnnotations;
 2
 3namespace Elsa.Workflows;
 4
 5/// <summary>
 6/// A storage driver that stores objects in memory.
 7/// </summary>
 8[Display(Name = "Memory")]
 9public class MemoryStorageDriver : IStorageDriver
 10{
 42111    private readonly IDictionary<string, object> _dictionary = new Dictionary<string, object>();
 12    /// <inheritdoc />
 013    public double Priority => 0;
 14    /// <inheritdoc />
 015    public IEnumerable<string> Tags => [];
 16
 17    /// <inheritdoc />
 18    public ValueTask WriteAsync(string id, object value, StorageDriverContext context)
 19    {
 020        _dictionary[id] = value;
 021        return ValueTask.CompletedTask;
 22    }
 23
 24    /// <inheritdoc />
 25    public ValueTask<object?> ReadAsync(string id, StorageDriverContext context)
 26    {
 027        var value = _dictionary.TryGetValue(id, out var v) ? v : default;
 028        return new (value);
 29    }
 30
 31    /// <inheritdoc />
 32    public ValueTask DeleteAsync(string id, StorageDriverContext context)
 33    {
 034        _dictionary.Remove(id);
 035        return ValueTask.CompletedTask;
 36    }
 37}