< Summary

Information
Class: Infrastructure.DependencyInjectionContainer
Assembly: Infrastructure
File(s): /home/runner/work/Northwind-Api/Northwind-Api/src/Infrastructure/DependencyInjectionContainer.cs
Line coverage
34%
Covered lines: 11
Uncovered lines: 21
Coverable lines: 32
Total lines: 50
Line coverage: 34.3%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddInfrastructure(...)0%3234.37%

File(s)

/home/runner/work/Northwind-Api/Northwind-Api/src/Infrastructure/DependencyInjectionContainer.cs

#LineLine coverage
 1using Infrastructure.Context;
 2using Infrastructure.Repository;
 3using Microsoft.EntityFrameworkCore;
 4using Microsoft.EntityFrameworkCore.Diagnostics;
 5using Microsoft.Extensions.Configuration;
 6using Microsoft.Extensions.DependencyInjection;
 7using Microsoft.Extensions.Hosting;
 8using Microsoft.Extensions.Logging;
 9
 10namespace Infrastructure;
 11public static class DependencyInjectionContainer {
 12  const int POOL_SIZE = 1024;
 13
 114  public static IServiceCollection AddInfrastructure(this IServiceCollection services, IHostEnvironment environment, ICo
 15
 116    services.AddScoped<NorthwindRepository>();
 17
 118    var connection = configuration.GetConnectionString("DefaultConnection");
 19
 120    services.AddPooledDbContextFactory<NorthwindContext>((sp, options) => {
 021      options.UseQueryTrackingBehavior(QueryTrackingBehavior.NoTracking);
 122
 023      if (environment.IsDevelopment()) {
 024        options.EnableDetailedErrors();
 025        options.EnableSensitiveDataLogging();
 026      }
 027      var loggerFactory = sp.GetRequiredService<ILoggerFactory>();
 028      options.UseLoggerFactory(loggerFactory);
 129
 030      options.LogTo(
 031        message => loggerFactory.CreateLogger("EFCore"),
 032        [DbLoggerCategory.Database.Command.Name],
 033        LogLevel.Information,
 034        DbContextLoggerOptions.SingleLine
 035      );
 136
 037      options.UseNpgsql(connection, sqlOptions => {
 038        sqlOptions.EnableRetryOnFailure(
 039          maxRetryCount: 10,
 040          maxRetryDelay: TimeSpan.FromSeconds(10),
 041          errorCodesToAdd: []
 042        );
 043      });
 144
 045    },
 146    POOL_SIZE);
 47
 148    return services;
 149  }
 50}