< Summary - ZhEaIsNsAaBn.Libraries coverage (affected: 23 packages)

Information
Class: ZhEaIsNsAaBn.APPSettings.EFConfigurationProvider<T1, T2>
Assembly: ZhEaIsNsAaBn.APPSettings
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.APPSettings/EFConfigurationProvider.cs
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 44
Line coverage: 100%
Branch coverage
75%
Covered branches: 3
Total branches: 4
Branch coverage: 75%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)50%22100%
Load()100%22100%
Reload()100%11100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.APPSettings/EFConfigurationProvider.cs

#LineLine coverage
 1namespace ZhEaIsNsAaBn.APPSettings;
 2
 3/// <summary>Configuration provider that reads key/value rows from a database table through EF Core.</summary>
 4/// <typeparam name="TSettingsTable">The settings entity.</typeparam>
 5/// <typeparam name="TDbContext">The context that holds the settings table.</typeparam>
 6public sealed class EFConfigurationProvider< TSettingsTable, TDbContext > : ConfigurationProvider
 7    where TSettingsTable : class, IEFConfigurationValue, new()
 8    where TDbContext : DbContext
 9{
 10    private readonly EFConfigurationProviderSettings<TSettingsTable, TDbContext> _settings;
 11
 12
 13    /// <summary>Creates the provider.</summary>
 14    /// <param name="settings">The provider settings.</param>
 15    /// <exception cref="ArgumentNullException"><paramref name="settings"/> is <see langword="null"/>.</exception>
 4416    public EFConfigurationProvider( EFConfigurationProviderSettings<TSettingsTable, TDbContext> settings )
 4417        => _settings = settings ?? throw new ArgumentNullException( nameof( settings ) );
 18
 19
 20    /// <summary>
 21    /// Reads the rows matching the query (no tracking). Keys are case-insensitive; when two rows share a key, the last 
 22    /// </summary>
 23    /// <exception cref="InvalidOperationException">No <see cref="IDbContextFactory{TContext}"/> is set.</exception>
 24    public override void Load()
 25    {
 6426        using var context = _settings.GetRequiredDbContextFactory().CreateDbContext();
 27
 6428        var data = new Dictionary<string, string?>( StringComparer.OrdinalIgnoreCase );
 29
 30
 32031        foreach ( var row in context.Set<TSettingsTable>().AsNoTracking().Where( _settings.Query ) ) { data[ row.Key ] =
 32
 33
 6434        Data = data;
 12835    }
 36
 37    /// <summary>Reads the table again and signals the change, so reload tokens and <c>IOptionsMonitor</c> see the new v
 38    /// <exception cref="InvalidOperationException">No <see cref="IDbContextFactory{TContext}"/> is set.</exception>
 39    public void Reload()
 40    {
 2041        Load();
 2042        OnReload();
 2043    }
 44}