< Summary - Combined Code Coverage

Information
Class: NLightning.Infrastructure.Persistence.EntityConfiguration.Node.PeerEntityConfiguration
Assembly: NLightning.Infrastructure.Persistence
File(s): /home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Node/PeerEntityConfiguration.cs
Tag: 36_15743069263
Line coverage
0%
Covered lines: 0
Uncovered lines: 21
Coverable lines: 21
Total lines: 39
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
ConfigurePeerEntity(...)0%620%
OptimizeConfigurationForSqlServer(...)100%210%

File(s)

/home/runner/work/nlightning/nlightning/src/NLightning.Infrastructure.Persistence/EntityConfiguration/Node/PeerEntityConfiguration.cs

#LineLine coverage
 1using Microsoft.EntityFrameworkCore;
 2using Microsoft.EntityFrameworkCore.Metadata.Builders;
 3
 4namespace NLightning.Infrastructure.Persistence.EntityConfiguration.Node;
 5
 6using Domain.Crypto.Constants;
 7using Entities.Node;
 8using Enums;
 9using ValueConverters;
 10
 11public static class PeerEntityConfiguration
 12{
 13    public static void ConfigurePeerEntity(this ModelBuilder modelBuilder, DatabaseType databaseType)
 14    {
 015        modelBuilder.Entity<PeerEntity>(entity =>
 016        {
 017            // Set PrimaryKey
 018            entity.HasKey(e => e.NodeId);
 019
 020            // Set required props
 021            entity.Property(e => e.Host).IsRequired();
 022            entity.Property(e => e.Port).IsRequired();
 023            entity.Property(e => e.LastSeenAt).IsRequired();
 024
 025            // Required byte[] properties
 026            entity.Property(e => e.NodeId)
 027                  .HasConversion<CompactPubKeyConverter>()
 028                  .IsRequired();
 029
 030            if (databaseType == DatabaseType.MicrosoftSql)
 031                OptimizeConfigurationForSqlServer(entity);
 032        });
 033    }
 34
 35    private static void OptimizeConfigurationForSqlServer(EntityTypeBuilder<PeerEntity> entity)
 36    {
 037        entity.Property(e => e.NodeId).HasColumnType($"varbinary({CryptoConstants.CompactPubkeyLen})");
 038    }
 39}