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

Information
Class: ZhEaIsNsAaBn.DbSeeder.Registrations.SeedContextResolver
Assembly: ZhEaIsNsAaBn.DbSeeder
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder/Registrations/SeedContextResolver.cs
Line coverage
100%
Covered lines: 4
Uncovered lines: 0
Coverable lines: 4
Total lines: 17
Line coverage: 100%
Branch coverage
50%
Covered branches: 2
Total branches: 4
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Resolve(...)50%44100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.DbSeeder/Registrations/SeedContextResolver.cs

#LineLine coverage
 1namespace ZhEaIsNsAaBn.DbSeeder.Registrations;
 2
 3/// The context seed tools work on: a new one from <see cref="IDbContextFactory{TContext}"/> (owned by the caller) when 
 4/// otherwise the scoped context (not owned).
 5internal static class SeedContextResolver
 6{
 7    /// <exception cref="InvalidOperationException">The context isn't registered.</exception>
 8    public static (TDbContext Context, bool Owned) Resolve< TDbContext >( IServiceProvider serviceProvider )
 9        where TDbContext : DbContext
 10    {
 57911        if ( serviceProvider.GetService<IDbContextFactory<TDbContext>>() is { } factory ) { return ( factory.CreateDbCon
 12
 57913        return serviceProvider.GetService<TDbContext>() is { } context
 57914                   ? ( context, false )
 57915                   : throw new InvalidOperationException( $"{typeof( TDbContext ).Name} isn't registered: add it (AddDbC
 16    }
 17}