< Summary - Combined Code Coverage

Information
Class: NLightning.Infrastructure.Persistence.EntityConfiguration.Bitcoin.BlockchainStateEntityConfiguration
Assembly: NLightning.Infrastructure.Persistence
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Bitcoin/BlockchainStateEntityConfiguration.cs
Tag: 36_15743069263
Line coverage
0%
Covered lines: 0
Uncovered lines: 23
Coverable lines: 23
Total lines: 41
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
ConfigureBlockchainStateEntity(...)0%620%
OptimizeConfigurationForSqlServer(...)100%210%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Bitcoin/BlockchainStateEntityConfiguration.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.EntityFrameworkCore.Metadata.Builders;
 3
 4namespace NLightning.Infrastructure.Persistence.EntityConfiguration.Bitcoin;
 5
 6using Domain.Crypto.Constants;
 7using Entities.Bitcoin;
 8using Enums;
 9using ValueConverters;
 10
 11public static class BlockchainStateEntityConfiguration
 12{
 13    public static void ConfigureBlockchainStateEntity(this ModelBuilder modelBuilder, DatabaseType databaseType)
 14    {
 015        modelBuilder.Entity<BlockchainStateEntity>(entity =>
 016        {
 017            // Set PrimaryKey
 018            entity.HasKey(e => e.Id);
 019
 020            // Set required props
 021            entity.Property(e => e.LastProcessedHeight).IsRequired();
 022            entity.Property(e => e.LastProcessedBlockHash)
 023                  .HasConversion<HashConverter>()
 024                  .IsRequired();
 025            entity.Property(e => e.LastProcessedAt).IsRequired();
 026
 027            // Configure Id as Guid
 028            entity.Property(e => e.Id)
 029                  .HasConversion<Guid>()
 030                  .IsRequired();
 031
 032            if (databaseType == DatabaseType.MicrosoftSql)
 033                OptimizeConfigurationForSqlServer(entity);
 034        });
 035    }
 36
 37    private static void OptimizeConfigurationForSqlServer(EntityTypeBuilder<BlockchainStateEntity> entity)
 38    {
 039        entity.Property(e => e.LastProcessedBlockHash).HasColumnType($"varbinary({CryptoConstants.Sha256HashLen})");
 040    }
 41}