< 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: 40
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    {
 121        builder.HasIndex(x => x.Name).HasDatabaseName($"IX_{nameof(User)}_{nameof(User.Name)}").IsUnique();
 122        builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(User)}_{nameof(User.TenantId)}");
 123        builder.Property(x => x.Roles).HasColumnName("Roles").HasConversion(StringCollectionToStringConverter, StringToS
 124    }
 25
 26    public void Configure(EntityTypeBuilder<Application> builder)
 27    {
 128        builder.HasIndex(x => x.ClientId).HasDatabaseName($"IX_{nameof(Application)}_{nameof(Application.ClientId)}").Is
 129        builder.HasIndex(x => x.Name).HasDatabaseName($"IX_{nameof(Application)}_{nameof(Application.Name)}").IsUnique()
 130        builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(Application)}_{nameof(Application.TenantId)}");
 131        builder.Property(x => x.Roles).HasColumnName("Roles").HasConversion(StringCollectionToStringConverter, StringToS
 132    }
 33
 34    public void Configure(EntityTypeBuilder<Role> builder)
 35    {
 136        builder.HasIndex(x => x.Name).HasDatabaseName($"IX_{nameof(Role)}_{nameof(Role.Name)}").IsUnique();
 137        builder.HasIndex(x => x.TenantId).HasDatabaseName($"IX_{nameof(Role)}_{nameof(Role.TenantId)}");
 138        builder.Property(x => x.Permissions).HasColumnName("Permissions").HasConversion(StringCollectionToStringConverte
 139    }
 40}