< 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
85%
Covered lines: 6
Uncovered lines: 1
Coverable lines: 7
Total lines: 59
Line coverage: 85.7%
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%11100%
UsePostgreSql(...)100%11100%
UsePostgreSql(...)100%210%
UsePostgreSql(...)100%11100%
UsePostgreSql(...)100%11100%

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 Npgsql.EntityFrameworkCore.PostgreSQL.Infrastructure;
 5
 6// ReSharper disable once CheckNamespace
 7namespace Elsa.Persistence.EFCore.Extensions;
 8
 9/// <summary>
 10/// Provides extensions to configure EF Core to use PostgreSQL.
 11/// </summary>
 12public static class PostgreSqlProvidersExtensions
 13{
 414    private static Assembly Assembly => typeof(PostgreSqlProvidersExtensions).Assembly;
 15
 16    public static TFeature UsePostgreSql<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature
 17        string connectionString,
 18        ElsaDbContextOptions? options = null,
 19        Action<NpgsqlDbContextOptionsBuilder>? configure = null)
 20        where TDbContext : ElsaDbContextBase
 21        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 22    {
 423        return feature.UsePostgreSql(Assembly, connectionString, options, configure);
 24    }
 25
 26    public static TFeature UsePostgreSql<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature
 27        Func<IServiceProvider, string> connectionStringFunc,
 28        ElsaDbContextOptions? options = null,
 29        Action<NpgsqlDbContextOptionsBuilder>? configure = null)
 30        where TDbContext : ElsaDbContextBase
 31        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 32    {
 033        return feature.UsePostgreSql(Assembly, connectionStringFunc, options, configure);
 34    }
 35
 36    public static TFeature UsePostgreSql<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature
 37        Assembly migrationsAssembly,
 38        string connectionString,
 39        ElsaDbContextOptions? options = null,
 40        Action<NpgsqlDbContextOptionsBuilder>? configure = null)
 41        where TDbContext : ElsaDbContextBase
 42        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 43    {
 165744        return feature.UsePostgreSql(migrationsAssembly, _ => connectionString, options, configure);
 45    }
 46
 47    public static TFeature UsePostgreSql<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature
 48        Assembly migrationsAssembly,
 49        Func<IServiceProvider, string> connectionStringFunc,
 50        ElsaDbContextOptions? options = null,
 51        Action<NpgsqlDbContextOptionsBuilder>? configure = null)
 52        where TDbContext : ElsaDbContextBase
 53        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 54    {
 455        feature.Module.Services.TryAddScopedImplementation<IEntityModelCreatingHandler, SetupForPostgreSql>();
 165756        feature.DbContextOptionsBuilder = (sp, db) => db.UseElsaPostgreSql(migrationsAssembly, connectionStringFunc(sp),
 457        return (TFeature)feature;
 58    }
 59}