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

Information
Class: ZhEaIsNsAaBn.Infrastructure.Specifications.SpecificationUnitOfWork<T>
Assembly: ZhEaIsNsAaBn.Infrastructure.Specifications
File(s): /home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.Specifications/UnitOfWork/SpecificationUnitOfWork.cs
Line coverage
100%
Covered lines: 8
Uncovered lines: 0
Coverable lines: 8
Total lines: 34
Line coverage: 100%
Branch coverage
75%
Covered branches: 6
Total branches: 8
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%11100%
Repository()75%44100%
Repository()75%44100%

File(s)

/home/runner/work/ZhEaIsNsAaBn.Libraries.V1/ZhEaIsNsAaBn.Libraries.V1/src/DataBasePackages/ZhEaIsNsAaBn.Infrastructure.Specifications/UnitOfWork/SpecificationUnitOfWork.cs

#LineLine coverage
 1using Microsoft.Extensions.DependencyInjection;
 2
 3namespace ZhEaIsNsAaBn.Infrastructure.Specifications;
 4
 5/// <summary>Core <see cref="BaseUnitOfWork{TDbContext}"/> that also hands out specification repositories from DI.</summ
 6/// <typeparam name="TDbContext">The application's context.</typeparam>
 7public class SpecificationUnitOfWork< TDbContext > : BaseUnitOfWork<TDbContext>, ISpecificationUnitOfWork<TDbContext>
 8    where TDbContext : DbContext
 9{
 10    private readonly IServiceProvider _serviceProvider;
 11
 12
 13    /// <summary>Creates the unit of work.</summary>
 14    /// <param name="serviceProvider">The service provider repositories are resolved from.</param>
 15    /// <param name="dbContextProvider">The context provider (same one the repositories use).</param>
 816    public SpecificationUnitOfWork( IServiceProvider serviceProvider, IDbContextProvider<TDbContext> dbContextProvider )
 817        => _serviceProvider = serviceProvider;
 18
 19
 20    /// <inheritdoc />
 21    public ISpecificationRepository<TEntity, TId> Repository< TEntity, TId >()
 22        where TEntity : class, IBaseEntity<TId>
 23        where TId : struct, IEquatable<TId>
 424        => _serviceProvider.GetService<ISpecificationRepository<TEntity, TId>>()
 425           ?? _serviceProvider.GetService<ISpecificationRepository<TDbContext, TEntity, TId>>()
 426           ?? throw new InvalidOperationException( $"No specification repository is registered for {typeof( TEntity ).Na
 27
 28    /// <inheritdoc />
 29    public ISpecificationRepository<TEntity> Repository< TEntity >()
 30        where TEntity : class, IBaseEntity
 431        => _serviceProvider.GetService<ISpecificationRepository<TEntity>>()
 432           ?? _serviceProvider.GetService<ISpecificationIntRepository<TDbContext, TEntity>>()
 433           ?? throw new InvalidOperationException( $"No specification repository is registered for {typeof( TEntity ).Na
 34}