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

Information
Class: Microsoft.EntityFrameworkCore.InfrastructureServiceExtensions
Assembly: ZhEaIsNsAaBn.Infrastructure.Core
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.Core/Extensions/InfrastructureServiceExtensions.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 46
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetDbErrorClassifier(...)100%11100%
GetStoredProcedureExecutor(...)100%11100%
GetModelDefaultsProvider(...)100%11100%
RequireStoredProcedureExecutor(...)100%22100%
Find(...)100%11100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.Core/Extensions/InfrastructureServiceExtensions.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore.Infrastructure;
 2using ZhEaIsNsAaBn.Infrastructure.Core;
 3
 4// ReSharper disable once CheckNamespace
 5namespace Microsoft.EntityFrameworkCore;
 6
 7/// <summary>
 8/// Reads the provider handlers registered for one <see cref="DbContext"/> through an <c>IDbContextOptionsExtension</c> 
 9/// <c>UseSqlServerInfrastructure()</c>). They live in the context's internal service provider, so each context can use 
 10/// provider; they are never resolved from the app's DI container.
 11/// </summary>
 12public static class InfrastructureServiceExtensions
 13{
 14    /// <summary>The context's error classifier.</summary>
 15    /// <param name="dbContext">The context.</param>
 16    /// <returns>The classifier, or <see langword="null"/> when no provider registered one.</returns>
 17    /// <exception cref="ArgumentNullException"><paramref name="dbContext"/> is <see langword="null"/>.</exception>
 58818    public static IDbErrorClassifier? GetDbErrorClassifier( this DbContext dbContext ) => Find<IDbErrorClassifier>( dbCo
 19
 20    /// <summary>The context's stored-procedure executor.</summary>
 21    /// <param name="dbContext">The context.</param>
 22    /// <returns>The executor, or <see langword="null"/> when no provider registered one.</returns>
 23    /// <exception cref="ArgumentNullException"><paramref name="dbContext"/> is <see langword="null"/>.</exception>
 5624    public static IStoredProcedureExecutor? GetStoredProcedureExecutor( this DbContext dbContext ) => Find<IStoredProced
 25
 26    /// <summary>The context's model defaults.</summary>
 27    /// <param name="dbContext">The context.</param>
 28    /// <returns>The defaults, or <see langword="null"/> when no provider registered them.</returns>
 29    /// <exception cref="ArgumentNullException"><paramref name="dbContext"/> is <see langword="null"/>.</exception>
 6030    public static IModelDefaultsProvider? GetModelDefaultsProvider( this DbContext dbContext ) => Find<IModelDefaultsPro
 31
 32
 33    /// <summary>The executor, or a clear <see cref="InvalidOperationException"/>.</summary>
 34    internal static IStoredProcedureExecutor RequireStoredProcedureExecutor( this DbContext dbContext )
 4035        => dbContext.GetStoredProcedureExecutor()
 4036           ?? throw new InvalidOperationException( $"No stored-procedure executor is registered for {dbContext.GetType()
 4037                                                   + "e.g. options.UseSqlServer( connectionString ).UseSqlServerInfrastr
 38
 39    private static T? Find< T >( DbContext dbContext )
 40        where T : class
 41    {
 70442        ArgumentNullException.ThrowIfNull( dbContext );
 43
 70444        return dbContext.GetInfrastructure().GetService<T>();
 45    }
 46}