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

Information
Class: ZhEaIsNsAaBn.APPSettings.EFConfigurationService<T1, T2>
Assembly: ZhEaIsNsAaBn.APPSettings
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.APPSettings/Services/EFConfigurationService.cs
Line coverage
94%
Covered lines: 18
Uncovered lines: 1
Coverable lines: 19
Total lines: 58
Line coverage: 94.7%
Branch coverage
83%
Covered branches: 5
Total branches: 6
Branch coverage: 83.3%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
InsertAsync()100%11100%
InsertFromJsonAsync()100%11100%
ManualReload()83.33%6688.88%

File(s)

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

#LineLine coverage
 1namespace ZhEaIsNsAaBn.APPSettings;
 2
 3/// <summary>Default service: writes through the registered writer, then reloads the database sources.</summary>
 4internal sealed class EFConfigurationService< TSettingsTable, TDbContext > : IEFConfigurationService<TSettingsTable, TDb
 5    where TSettingsTable : class, IEFConfigurationValue, new()
 6    where TDbContext : DbContext
 7{
 8    private readonly IConfiguration                                     _configuration;
 9    private readonly IEFConfigurationWriter<TSettingsTable, TDbContext> _writer;
 10
 11
 2412    public EFConfigurationService( IConfiguration configuration, IEFConfigurationWriter<TSettingsTable, TDbContext> writ
 13    {
 2414        _configuration = configuration;
 2415        _writer        = writer;
 2416    }
 17
 18
 19    /// <inheritdoc />
 20    public async Task InsertAsync( string key, string value, CancellationToken cancellationToken = default )
 21    {
 1222        await _writer.InsertAsync( key, value, cancellationToken ).ConfigureAwait( false );
 23
 1224        ManualReload();
 1225    }
 26
 27    /// <inheritdoc />
 28    public async Task InsertFromJsonAsync( string json, CancellationToken cancellationToken = default )
 29    {
 430        await _writer.InsertFromJsonAsync( json, cancellationToken ).ConfigureAwait( false );
 31
 432        ManualReload();
 433    }
 34
 35    /// <inheritdoc />
 36    public void ManualReload()
 37    {
 2438        if ( _configuration is not IConfigurationRoot root )
 39        {
 040            throw new InvalidOperationException( "The registered IConfiguration is not an IConfigurationRoot, so it can'
 41        }
 42
 43
 2444        var reloaded = false;
 45
 8846        foreach ( var provider in root.Providers.OfType<EFConfigurationProvider<TSettingsTable, TDbContext>>() )
 47        {
 2048            provider.Reload();
 2049            reloaded = true;
 50        }
 51
 52
 2453        if ( !reloaded )
 54        {
 455            throw new InvalidOperationException( $"The registered IConfiguration has no {typeof( TSettingsTable ).Name} 
 56        }
 2057    }
 58}