< Summary

Information
Class: ClutterStock.Infrastructure.Extensions.ServiceCollectionExtensions
Assembly: Infrastructure
File(s): /home/runner/work/ClutterStock/ClutterStock/backend/src/Infrastructure/Extensions/ServiceCollectionExtensions.cs
Tag: 58_25416222083
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 22
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
AddInfrastructure(...)100%11100%

File(s)

/home/runner/work/ClutterStock/ClutterStock/backend/src/Infrastructure/Extensions/ServiceCollectionExtensions.cs

#LineLine coverage
 1using ClutterStock.Domain.Abstractions;
 2using ClutterStock.Infrastructure.Database;
 3using Microsoft.EntityFrameworkCore;
 4using Microsoft.Extensions.DependencyInjection;
 5
 6namespace ClutterStock.Infrastructure.Extensions;
 7
 8public static class ServiceCollectionExtensions
 9{
 10    public static IServiceCollection AddInfrastructure(this IServiceCollection services, string connectionString)
 11    {
 12        // Accept either a Postgres URL (postgres[ql]://…) or native key=value Npgsql format.
 313        var resolved = PostgresUrlParser.Parse(connectionString);
 14
 315        services.AddDbContext<ApplicationContext>(options =>
 316                                                      options.UseNpgsql(resolved));
 17
 318        services.AddScoped<IAppDbContext>(static sp => sp.GetRequiredService<ApplicationContext>());
 19
 320        return services;
 21    }
 22}