< Summary

Information
Class: AsiBackbone.EntityFrameworkCore.Configurations.CapabilityGrantUseEntityConfiguration
Assembly: AsiBackbone.EntityFrameworkCore
File(s): /home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.EntityFrameworkCore/Configurations/CapabilityGrantUseEntityConfiguration.cs
Line coverage
100%
Covered lines: 17
Uncovered lines: 0
Coverable lines: 17
Total lines: 32
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
.cctor()100%11100%
Configure(...)100%11100%

File(s)

/home/runner/work/AsiBackbone/AsiBackbone/src/AsiBackbone.EntityFrameworkCore/Configurations/CapabilityGrantUseEntityConfiguration.cs

#LineLine coverage
 1using AsiBackbone.EntityFrameworkCore.Persistence;
 2using Microsoft.EntityFrameworkCore;
 3using Microsoft.EntityFrameworkCore.Metadata.Builders;
 4using Microsoft.EntityFrameworkCore.Storage.ValueConversion;
 5
 6namespace AsiBackbone.EntityFrameworkCore.Configurations;
 7
 8/// <summary>Configures durable capability-grant use records.</summary>
 9public sealed class CapabilityGrantUseEntityConfiguration : IEntityTypeConfiguration<CapabilityGrantUseEntity>
 10{
 111    private static readonly ValueConverter<DateTimeOffset, long> DateTimeOffsetToUtcTicksConverter = new(
 112        value => value.ToUniversalTime().Ticks,
 113        value => new DateTimeOffset(value, TimeSpan.Zero));
 14
 15    /// <inheritdoc />
 16    public void Configure(EntityTypeBuilder<CapabilityGrantUseEntity> builder)
 17    {
 2018        ArgumentNullException.ThrowIfNull(builder);
 2019        _ = builder.ToTable("AsiBackboneCapabilityGrantUses");
 2020        _ = builder.HasKey(entity => entity.Id);
 2021        _ = builder.Property(entity => entity.Id).ValueGeneratedNever();
 2022        _ = builder.Property(entity => entity.ConcurrencyStamp).IsRequired().HasMaxLength(64).IsConcurrencyToken();
 2023        _ = builder.Property(entity => entity.Issuer).IsRequired().HasMaxLength(256);
 2024        _ = builder.Property(entity => entity.TokenId).IsRequired().HasMaxLength(256);
 2025        _ = builder.Property(entity => entity.UseCount).IsRequired();
 2026        _ = builder.Property(entity => entity.State).HasConversion<string>().IsRequired().HasMaxLength(64);
 2027        _ = builder.Property(entity => entity.LastUsedUtc).HasConversion(DateTimeOffsetToUtcTicksConverter).IsRequired()
 2028        _ = builder.Property(entity => entity.RetainUntilUtc).HasConversion(DateTimeOffsetToUtcTicksConverter).IsRequire
 2029        _ = builder.HasIndex(entity => new { entity.Issuer, entity.TokenId }).IsUnique();
 2030        _ = builder.HasIndex(entity => entity.RetainUntilUtc);
 2031    }
 32}