< Summary

Information
Class: Elsa.Persistence.EFCore.Modules.Identity.Configurations
Assembly: Elsa.Persistence.EFCore
File(s): /home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore/Modules/Identity/Configurations.cs
Line coverage
100%
Covered lines: 19
Uncovered lines: 0
Coverable lines: 19
Total lines: 43
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
get_StringCollectionToStringConverter()100%11100%
get_StringToStringCollectionConverter()100%11100%
.cctor()100%11100%
Configure(...)100%11100%
Configure(...)100%11100%
Configure(...)100%11100%

File(s)

/home/runner/work/elsa-core/elsa-core/src/modules/Elsa.Persistence.EFCore/Modules/Identity/Configurations.cs

#LineLine coverage
 1using System.Linq.Expressions;
 2using Elsa.Identity.Entities;
 3using Microsoft.EntityFrameworkCore;
 4using Microsoft.EntityFrameworkCore.ChangeTracking;
 5using Microsoft.EntityFrameworkCore.Metadata.Builders;
 6
 7namespace Elsa.Persistence.EFCore.Modules.Identity;
 8
 9internal class Configurations : IEntityTypeConfiguration<User>, IEntityTypeConfiguration<Application>, IEntityTypeConfig
 10{
 311    private static Expression<Func<ICollection<string>, string>> StringCollectionToStringConverter => v => string.Join("
 312    private static Expression<Func<string, ICollection<string>>> StringToStringCollectionConverter => v => v.Split(",", 
 13
 114    private static readonly ValueComparer<ICollection<string>> StringCollectionComparer = new(
 115        (c1, c2) => c1!.SequenceEqual(c2!),
 116        c => c.Aggregate(0, (a, v) => HashCode.Combine(a, v.GetHashCode())),
 117        c => c.ToList());
 18
 19    public void Configure(EntityTypeBuilder<User> builder)
 20    {
 21        // Uniqueness is per tenant, not global. A global unique index made it impossible for two tenants
 22        // to hold a role or user of the same name -- so "roles are configurable per tenant" could not be
 23        // true, however the rest of the stack behaved.
 124        builder.HasIndex(x => new { x.TenantId, x.Name }).HasDatabaseName($"IX_{nameof(User)}_{nameof(User.TenantId)}_{n
 125        builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(User)}_{nameof(User.TenantId)}");
 126        builder.Property(x => x.Roles).HasColumnName("Roles").HasConversion(StringCollectionToStringConverter, StringToS
 127    }
 28
 29    public void Configure(EntityTypeBuilder<Application> builder)
 30    {
 131        builder.HasIndex(x => new { x.TenantId, x.ClientId }).HasDatabaseName($"IX_{nameof(Application)}_{nameof(Applica
 132        builder.HasIndex(x => new { x.TenantId, x.Name }).HasDatabaseName($"IX_{nameof(Application)}_{nameof(Application
 133        builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(Application)}_{nameof(Application.TenantId)}");
 134        builder.Property(x => x.Roles).HasColumnName("Roles").HasConversion(StringCollectionToStringConverter, StringToS
 135    }
 36
 37    public void Configure(EntityTypeBuilder<Role> builder)
 38    {
 139        builder.HasIndex(x => new { x.TenantId, x.Name }).HasDatabaseName($"IX_{nameof(Role)}_{nameof(Role.TenantId)}_{n
 140        builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(Role)}_{nameof(Role.TenantId)}");
 141        builder.Property(x => x.Permissions).HasColumnName("Permissions").HasConversion(StringCollectionToStringConverte
 142    }
 43}