• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

loresoft / EntityFrameworkCore.Generator / 27730465225

18 Jun 2026 01:21AM UTC coverage: 74.693% (+19.8%) from 54.885%
27730465225

push

github

pwelter34
update tests

922 of 1609 branches covered (57.3%)

Branch coverage included in aggregate %.

7 of 7 new or added lines in 2 files covered. (100.0%)

230 existing lines in 23 files now uncovered.

4007 of 4990 relevant lines covered (80.3%)

1258.69 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/EntityFrameworkCore.Generator.Core/SecretsStore.cs
1
using System.Text.Json;
2

3
using EntityFrameworkCore.Generator.Extensions;
4

5
using Microsoft.Extensions.Configuration;
6
using Microsoft.Extensions.Configuration.UserSecrets;
7

8
namespace EntityFrameworkCore.Generator;
9

10
public class SecretsStore
11
{
12
    private readonly string _secretsFilePath;
13
    private readonly IDictionary<string, string?> _secrets;
14

UNCOV
15
    public SecretsStore(string userSecretsId)
×
16
    {
UNCOV
17
        if (string.IsNullOrEmpty(userSecretsId))
×
UNCOV
18
            throw new ArgumentException("Value cannot be null or empty.", nameof(userSecretsId));
×
19

UNCOV
20
        _secretsFilePath = PathHelper.GetSecretsPathFromSecretsId(userSecretsId);
×
21

22
        // workaround bug in configuration
UNCOV
23
        var secretDir = Path.GetDirectoryName(_secretsFilePath);
×
24
        if (secretDir.HasValue() && !Directory.Exists(secretDir))
×
UNCOV
25
            Directory.CreateDirectory(secretDir);
×
26

27
        _secrets = Load(userSecretsId);
×
28
    }
×
29

UNCOV
30
    public string? this[string key] => _secrets[key];
×
31

32
    public int Count => _secrets.Count;
×
33

34
    public bool ContainsKey(string key) => _secrets.ContainsKey(key);
×
35

36
    public IEnumerable<KeyValuePair<string, string?>> AsEnumerable() => _secrets;
×
37

38
    public void Clear() => _secrets.Clear();
×
39

40
    public void Set(string key, string value) => _secrets[key] = value;
×
41

42
    public void Remove(string key)
43
    {
44
        _secrets.Remove(key);
×
UNCOV
45
    }
×
46

47
    public virtual void Save()
48
    {
49
        var secretDir = Path.GetDirectoryName(_secretsFilePath);
×
UNCOV
50
        if (secretDir.HasValue() && !Directory.Exists(secretDir))
×
UNCOV
51
            Directory.CreateDirectory(secretDir);
×
52

53
        var options = new JsonWriterOptions
×
54
        {
×
55
            Indented = true
×
UNCOV
56
        };
×
57

58
        using var stream = File.Create(_secretsFilePath);
×
59
        using var writer = new Utf8JsonWriter(stream, options);
×
60

UNCOV
61
        writer.WriteStartObject();
×
62

63
        foreach (var secret in _secrets.AsEnumerable())
×
UNCOV
64
            writer.WriteString(secret.Key, secret.Value);
×
65

UNCOV
66
        writer.WriteEndObject();
×
67
        writer.Flush();
×
68
    }
×
69

70
    protected virtual IDictionary<string, string?> Load(string userSecretsId)
71
    {
72
        return new ConfigurationBuilder()
×
UNCOV
73
            .AddJsonFile(_secretsFilePath, optional: true)
×
UNCOV
74
            .Build()
×
UNCOV
75
            .AsEnumerable()
×
76
            .Where(i => i.Value != null)
×
77
            .ToDictionary(i => i.Key, i => i.Value, StringComparer.OrdinalIgnoreCase);
×
78
    }
79
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc