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

Information
Class: ZhEaIsNsAaBn.DbSeeder.Design.DesignSession
Assembly: ZhEaIsNsAaBn.DbSeeder.Design
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder.Design/Commands/DesignSession.cs
Line coverage
100%
Covered lines: 13
Uncovered lines: 0
Coverable lines: 13
Total lines: 53
Line coverage: 100%
Branch coverage
85%
Covered branches: 12
Total branches: 14
Branch coverage: 85.7%
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_Provider()100%11100%
Designer(...)50%22100%
HostEnvironmentName()83.33%66100%
Report(...)100%66100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder.Design/Commands/DesignSession.cs

#LineLine coverage
 1namespace ZhEaIsNsAaBn.DbSeeder.Design;
 2
 3/// What every command works on: the context, its seed configuration, the app's services and the console. One per <c>Run
 4internal sealed class DesignSession
 5{
 6    private readonly IServiceProvider _services;
 7
 8
 4119    public DesignSession( DbContext dbContext, SeedConfiguration configuration, IServiceProvider services, IAnsiConsole 
 10    {
 11        DbContext     = dbContext;
 12        Configuration = configuration;
 41113        _services     = services;
 14        Console       = console;
 41115    }
 16
 17
 18    public DbContext DbContext { get; }
 19
 20    public SeedConfiguration Configuration { get; }
 21
 22    public IAnsiConsole Console { get; }
 23
 24    /// The context's database provider (as registered with <c>UseSqlServer()</c> …).
 18625    public ISeedDatabaseProvider Provider => Configuration.CreateProvider( _services );
 26
 27
 41128    public SeedDesigner Designer( DesignSettings settings ) => new( DbContext, Configuration, settings.Directory ?? Envi
 29
 30    /// The app host's environment name (IHostEnvironment.EnvironmentName), <see langword="null"/> without a host. Found
 31    /// doesn't depend on Hosting, and an app with a host has its abstractions loaded.
 32    public string? HostEnvironmentName()
 33    {
 2434        var contract = AppDomain.CurrentDomain.GetAssemblies()
 2435                                .Select( a => a.GetType( "Microsoft.Extensions.Hosting.IHostEnvironment", throwOnError: 
 2436                                .FirstOrDefault( t => t is not null );
 37
 2438        return contract is not null && _services.GetService( contract ) is { } environment ? contract.GetProperty( "Envi
 39    }
 40
 41    /// Prints messages, warnings (yellow) and errors (red); returns the exit code.
 42    public int Report( DesignResult result )
 43    {
 216044        foreach ( var message in result.Messages ) { Console.WriteLine( message ); }
 45
 49546        foreach ( var warning in result.Warnings ) { Console.MarkupLine( $"[yellow]warning:[/] {Markup.Escape( warning )
 47
 57648        foreach ( var error in result.Errors ) { Console.MarkupLine( $"[red]error:[/] {Markup.Escape( error )}" ); }
 49
 50
 24351        return result.ExitCode;
 52    }
 53}