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

Information
Line coverage
95%
Covered lines: 22
Uncovered lines: 1
Coverable lines: 23
Total lines: 64
Line coverage: 95.6%
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(...)100%22100%
get_ContextKey()50%22100%
get_Migrations()100%11100%
get_Warnings()100%11100%
get_ProviderFactory()100%210%
WithFiles(...)100%11100%
CreateProvider(...)100%11100%
RolesFor(...)100%11100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder/Configuration/SeedConfiguration.cs

#LineLine coverage
 1#region Usings
 2using System.Collections.Concurrent;
 3#endregion
 4
 5namespace ZhEaIsNsAaBn.DbSeeder;
 6
 7/// Everything <c>Build()</c> resolved for one context: options, migrations assembly, provider and the role cache.
 8internal sealed class SeedConfiguration
 9{
 89010    private readonly ConcurrentDictionary<Type, SeedEntityRoles>                  _roles = new();
 11    private readonly Lazy<LayerResponse<IReadOnlyList<SeedMigrationFiles>>>       _migrations;
 12    private readonly Func<IServiceProvider, ISeedDatabaseProvider>                _providerFactory;
 13
 14
 15    // files: migration files (resource path → text) to use instead of the assembly's embedded ones — design tools and t
 16    // on a folder on disk.
 89017    public SeedConfiguration(
 89018            Type contextType,
 89019            Assembly assembly,
 89020            SeedOptions options,
 89021            Func<IServiceProvider, ISeedDatabaseProvider> providerFactory,
 89022            IReadOnlyDictionary<string, string>? files = null
 89023        )
 24    {
 25        ContextType      = contextType;
 89026        Assembly         = assembly;
 89027        Options          = options;
 89028        _providerFactory = providerFactory;
 89029        _migrations      = new Lazy<LayerResponse<IReadOnlyList<SeedMigrationFiles>>>( () => files is null
 89030                                                                                                         ? SeedMigration
 89031                                                                                                         : SeedMigration
 32
 33
 34        // Fail fast on configured types (wrong field types, a property in two roles).
 184935        foreach ( var settings in options.Entities.Values ) { _roles[ settings.ClrType ] = SeedEntityRoles.Resolve( sett
 88436    }
 37
 38
 39    public Type ContextType { get; }
 40
 41    /// The history key: the context's full type name (also the manifests' <c>ContextType</c>).
 175542    public string ContextKey => ContextType.FullName ?? ContextType.Name;
 43
 44    public Assembly Assembly { get; }
 45
 46    public SeedOptions Options { get; }
 47
 48    /// The embedded migrations of this context, parsed once (they can't change at run time).
 52549    public LayerResponse<IReadOnlyList<SeedMigrationFiles>> Migrations => _migrations.Value;
 50
 51    /// "Set twice" warnings of the configuration, for the CLI.
 13252    public IReadOnlyList<string> Warnings => _roles.Values.SelectMany( r => r.Warnings ).Order( StringComparer.Ordinal )
 53
 54
 055    internal Func<IServiceProvider, ISeedDatabaseProvider> ProviderFactory => _providerFactory;
 56
 57
 58    /// The same configuration reading its migrations from <paramref name="files"/> (resource path → text) instead of th
 21359    public SeedConfiguration WithFiles( IReadOnlyDictionary<string, string> files ) => new( ContextType, Assembly, Optio
 60
 42961    public ISeedDatabaseProvider CreateProvider( IServiceProvider serviceProvider ) => _providerFactory( serviceProvider
 62
 230763    public SeedEntityRoles RolesFor( Type clrType ) => _roles.GetOrAdd( clrType, t => SeedEntityRoles.Resolve( t, Option
 64}