< Summary

Information
Class: Elsa.Persistence.EFCore.Extensions.PostgreSqlProvidersExtensions
Assembly: Elsa.Persistence.EFCore.PostgreSql
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.PostgreSql/PostgreSqlProvidersExtensions.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 8
Coverable lines: 8
Total lines: 63
Line coverage: 0%
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
get_Assembly()100%210%
AddPostgreSqlEntityModelCreatingHandlers(...)100%210%
UsePostgreSql(...)100%210%
UsePostgreSql(...)100%210%
UsePostgreSql(...)100%210%
UsePostgreSql(...)100%210%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.PostgreSql/PostgreSqlProvidersExtensions.cs

#LineLine coverage
 1using System.Reflection;
 2using Elsa.Extensions;
 3using Elsa.Persistence.EFCore.PostgreSql.Handlers;
 4using Microsoft.Extensions.DependencyInjection;
 5using Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
 6
 7// ReSharper disable once CheckNamespace
 8namespace Elsa.Persistence.EFCore.Extensions;
 9
 10/// <summary>
 11/// Provides extensions to configure EF Core to use PostgreSQL.
 12/// </summary>
 13public static class PostgreSqlProvidersExtensions
 14{
 015    private static Assembly Assembly => typeof(PostgreSqlProvidersExtensions).Assembly;
 16
 17    public static IServiceCollection AddPostgreSqlEntityModelCreatingHandlers(this IServiceCollection services) =>
 018        services.TryAddScopedImplementation<IEntityModelCreatingHandler, SetupForPostgreSql>();
 19
 20    public static TFeature UsePostgreSql<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature
 21        string connectionString,
 22        ElsaDbContextOptions? options = null,
 23        Action<NpgsqlDbContextOptionsBuilder>? configure = null)
 24        where TDbContext : ElsaDbContextBase
 25        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 26    {
 027        return feature.UsePostgreSql(Assembly, connectionString, options, configure);
 28    }
 29
 30    public static TFeature UsePostgreSql<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature
 31        Func<IServiceProvider, string> connectionStringFunc,
 32        ElsaDbContextOptions? options = null,
 33        Action<NpgsqlDbContextOptionsBuilder>? configure = null)
 34        where TDbContext : ElsaDbContextBase
 35        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 36    {
 037        return feature.UsePostgreSql(Assembly, connectionStringFunc, options, configure);
 38    }
 39
 40    public static TFeature UsePostgreSql<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature
 41        Assembly migrationsAssembly,
 42        string connectionString,
 43        ElsaDbContextOptions? options = null,
 44        Action<NpgsqlDbContextOptionsBuilder>? configure = null)
 45        where TDbContext : ElsaDbContextBase
 46        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 47    {
 048        return feature.UsePostgreSql(migrationsAssembly, _ => connectionString, options, configure);
 49    }
 50
 51    public static TFeature UsePostgreSql<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature
 52        Assembly migrationsAssembly,
 53        Func<IServiceProvider, string> connectionStringFunc,
 54        ElsaDbContextOptions? options = null,
 55        Action<NpgsqlDbContextOptionsBuilder>? configure = null)
 56        where TDbContext : ElsaDbContextBase
 57        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 58    {
 059        feature.Module.Services.AddPostgreSqlEntityModelCreatingHandlers();
 060        feature.DbContextOptionsBuilder = (sp, db) => db.UseElsaPostgreSql(migrationsAssembly, connectionStringFunc(sp),
 061        return (TFeature)feature;
 62    }
 63}