< Summary

Information
Class: Elsa.Persistence.EFCore.Extensions.SqliteProvidersExtensions
Assembly: Elsa.Persistence.EFCore.Sqlite
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Sqlite/SqliteProvidersExtensions.cs
Line coverage
87%
Covered lines: 7
Uncovered lines: 1
Coverable lines: 8
Total lines: 75
Line coverage: 87.5%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
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%
UseSqlite(...)100%11100%
UseSqlite(...)100%210%
UseSqlite(...)100%22100%
UseSqlite(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore.Sqlite/SqliteProvidersExtensions.cs

#LineLine coverage
 1using System.Reflection;
 2using Elsa.Persistence.EFCore.EntityHandlers;
 3using Elsa.Persistence.EFCore.Sqlite;
 4using Elsa.Extensions;
 5using Microsoft.EntityFrameworkCore.Infrastructure;
 6using Microsoft.Extensions.DependencyInjection;
 7using Microsoft.Extensions.DependencyInjection.Extensions;
 8
 9// ReSharper disable once CheckNamespace
 10namespace Elsa.Persistence.EFCore.Extensions;
 11
 12/// <summary>
 13/// Provides extensions to configure EF Core to use Sqlite.
 14/// </summary>
 15public static class SqliteProvidersExtensions
 16{
 217    private static Assembly Assembly => typeof(SqliteProvidersExtensions).Assembly;
 18
 19    /// <summary>
 20    /// Configures the feature to use Sqlite.
 21    /// </summary>
 22    public static TFeature UseSqlite<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
 23        string? connectionString = null,
 24        ElsaDbContextOptions? options = null,
 25        Action<SqliteDbContextOptionsBuilder>? configure = null)
 26        where TDbContext : ElsaDbContextBase
 27        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 28    {
 229        return feature.UseSqlite(Assembly, connectionString, options, configure);
 30    }
 31
 32    /// <summary>
 33    /// Configures the feature to use Sqlite.
 34    /// </summary>
 35    public static TFeature UseSqlite<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
 36        Func<IServiceProvider, string> connectionStringFunc,
 37        ElsaDbContextOptions? options = null,
 38        Action<SqliteDbContextOptionsBuilder>? configure = null)
 39        where TDbContext : ElsaDbContextBase
 40        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 41    {
 042        return feature.UseSqlite(Assembly, connectionStringFunc, options, configure);
 43    }
 44
 45    /// <summary>
 46    /// Configures the feature to use Sqlite.
 47    /// </summary>
 48    public static TFeature UseSqlite<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
 49        Assembly migrationsAssembly,
 50        string? connectionString = null,
 51        ElsaDbContextOptions? options = null,
 52        Action<SqliteDbContextOptionsBuilder>? configure = null)
 53        where TDbContext : ElsaDbContextBase
 54        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 55    {
 256        connectionString ??= "Data Source=elsa.sqlite.db;Cache=Shared;";
 257        return feature.UseSqlite(migrationsAssembly, _ => connectionString, options, configure);
 58    }
 59
 60    /// <summary>
 61    /// Configures the feature to use Sqlite.
 62    /// </summary>
 63    public static TFeature UseSqlite<TFeature, TDbContext>(this PersistenceFeatureBase<TFeature, TDbContext> feature,
 64        Assembly migrationsAssembly,
 65        Func<IServiceProvider, string> connectionStringFunc,
 66        ElsaDbContextOptions? options = null,
 67        Action<SqliteDbContextOptionsBuilder>? configure = null)
 68        where TDbContext : ElsaDbContextBase
 69        where TFeature : PersistenceFeatureBase<TFeature, TDbContext>
 70    {
 271        feature.Module.Services.TryAddScopedImplementation<IEntityModelCreatingHandler, SetupForSqlite>();
 272        feature.DbContextOptionsBuilder = (sp, db) => db.UseElsaSqlite(migrationsAssembly, connectionStringFunc(sp), opt
 273        return (TFeature)feature;
 74    }
 75}